Tag Archives: ios

(Objective C) Enable UIButton inside UIImageView

When you add a UIButton as a subview to UIImageView, it will not correspond to touch events automatically, UIImageView’s userinteraction property needs to be set

Posted in Objective-C | Also tagged , , , , , , | Leave a comment

Scaling an image in Objective-C (Cocoa Framework)

The UIImage class can be used to represent an image. The following snippet scales an image according to a size which is provided with a CGSize parameter. + (UIImage *)scale:(UIImage *)image toSize:(CGSize)size { UIGraphicsBeginImageContext(size); [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return scaledImage; }

Posted in Objective-C | Also tagged , , , , , , , , , , | Leave a comment

Run a method in a separate thread in Objective-C (Cocoa Framework)

In some situations, performing operations in a single thread can cause an application to appear as if it is hanging. For example, when searching with autocomplete enabled within a large amount of records in a database . The user is typing and the application is performing a computationally complex operation at the same time (searching [...]

Posted in Objective-C | Also tagged , , , , , , , , , , | 1 Comment

Date Formatting in Objective-C (Cocoa Framework)

Date Formatting in Objective-C //Format Date NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat: @"yyyy-MM-dd HH:mm:ss zzz"]; // 2009-02-01 19:50:41 PST NSString *dateString = [dateFormat stringFromDate: [scoreData objectForKey: @"date"]]; http://codesnippets.joyent.com/posts/show/12740

Posted in Objective-C | Also tagged , , , , , , , , , , | Leave a comment

Get Device GUID from iPhone

Get Device GUID from iPhone UIDevice *device = [UIDevice currentDevice]; NSString *uniqueIdentifier = [device uniqueIdentifier]; http://codesnippets.joyent.com/posts/show/12741

Posted in Objective-C | Also tagged , , , , , | Leave a comment

Show/Hide iPhone Status Bar

Show/Hide iPhone Status Bar //Hide [UIApplication sharedApplication].statusBarHidden = YES; //Show [UIApplication sharedApplication].statusBarHidden = NO; http://codesnippets.joyent.com/posts/show/12742

Posted in Objective-C | Also tagged , , , , , , , | Leave a comment

Toggle iPhone network indicator in status bar

Toggle iPhone network indicator in status bar //show [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; //hide [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; http://codesnippets.joyent.com/posts/show/12742

Posted in Objective-C | Also tagged , , , , , , , , | Leave a comment

Simple alert box on iPhone

Simple alert box on iPhone UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @”Network error” message: @”Error sending your info to the server” delegate: self cancelButtonTitle: @”Ok” otherButtonTitles: nil]; [someError show]; [someError release]; http://codesnippets.joyent.com/posts/show/12744

Posted in Objective-C | Also tagged , , , , , , , , | Leave a comment

(iPhone) IOS TableViews in Navigation Controller

Pulls data from a plist set up as a dictionary of arrays of strings. Creates multi-level TableView that can be nested inside a navigation controller. Snippet shows key methods for 2 nested levels. 2 levels –> 2 classes (both of which extend UITableViewController)

Posted in Objective-C | Also tagged , , , | Leave a comment

UIWebView to display web content (Cocoa Framework)

UIWebViews can be used to display web pages (for example, within iPhone applications). The snippets below demonstrate a view controller to display http://snipd.net .

Posted in Objective-C | Also tagged , , , , , , , , | Leave a comment