- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用以下代码在用户单击按钮时显示上一个 View
[self.navigationController popViewControllerAnimated:YES];
在之前的 View 中,我覆盖了 viewWillAppear 以初始化一些东西。但是,似乎没有调用 viewWillAppear。我将 NSLog 放在 viewDidload、viewWillAppear、viewDidAppear 中,并且只调用 viewDidAppear。这是正常行为吗?如果是,我应该覆盖什么事件以便我可以进行初始化?谢谢。
根据要求-viewWillAppear 用于上一个 View
- (void)viewWillAppear:(BOOL)animated{
NSLog(@"ViewWillAppear");
//[[GameStore defaultStore] resetGame];
[self setHangmanImage];
NSLog([[[GameStore defaultStore] selectedList] label]);
[labelListName setText:[NSString stringWithFormat:@"List Name: %@", [[[GameStore defaultStore] selectedList] label]]];
[labelCurrentIndex setHidden:YES];
[labelCurrentWord setHidden:YES];
[[self navigationController] setNavigationBarHidden:NO];
[FlurryAnalytics logEvent:@"GameViewController - viewWillAppear"];
[self getNewQuestion];
NSLog(@"ViewWillAppear finish");
[super viewWillAppear:YES];
}
我使用以下代码在应用委托(delegate)中设置 UINavigationalController
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
HomeViewController *hv = [[HomeViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:hv];
// You can now release the itemsViewController here,
// UINavigationController will retain it
[hv release];
// Place navigation controller's view in the window hierarchy
[[self window] setRootViewController:navController];
[navController release];
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
return YES;
}
更新
我不知道发生了什么,但昨晚尝试在模拟器中再次运行该应用程序并且它仍然有这个问题后,我决定保存所有内容并关闭我的计算机,因为已经很晚了。
今天早上我重新打开我的电脑,打开 xcode,清理项目并构建并运行它,我的问题得到解决,-viewWillAppear 被调用。我没有改变任何东西和它的工作。我在 -willShowView 中添加了 NSLog 并且它没有被调用。我不知道为什么突然调用 viewWillAppear。
最佳答案
确保设置了导航 Controller 的委托(delegate),然后使用此函数在您要调用其 viewWillAppear 的类中调用 viewWillAppear:
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[self viewWillAppear:animated];
}
关于iphone - popviewcontroller 没有调用 viewWillappear,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7564596/
是否有与 UINavigationController 的 popViewController 等效的 TTNavigator? (或者关闭我找不到的 View Controller 的替代方法?)
我遇到了一个奇怪的故障,当调用 popViewControllerAnimated: 时, View Controller 上的正常标题 View 突然向左对齐。有人似乎遇到过类似的问题吗? 最佳答案
我在 popViewController 方面遇到问题。 我使用pushViewController转到OrdersFormViewController OrdersFormViewControlle
导航 Controller 中的 Popviewcontroller 只弹出当前页面并将我们发送到上一页。有没有办法弹出两页并返回到上一页之前的页面(后两页),或者我必须将其推送到该页面。谢谢 最佳答
我有两个 UIViewController,“A”和“B”,其中“A”覆盖 shouldAutorotateToInterfaceOrientation 以针对 UIInterfaceOrientat
我想从 View 1 的类方法中返回我的 Root View 。在 View 1 的实例方法中,我只想说 [self.navigationController popViewControllerAni
我可以在不使用这样的代码的情况下从导航 Controller 堆栈中删除 View Controller 吗 [mynavigationController popViewControllerAnim
我正在制作一个应用程序,它从解析中检索图像并将其显示到 Collection View 中。当用户点击图像时,图像会详细显示。我有一个用户可以更改的文本字段。当用户更改某些内容时,他们会点击保存按钮并
我在我的应用程序中使用 UISegue 在我的应用程序中的 View Controller 之间自动转换。我称它们为 A 和 B。 它按预期工作,但是当我想从 B 返回 A 时,我尝试调用[self.
我正在使用 ARC。我有 UINavigationController 来推送和弹出。碰巧其中一个 ViewController 是一个巨大的 ScrollView ,可容纳 100MB。在 popV
由于我试图拒绝但没有成功的奇怪请求,我不得不覆盖导航栏的后退按钮。 我制作了一个自定义的 UINavigationController 子类并破解了- (BOOL)navigationBar:(UIN
我有两个 View Controller 。第一个 View Controller 没有状态栏。 class ViewController: UIViewController { overri
我一直在努力使用 UINavigationalController 在 View 之间切换。我已经多次使用这个系统没有问题,但在我的新应用程序中它不能正常工作。 这是问题: 当我推送一个新的 View
因此,当发生错误时,我尝试将 View Controller 从堆栈中弹出,但似乎一次性弹出太多内容。顶部的导航栏失去了标题和按钮,但旧的 TableView 数据仍然可见。我不知道发生了什么....
我完全被难住了,情况是这样的: 我的应用程序使用核心位置框架来获取用户的当前位置,然后 ping 我的服务器 TrailBehind附近有趣的地方并将它们显示为列表。没问题。 为了节省电池,我在从服务
当我推送或弹出 UIViewController 时,动画需要多长时间才能完成幻灯片动画。我在主窗口上有一个 View ,当推送或弹出 ViewController 时,我需要同步滑动该 View 。
我有一个 UINavigationController ,上面有一系列 UIViewControllers 。在某些情况下,我想正好弹回两个级别。我以为我可以通过连续两次调用 popViewContr
我创建了一个 UINavigationController (作为初始屏幕)并将它们与我的 UITableViewController 连接起来(作为根)。 接下来,我创建另一个 UINavigati
我在 ARC 下的内存管理有一些问题。当我在我的应用程序中弹出 View Controller 时,它们都不会释放内存,有时不会调用 View Controller 的 dealloc。即使调用了 d
当使用 UINavigationController 创建的后退按钮弹出 viewController 时,我需要调用我已有的方法来保存数据。 有没有办法获得委托(delegate)回调或我在文档中没
我是一名优秀的程序员,十分优秀!