为什么instantiateViewControllerWithIdentifier:不分配更多内存?

时间:2012-06-28 20:28:59

标签: ios uiviewcontroller uistoryboard

根据the documentationinstantiateViewControllerWithIdentifier“每次调用时都会创建指定视图控制器的新实例。”

我正在使用Instruments的Activity Monitor运行我的应用程序(使用ARC),当我用来实例化之前实例化的ViewController时,我注意到内存使用量没有任何差别。

为什么?请参阅下面的方法goToPreviousPage

@implementation CBNavigator

int currentPage = 0;

-(IBAction)goToNextPage{
    [self dismissViewControllerAnimated:YES completion:^{
        currentPage++;
        UIViewController *nextPageVC = [self.storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"%d", currentPage ]];
        [self presentModalViewController:nextPageVC animated:YES];
    }];        
}

-(IBAction)goToPreviousPage{    
    [self dismissViewControllerAnimated:YES completion:^{
        currentPage--;
        UIViewController *previousPageVC = [self.storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"%d", currentPage ]];
        [self presentModalViewController:previousPageVC animated:YES];
    }];
}
@end

0 个答案:

没有答案