这是一个奇怪的累积错误,它以某种方式将我的 VC 多次推到 Nav VC 上。
我有一个 UINavigationController,其 rootViewController 设置为 CWLandingVC (lvc)。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CWLandingVC *lvc = [[CWLandingVC alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:lvc];
...
}
在 lvc 上,用户登录,当我的 APIClient 类获得成功的服务器响应时,它会发布通知:
NSNotification* notification = [NSNotification notificationWithName:@"sessionArrived" object:self];
NSLog(@"APIClient Posting notification for sessionArrived");
[[NSNotificationCenter defaultCenter] postNotification:notification];
lvc 监听这个并相应地发送这个选择器:
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self
selector:@selector(toPagebookWorkspace)
name:@"sessionArrived"
object:client];
...
- (void)toPagebookWorkspace {
NSLog(@"lvc Calling toPagebookWorkspace for session %@. Opening PagebookWorkspace view.", [self sessionId]);
CWWorkspaceVCViewController *wvc = [[CWWorkspaceVCViewController alloc] init];
[[self navigationController] pushViewController:wvc animated:YES];
}
当用户登录,成功执行 pushViewController:wvc,注销到 lvc,然后重新登录时,就会出现错误。当他们这样做时,通知会再次发布——我使用 NSLog(@"Posting notification for sessionArrived"); – 但是选择器 toPagebookWorkspace 被调用了两次。如果我重复这个错误,选择器会被调用 3 次,以此类推。所以每次我重现这个错误时,越来越多的 wvc 在 UINavigationController 中相互叠加。
也许这些日志可以帮助阐明我所看到的奇怪的累积序列。对于每个 APIClient 通知帖子,我都会收到越来越多的 pushViewController:wvc,而不仅仅是 1 个推送。
Logging in...
APIClient Posting notifcation for sessionArrived
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
Pressed back on nav bar, calling viewWillDisappear
Logging in...
APIClient Posting notifcation for sessionArrived
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
nested push animation can result in corrupted navigation bar
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Unbalanced calls to begin/end appearance transitions for <CWWorkspaceVCViewController: 0x8067410>.
Pressed back on nav bar, calling viewWillDisappear
Pressed back on nav bar, calling viewWillDisappear
Logging in...
APIClient Posting notifcation for sessionArrived
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
nested push animation can result in corrupted navigation bar
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
nested push animation can result in corrupted navigation bar
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Unbalanced calls to begin/end appearance transitions for <CWWorkspaceVCViewController: 0x8068330>.
Pressed back on nav bar, calling viewWillDisappear
Pressed back on nav bar, calling viewWillDisappear
Pressed back on nav bar, calling viewWillDisappear
Logging in...
APIClient Posting notifcation for sessionArrived
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
nested push animation can result in corrupted navigation bar
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
nested push animation can result in corrupted navigation bar
lvc Calling toPagebookWorkspace for session lvcke2. Opening PagebookWorkspace view.
nested push animation can result in corrupted navigation bar
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Unbalanced calls to begin/end appearance transitions for <CWWorkspaceVCViewController: 0x7257930>.
Pressed back on nav bar, calling viewWillDisappear
Pressed back on nav bar, calling viewWillDisappear
Pressed back on nav bar, calling viewWillDisappear
Pressed back on nav bar, calling viewWillDisappear
如果您有任何想法,非常感谢您提前提供的帮助。