我想做以下事情:
[self.navigationController performSelectorOnMainThread:@selector(pushViewController:animated:) withObject:<#(id)#> waitUntilDone:NO];
我不知道如何在这里传递视图控制器和bool动画值?谁能帮我吗?我的猜测是我在withObject中传入一个NSDictionary?
答案 0 :(得分:4)
超级方法(pushViewController:animated :)无法覆盖,所以你应该像下面的代码一样。
[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]];
}
答案 1 :(得分:0)
你可能想制作一种方法来做那些事情。
[self.navigationController performSelectorOnMainThread:@selector(pushViewController:animated:) withObject:<#(id)#> waitUntilDone:NO];
将成为:
[self.navigationController performSelectorOnMainThread:@selector(someMethod) withObject:<#(id)#> waitUntilDone:NO];
-(void)someMethod
{
//pushViewController:animated: //and other stuffs
}