issue with pushViewController on main thread
I would like to do the following:
[self.navigationController performSelectorOnMainThread:@selector(pushViewController:animated:) withObject:<#(id)#> waitUntilDone:NO];
I am not sure however on how to pass in the view controller and the bool animated value in here? Can anyone help me out? My guess is that I pass in a NSDictionary in the withObject?开发者_运维知识库
Super methods(pushViewController:animated:) can not override, so you should be like a below code.
[self performSelectorOnMainThread:@selector(pushMyViewController:) withObject:[NSDictionary dictionaryWithObjectsAndKeys:<#yourViewController#>,@"viewController", [NSNumber numberWithBool:YES], @"animated", nil] waitUntilDone:NO];
- (void)pushMyViewController:(NSDictionary *)info
{
[self.navigationController pushViewController:[info valueForKey:@"viewController"] animated:[[info valueForKey:@"animated"] boolValue]];
}
You probably want to make a method to do that stuff.
[self.navigationController performSelectorOnMainThread:@selector(pushViewController:animated:) withObject:<#(id)#> waitUntilDone:NO];
Will become:
[self.navigationController performSelectorOnMainThread:@selector(someMethod) withObject:<#(id)#> waitUntilDone:NO];
-(void)someMethod
{
//pushViewController:animated: //and other stuffs
}
精彩评论