How to find topmost view controller on iOS

后端 未结 30 2315
遥遥无期
遥遥无期 2020-11-22 08:40

I\'ve run into a couple of cases now where it would be convenient to be able to find the \"topmost\" view controller (the one responsible for the current view), but haven\'t

30条回答
  •  抹茶落季
    2020-11-22 09:01

    you could find the top most view controller by using

    NSArray *arrViewControllers=[[self navigationController] viewControllers];
    UIViewController *topMostViewController=(UIViewController *)[arrViewControllers objectAtIndex:[arrViewControllers count]-1];
    

提交回复
热议问题