Checkbox image toggle in UITableViewCell

It’s actually pretty easy. Just create a new subclass of UIControl and put it all in there (no need for a separate controller.) Let’s call it ToggleImageControl. @interface ToggleImageControl : UIControl { BOOL selected; UIImageView *imageView; UIImage *normalImage; UIImage *selectedImage; } Create a ToggleImageControl for each cell, and add it at the appropriate position. ToggleImageControl … Read more

Set dimensions for UIImagePickerController “move and scale” cropbox

Not possible with UIImagePickerController unfortunately. The solution I recommend is to disable editing for the image picker and handle it yourself. For instance, I put the image in a scrollable, zoomable image view. On top of the image view is a fixed position “crop guide view” that draws the crop indicator the user sees. Assuming … Read more

Adding unknown number of rows to ‘Static Cells’ UITableView

To add dynamic cells to a static cells table you have to override every UITableView delegate method that has an indexPath. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath -(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath -(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath -(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath . -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath … Read more

Simple http post example in Objective-C?

This is what I recently used, and it worked fine for me: NSString *post = @”key1=val1&key2=val2″; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@”%d”, [postData length]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:@”http://www.nowhere.com/sendFormHere.php”]]; [request setHTTPMethod:@”POST”]; [request setValue:postLength forHTTPHeaderField:@”Content-Length”]; [request setValue:@”application/x-www-form-urlencoded” forHTTPHeaderField:@”Content-Type”]; [request setHTTPBody:postData]; Originally taken from http://deusty.blogspot.com/2006/11/sending-http-get-and-post-from-cocoa.html, but that … Read more