当我在 iOS 4.3 中调用 ViewDidAppear 时它不起作用?
我有一个 UITabBarController,其中包括四个 UIViewController,当我想调用 viewDidAppear 时它不起作用。我不明白为什么只有 iOS 4.3 才会出现这种情况?
//
UINavigationController *nav3 = [[UINavigationController alloc] init];
SearchViewController *searchViewController = [[SearchViewController alloc] init];
searchViewController.context = context;
[nav3 pushViewController:searchViewController animated:NO];
[arrayViewController addObject:nav3];
[nav3 release]; [searchViewController release];
//
UINavigationController *nav4 = [[UINavigationController alloc] init];
FavorisViewController *favorisViewController = [[FavorisViewController alloc] init];
favorisViewController.context = context;
[nav4 pushViewController:favorisViewController animated:NO];
[arrayViewController addObject:nav4];
[nav4 release]; [favorisViewController release];
我最喜欢的 UIViewController:
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
NSError *error;
NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
fetch.entity = [NSEntityDescription entityForName:@"Businesses" inManagedObjectContext:context];
fetchObject = [context executeFetchRequest:fetch error:&error];
[fetch release];
}
- (void)viewDidAppear:(BOOL)animated
{
NSLog(@"test");
}
I have a UITabBarController that include four UIViewController and when i want call viewDidAppear it doesn't work. I don't why this happens just for iOS 4.3?
//
UINavigationController *nav3 = [[UINavigationController alloc] init];
SearchViewController *searchViewController = [[SearchViewController alloc] init];
searchViewController.context = context;
[nav3 pushViewController:searchViewController animated:NO];
[arrayViewController addObject:nav3];
[nav3 release]; [searchViewController release];
//
UINavigationController *nav4 = [[UINavigationController alloc] init];
FavorisViewController *favorisViewController = [[FavorisViewController alloc] init];
favorisViewController.context = context;
[nav4 pushViewController:favorisViewController animated:NO];
[arrayViewController addObject:nav4];
[nav4 release]; [favorisViewController release];
My Favorite UIViewController:
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
NSError *error;
NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
fetch.entity = [NSEntityDescription entityForName:@"Businesses" inManagedObjectContext:context];
fetchObject = [context executeFetchRequest:fetch error:&error];
[fetch release];
}
- (void)viewDidAppear:(BOOL)animated
{
NSLog(@"test");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
UINavigationController
方法initWithRootViewController:
代替。例如,还要注意,仅仅因为视图被推入堆栈,并不意味着它是可见的。在您选择具有该视图的选项卡之前,不应调用
viewDidAppear:
。Try using the
UINavigationController
methodinitWithRootViewController:
instead. For example,Note as well that just because the view is pushed onto the stack, doesn't mean it's visible. Until you select the tab with that view,
viewDidAppear:
should not be called.