作者zonble (zonble)
看板MacDev
标题Re: [问题] 程式的流程-viewController想call supe …
时间Sat Jul 24 04:17:58 2010
※ 引述《Gsus (肉元,吉米,助教)》之铭言:
: 我要怎麽在a/bViewController中remove自己 ?
: 并且让appDelegate去add tabBarController.view ?
: 我知道的方法有利用protocol,在appDelegate中实作protocol的method
: 并且在a/bViewController中call appDelegate中的protocol method
: 但是我想问有没有其他的方法?
听起来你想要做的事情就是,你想要把 applcation delegate 里头
定义的那个 window 上面换不同的内容,原本是 FirstViewContoller
的 view,把这个 view 拿掉,然後换成 tabBarController 的 view
我假设 firstViewController 与 tabBarController 都是 AppDelegate
的成员变数,那麽,先在 AppDelegate 里头弄一个 method
- (void)useTabBarView
{
[firstViewController viewWillDisappear:YES];
[firstViewController.view removeFromSuperView];
[firstViewController viewDidDisappear:YES];
[tabBarController viewWillAppear:YES];
[window addSubview:tabBarController.view];
[tabBarController viewDidAppear:YES];
// 高兴的话还可以加上 UIVew animation…
}
然後,我们在 a/bViewController 要拿到 AppDelegate 物件,就可以
呼叫这个 method 了。
1. 在 a/vViewController 里头要 inlucde AppDelegate 的 header
2. 大概是这样写
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate useTabBarView];
我好像在前面哪边也有提到怎样拿到 AppDelegate 的 instance。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.42.191.15
1F:推 Gsus:感谢! 我已经试成功了~ 07/24 09:40