I have a modal view controller that initiates a process. If I dismiss the modal view controller, then reopen it, it c开发者_JAVA技巧ontinues from where it left off. What I want is to (upon dismissal) reset the modal view controller, cancel all processing and reset it to it's initial state. Is there a way?
Cheers
Don't save the UIViewController
subclass object in an ivar, just alloc] init]
a new one every time you want to present one.
sorry if I'll say something obvious, but I spent some of time to figure out how to do this:
Don't save the
UIViewController
subclass object in an ivar, justalloc] init]
a new one every time you want to present one.
In my case I have this code in MasterViewController.h
@property (strong, nonatomic) ContactsDetailViewController *detailViewController;
and this one in MasterViewController.m
@synthesize detailViewController = _detailViewController;
if (!self.detailViewController) {
self.detailViewController = [[ContactsDetailViewController alloc]
initWithNibName:@"ContactsDetailViewController"
bundle:nil];
}
You should delete this code and use next code in place, where you pushing your modal view controller:
ContactsDetailViewController *detailViewController = [[ContactsDetailViewController alloc] initWithNibName:@"ContactsDetailViewController" bundle:nil];
detailViewController.title = @"View Controller"; // for example
[self.navigationController pushViewController:detailViewController animated:YES];
note: I'm using ARC in this project
Hope it will be helpful for someone
IN the viewDidUnload method of the viewController for your modal view, try stopping the task.
精彩评论