内存未在iOS 5.1中使用ARC和故事板发布 [英] memory not releasing with ARC and storyboard in iOS 5.1

查看:81
本文介绍了内存未在iOS 5.1中使用ARC和故事板发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用我的应用程序解决内存问题,该应用程序工作正常,但是一旦它达到低内存警告就会崩溃,并且在使用10到20分钟时非常非常滞后。

i'm cracking my head on memory issues with my app, the app are working fine except that it will crash once it hit low memory warning and are very very very laggy when using it for 10 to 20 minutes.

编辑:如何poptoviewcontroller?

how to poptoviewcontroller?

introvideo-> welcomeview& tutorialview-> mainviewcontroller-> scannerviewcontoller-> questionview - >(如果回答正确 - > correctView)else - > wrongView

introvideo-> welcomeview & tutorialview-> mainviewcontroller-> scannerviewcontoller-> questionview ->(if answer correct -> correctView) else ->wrongView

如何弹回mainView控制器?

how do i pop back to mainView controller ?

以下代码用于解决将视图控制器添加到navigationcontroller.viewcontroller堆栈的问题。因为我正在使用storyboard从viewcontroller推送到另一个视图控制器而没有弹出。
代码将弹出到已经在viewcontroller堆栈中的viewcontroller。

the below code are to solve adding view controller to the navigationcontroller.viewcontroller stack. As i'm using storyboard pushing from viewcontroller to another view contoller with out poping. the code will pop to the viewcontroller that are already in the viewcontroller stack.

附加的故事板流程:

http://dl.dropbox.com/ u / 418769 / storyboard%20flow.png

介绍视频 - >欢迎视图&教程视图(如果用户名!存在) - >主视图控制器

intro video -> welcome view & tutorial view (if username !exist) -> main view controller

这是用户将要去的主文件。

this is the main file that user will alway go to.

http://dl.dropbox.com/u/418769/scannerViewController。 h

http ://dl.dropbox.com/u/418769/scannerViewController.m

我正在使用自定义segue来弹出viewcontrollers,这解决了部分问题。

i'm using a custom segue to pop viewcontrollers, which solved part of the problem.

-(void)perform {
    UIViewController *sourceVC = (UIViewController *) self.sourceViewController;
    NSInteger index = -1;
    NSArray* arr = [[NSArray alloc] initWithArray:sourceVC.navigationController.viewControllers];
    for(int i=0 ; i<[arr count] ; i++)
    {
        if([[arr objectAtIndex:i] isKindOfClass:NSClassFromString(@"mainViewController")])
        {
            index = i;
        }       
    }    

    [UIView transitionWithView:sourceVC.navigationController.view duration:0.5
                       options:UIViewAnimationOptionTransitionCrossDissolve
                    animations:^{

                        [sourceVC.navigationController popToViewController:[arr objectAtIndex:index] animated:NO];

                    }
                    completion:^(BOOL  completed)
     {     

             }                      
     ];

}

然而,该应用程序仍在吃掉RAM和VRAM 。

however, the app are still eating up the RAM and VRAM.

我真的很感谢这里的任何朋友帮助解决我的问题,强烈的价值导致了这个问题吗?

I really appreciate any friends here to help solving my question, does Strong value caused this problem ?

推荐答案

当你说你正在使用自定义segue弹出到主视图控制器时,我不确定我是否完全明白这一点。您使用的是 performSegueWithIdentifier 吗?如果是这样,那么你就不会突然出现;你正在推动主视图控制器的另一个副本!

When you say that you're using a "custom segue to pop to the Main View Controller", I'm not sure if I quite understand that. Are you using performSegueWithIdentifier? If so, then you're not popping; you're pushing another copy of the main view controller!

在大多数故事板中,您没有看到右侧子视图中的segue循环回到父视图的左侧(并且您的屏幕快照显示令人眼花缭乱)进入主视图控制器的segue的数量,这是一个红旗)。这是一个更为习惯的故事板(摘自 在Ray Wenderlich开始的iOS 5中的故事板 ):

In most storyboards, you don't see a segue out of the right side child view looping back to the left of the parent view (and your screen snapshot showed a dizzying number of segue's entering back into the main view controller, which is a bit of a red flag). This is a far more customary storyboard (taken from Beginning Storyboards in iOS 5) at Ray Wenderlich):


通常你会用以下内容忽略子视图,而不是使用segue。

Usually you'll dismiss a child view with something like the follow, not use a segue.

[self.navigationController popViewControllerAnimated:YES];

如果你想回弹多个级别,你可以使用 popToViewController popToRootViewControllerAnimated 。或者如果你使用模态segues,你会用 dismissViewControllerAnimated 来解雇模态。

Of, if you wanted to pop back multiple levels, you would use popToViewController or popToRootViewControllerAnimated. Or if you use modal segues, you would dismiss the modal with dismissViewControllerAnimated.

如果我误解了你的话意思是自定义segue to pop,你能提供你正在使用的代码吗?

If I've misunderstood what you mean't by "custom segue to pop", can you provide what code you're using do to that?

这篇关于内存未在iOS 5.1中使用ARC和故事板发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆