I have a UIView
with a UITableView
and a UIImageView
in it. The UITableView
takes up the top half of the UIView
. The UIImageView
takes the bottom half of the UIView
.
I am using an NSTimer
to update the image that is being displayed in the UIImageView
. Basically, every 3 seconds, the UIImageView
loads in a new UIImage
.
Problem is, if I select a row from the UITableView
, the NSTimer
keeps running. How can I stop the NSTimer
on didSelectRowFromIndexPath
, and then start it again when the view returns to the screen?
-(void)viewDidLoad {
NSThread* timerThread = [[NSThread alloc] initWithTarget:self selector:@selector(startTimerThread) object:nil]; //Create a new thread
[timerThread start]; //start the thread
} // end viewDidLoad
//
-(void) startTimerThread {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
[[NSTimer scheduledTimerWithTimeInterval: 3.0
target: self
selector: @selector(loadNextPhoto)
userInfo: nil
repeats: YES] retain];
[runLoop run];
[pool release];
}