iOS開發(fā)中虱咧,如果需要在任意一個(gè)頁面中present一個(gè)controller時(shí)熊榛,因?yàn)橛锌赡墚?dāng)前正在顯示的頁面彈出了alertview或者已經(jīng)present了一個(gè)頁面,導(dǎo)致present到新頁面失效腕巡,這時(shí)我們可以這樣做:
- (UIViewController *)getPresentedViewController
{
UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *topVC = appRootVC;
if (topVC.presentedViewController) {
topVC = topVC.presentedViewController;
}
return topVC;
}
如果當(dāng)前沒有alertview或者present頁面玄坦,那將獲取到rootViewController根控制器,用根控制器去present跳轉(zhuǎn)绘沉,否則將獲取到當(dāng)前正在present的頁面煎楣,用此頁面去跳轉(zhuǎn)。
[[self getPresentedViewController] presentViewController:_callController animated:NO completion:nil];