navigationController在使用过程中会产生很多controller,但很多页面使用率特别低,在退出后可以直接将其移除,可以用下面方法实现:
- (void)removeBulidPhotoAlbumController{
NSMutableArray *removeArr = @[].mutableCopy;
for (int i=0; i<self.navigationController.childViewControllers.count; i++) {
id controller = self.navigationController.childViewControllers[i];
if ([controller isKindOfClass:[BulidPhotoAlbumController class]]) {
[removeArr addObject:controller];
}
}
NSMutableArray *tempArr = self.navigationController.childViewControllers.mutableCopy;
for (int i=0; i<removeArr.count; i++) {
id controller = removeArr[i];
[tempArr removeObject:controller];
}
[self.navigationController setViewControllers:tempArr]; }