Category Archives: Objective-C

Play a movie in fullscreen (Objective-C)

Hi, In reply to http://snipd.net/objective-c-play-a-video-in-full-screen#comment-290 . The following snippets show how to play a movie in fullscreen.

Posted in Objective-C | Tagged , , , , , , , | Leave a comment

(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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | Tagged , , , , , , , , , | Leave a comment

Animate A Fade-Out Of A NSWindow With Objective-C

Animate A Fade-Out Of A NSWindow With Objective-C – (void)fadeOutWindow:(NSWindow*)window{ float alpha = 1.0; [window setAlphaValue:alpha]; [window makeKeyAndOrderFront:self]; for (int x = 0; x < 10; x++) { alpha -= 0.1; [window setAlphaValue:alpha]; [NSThread sleepForTimeInterval:0.020]; } } http://codesnippets.joyent.com/posts/show/12745

Posted in Objective-C | Tagged , , , , , , , , | Leave a comment