开发者

Crashing app when i want to go rootview from other view controller

开发者 https://www.devze.com 2023-02-03 14:41 出处:网络
I want to go Root view Controller from another view controller but i got the terminating error. following is the error message in console,

I want to go Root view Controller from another view controller but i got the terminating error. following is the error message in console,

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray removeObjectsInRange:]: index (4) beyond bounds (1)'
开发者_运维百科

This is my code for that

NSArray *arr=self.navigationController.viewControllers;
 [self.navigationController popToViewController:[arr objectAtIndex:2] animated:YES];

So any one can give me the suggestion on it so can remove the crash


The NavigationController has a method called to pop to its root view controller. Maybe you should use this one instead.

- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
0

精彩评论

暂无评论...
验证码 换一张
取 消