IOS--如何從第N級介面返回到一級介面(即新增在UITabbarController上的UIController)
阿新 • • 發佈:2019-01-30
//第N個介面的返回按鈕點選事件
- (void)orderForBackBarButtonItemAction
{
AppDelegate *app = (AppDelegate *)[UIApplicationsharedApplication].delegate;
//MyTabBarController自己自定義的UItabbarController
MyTabBarController *tabbarVC = app.tabbar;
//turnToTabVCAtIndex在自定義的UITabbarController上寫的方法
[tabbarVC
}
//這個方法寫在自定義的UITabbarController上
- (void)turnToTabVCAtIndex:(NSUInteger)index
{
//selectedViewController和selectedIndex為蘋果裡面的一個屬性
if ([self.selectedViewControllerisKindOfClass:[UINavigationControllerclass]]){
[self.selectedViewControllerpopToRootViewControllerAnimated:
}
if (index != self.selectedIndex) {
self.selectedIndex = index;
}
}