<legend id='bGccz'><style id='bGccz'><dir id='bGccz'><q id='bGccz'></q></dir></style></legend>

    <small id='bGccz'></small><noframes id='bGccz'>

      <bdo id='bGccz'></bdo><ul id='bGccz'></ul>

      <tfoot id='bGccz'></tfoot>
    1. <i id='bGccz'><tr id='bGccz'><dt id='bGccz'><q id='bGccz'><span id='bGccz'><b id='bGccz'><form id='bGccz'><ins id='bGccz'></ins><ul id='bGccz'></ul><sub id='bGccz'></sub></form><legend id='bGccz'></legend><bdo id='bGccz'><pre id='bGccz'><center id='bGccz'></center></pre></bdo></b><th id='bGccz'></th></span></q></dt></tr></i><div id='bGccz'><tfoot id='bGccz'></tfoot><dl id='bGccz'><fieldset id='bGccz'></fieldset></dl></div>
    2. ios5 上的dismissViewControllerAnimated 崩溃

      时间:2023-05-30
      <tfoot id='u0c8n'></tfoot>
        <legend id='u0c8n'><style id='u0c8n'><dir id='u0c8n'><q id='u0c8n'></q></dir></style></legend>

            • <i id='u0c8n'><tr id='u0c8n'><dt id='u0c8n'><q id='u0c8n'><span id='u0c8n'><b id='u0c8n'><form id='u0c8n'><ins id='u0c8n'></ins><ul id='u0c8n'></ul><sub id='u0c8n'></sub></form><legend id='u0c8n'></legend><bdo id='u0c8n'><pre id='u0c8n'><center id='u0c8n'></center></pre></bdo></b><th id='u0c8n'></th></span></q></dt></tr></i><div id='u0c8n'><tfoot id='u0c8n'></tfoot><dl id='u0c8n'><fieldset id='u0c8n'></fieldset></dl></div>

                <tbody id='u0c8n'></tbody>

              <small id='u0c8n'></small><noframes id='u0c8n'>

              • <bdo id='u0c8n'></bdo><ul id='u0c8n'></ul>
                本文介绍了ios5 上的dismissViewControllerAnimated 崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                代码会因为循环引用而崩溃吗?

                Does the code crash, because of a circular reference?

                MenuController: UIViewController
                
                - (id)initWithNibName:
                {...
                TabsController *tabs = [[TabsController alloc] initWithNibName:@"TabsController" bundle:nil];
                self.tab = tabs;
                ....
                }
                
                //button pressed:
                - (IBAction)showPrefFromMenu:(id)sender {
                    // todo change delegate!?
                     tab.tabDelegate = self;
                    [self presentModalViewController:tab animated:YES];
                    //[tab release];
                }
                
                // delegate method:
                 -(void)myViewDismissed {
                    .... 
                    NSLog(@"tab references: %d", [tab retainCount]) ;
                
                    [self dismissModalViewControllerAnimated:YES];//crash       
                     ...
                
                }
                

                模态/子类:

                TabsController : UIViewController <...>
                
                - (IBAction)dismissTabs:(id)sender {
                      ...
                    NSLog(@"dismissTabs: sender: %@",sender);
                    [self.tabDelegate myViewDismissed];    
                }
                

                我看到 self.tabDelegate 是 MenuController 实例,并且在该代码上想要关闭并释放 TabsController.

                As I see the self.tabDelegate is the MenuController instance and on that code want do dismiss and deallocate the TabsController.

                虽然在 [self.tabDelegate myViewDismissed] 之后不再是代码;但是如果它不能执行,因为它被释放了,也许程序集 Ret 或者什么指令不能执行?返回语句.

                Although it isn't any more code after [self.tabDelegate myViewDismissed]; but if it would be than couldn't execute, because it is deallocated, maybe the assembly Ret or what instruction can't be executed? the return statement.

                我会尝试分离委托还是有更好的解决方案?

                I will try to separate the delegate or any better solution?

                崩溃是典型的:EXC_BAD_ACCESS(code=1,address=090)大会看起来像这样:ldr r1, [r4, r0]

                The crash is the typical one: EXC_BAD_ACCESS(code=1,address=090) the Assembly looks like this: ldr r1, [r4, r0]

                修改了一点代码,因为在模拟器 4.3 中不会崩溃,但在 5.0 时会崩溃,现在这里是当前代码:

                changed a bit the code, because in simulator 4.3 doesn't crash, but at 5.0 it is, now here is the current code:

                - (IBAction)showTab:(id)sender {
                
                    tab.tabDelegate = self;
                
                    if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
                        [self presentModalViewController:tab animated:YES];
                    }
                    else{
                        NSLog(@"Executing presentViewController (ios>= 5.0)");
                        [self presentViewController:tab animated:true completion: nil];
                    }
                
                }
                
                
                 -(void)delegateCallback {
                
                     if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
                         [self dismissModalViewControllerAnimated:NO]; 
                     }
                     else{
                         NSLog(@"Executing dismissViewControllerAnimated (ios>= 5.0)");
                         [self dismissViewControllerAnimated:TRUE completion: nil];//crash
                     }        
                
                }
                

                Edit3 截图:

                UIWindowController 转换:fromViewController:toViewController:didEndSeelctor 行崩溃,原因是:没有 parentViewController:https://devforums.apple.com/message/451045伙计们在这里找到了解决方案:https://github.com/ideashower/ShareKit/issues/254 但在保密协议下

                UIWindowController transition:fromViewController:toViewController:didEndSeelctor line is crashing, due to: no parentViewController: https://devforums.apple.com/message/451045 Guys here found a solution, : https://github.com/ideashower/ShareKit/issues/254 but in under NDA

                编辑已解决以重写到适用于 ios 5.0+ 的 PushviewController完整链接:https://stackoverflow.com/a/7767767/529543

                Edit solved to revrite to PushviewController for ios 5.0+ a heplfull link: https://stackoverflow.com/a/7767767/529543

                - (IBAction)presentViewController:(id)sender {
                
                
                    tab.tabDelegate = self;
                
                    if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
                        [self presentModalViewController:tab animated:FALSE];
                    }
                    else{
                        NSLog(@"Executing presentViewController (ios>= 5.0) [tab retainCount]: %d " ,[tab retainCount]);       
                
                    // store parent view to able to restore the state:
                    parentView = self.view.superview;        
                
                    // init a navigation controler and set up:
                    navigationController=[[UINavigationController alloc] initWithRootViewController:self];                
                    [self.view removeFromSuperview];
                
                    [myAppDelegate.window addSubview:navigationController.view];   ///appDelegate is delegate of ur Application     
                
                    navigationController.navigationBar.hidden =true;
                
                    [navigationController pushViewController:tab animated:YES];       
                
                }
                

                }

                然后弹出:

                -(void)infoViewDismissed {
                
                     if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
                
                         [self dismissModalViewControllerAnimated:NO];  
                     }
                     else{
                         NSLog(@"Executing dismissViewControllerAnimated (ios>= 5.0) ");
                
                         [navigationController popToRootViewControllerAnimated:false];        
                
                         [navigationController.view removeFromSuperview];
                
                         [parentView addSubview:self.view];
                
                     }     
                }
                

                我已经解决了我的问题,在一个非常丑陋的模式下,但功能正常......还被告知放弃对 ios3 的支持 :) 我根本不喜欢运行时的 GUI 架构切换.

                I have solved my problem, in a very ugly mode, but is functional...Also told to drop the support for ios3 :) I don't like the GUI architecture switch at runtime at all.

                推荐答案

                你的问题有点难理解,但我猜你有一个retain-cycle:

                Your question is a little difficult to understand, but I gather you have a retain-cycle:

                ObjectA retains ObjectB
                ObjectB retains ObjectA
                

                两个对象都没有被释放?

                and neither object gets deallocated?

                您的 tabDelegate 属性应为:

                Your property for the tabDelegate should read:

                @property (nonatomic, assign) id tabDelegate;
                //                    ^^^^^^-This is the important bit, this stops the retain cycle.
                

                这篇关于ios5 上的dismissViewControllerAnimated 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:支持 iOS 4.3 到 iOS 6.0 下一篇:如何在 iOS 上使用 OpenCV 对 CGImage 进行二值化?

                相关文章

                最新文章

                <i id='CPwiU'><tr id='CPwiU'><dt id='CPwiU'><q id='CPwiU'><span id='CPwiU'><b id='CPwiU'><form id='CPwiU'><ins id='CPwiU'></ins><ul id='CPwiU'></ul><sub id='CPwiU'></sub></form><legend id='CPwiU'></legend><bdo id='CPwiU'><pre id='CPwiU'><center id='CPwiU'></center></pre></bdo></b><th id='CPwiU'></th></span></q></dt></tr></i><div id='CPwiU'><tfoot id='CPwiU'></tfoot><dl id='CPwiU'><fieldset id='CPwiU'></fieldset></dl></div>
                  <bdo id='CPwiU'></bdo><ul id='CPwiU'></ul>

                <small id='CPwiU'></small><noframes id='CPwiU'>

                1. <legend id='CPwiU'><style id='CPwiU'><dir id='CPwiU'><q id='CPwiU'></q></dir></style></legend>
                  1. <tfoot id='CPwiU'></tfoot>