Lecture 16

Lecture 16 - Stanford CS193p Fall 2011 Developing...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Stanford CS193p Fall 2011 Developing Applications for iOS Fall 2011 Stanford CS193p Stanford CS193p Fall 2011 Today NSTimer and perform after delay Two delayed-action alternatives. More View Animation Continuation of Kitchen Sink demo Alerts and Action Sheets Notifying the user and getting modal answers to questions. UIImagePickerController Getting images from the camera or photo library. Core Motion Measuring the devices movement. Stanford CS193p Fall 2011 NSTimer Scheduled invocation of a method in the main queue NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:self selector:@selector(doSomething:) userInfo:(id)anyObject repeats:(BOOL)yesOrNo]; Not real time since it can run only each time around run loop Setting the time interval too short will essentially block the main thread. Taking too long each time youre called could also essentially block the main thread. Do any time consuming stuff in a thread and just use the timer to update state quickly. Stopping the timer- (void)invalidate; You probably want to nil-out your pointers to the timer after this! Stanford CS193p Fall 2011 Perform after Delay Alternative to NSTimer NSObject method:- (void)performSelector:(SEL)aSelector withObject:(id)argument afterDelay:(NSTimeInterval)seconds; Executes on the run loop (if any) of the current thread Only call this on the main thread (other threads possible, but not straightforward). Not real time (just like NSTimer is not). Does not execute immediately, even if seconds is (executes very very soon in that case). Can reschedule itself. Be careful that it stops calling itself when your view controller goes off screen, though. Example [self.tableView performSelector:@selector(reloadData) withObject:nil afterDelay:0]; Gives the UITableView a chance to settle down (by nishing this turn of the event loop). Stanford CS193p Fall 2011 Perform after Delay Canceling NSObject class method: + (void)cancelPreviousPerformRequestsWithTarget:(id)target selector:(SEL)aSelector object:(id)object; + (void)cancelPreviousPerformRequestsWithTarget:(id)target; There is no way to query what requests are outstanding At best, you can cancel and repost to be sure (but it will reset timing, of course). Stanford CS193p Fall 2011 Demo Kitchen Sink More sophisticated UIView animation NSTimer performSelector:withObject:afterDelay: Stanford CS193p Fall 2011 Alerts Two kinds of pop up and ask the user something mechanisms Action Sheets Alerts Action Sheets Slides up from the bottom of the screen on iPhone/iPod Touch, and in a popover on iPad. Can be displayed from a tab bar, toolbar, bar button item or from a rectangular area in a view....
View Full Document

This note was uploaded on 01/25/2012 for the course CS 193P taught by Professor Evandoll during the Fall '09 term at Stanford.

Page1 / 32

Lecture 16 - Stanford CS193p Fall 2011 Developing...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online