20120522 小记

小记1:

在使用UITabBarController使用,每个Tab有自己的UINavigationController,当navigator的栈中对于一个Controller时,

从其他tab单击切换到该tab时,默认显示该navigatior栈顶Controller,如果双击tab直接到栈底Controller,可需要人员要求

单击显示栈底Controller,在appDelegate中重写

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {

  if ([viewController isKindOfClass:[UINavigationController class]]) {

    [(UINavigationController *)viewController popToRootViewControllerAnimated:YES];

  }

}

可能出现的问题,当切换到多个Controller的tab时,栈顶Controller如果有数据请求,需要代理相应的。回来时候因为navigator已经pop到栈底了,

原来的栈顶元素木有了,则发生崩溃。

解决方案:在viewWillAppear 如果有请求和代理设置,在viewWillDisappear中一定要取消。

事实上,即使appear中请求了,delegate在disappear中也置空了,不会导致崩溃。

小记2:

NSNotifition发送给所有的观察者。

A,B页面都注册了Notification,当收到通知时,A,B页面都会收到响应。

本人今天遇到的bug时,当前时A页面,收到notification,A得到A的响应,此时B也响应了,讲B得spinner转到了A得页面上。

解决方案:同上,在appear中注册notification,disappear中注销掉。B页面就不会捣乱了。

原文地址:https://www.cnblogs.com/tiechui/p/2513276.html