Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
显示popover时iOS应用程序崩溃_Ios_Ipad_Uiviewcontroller_Uikit_Uipopovercontroller - Fatal编程技术网

显示popover时iOS应用程序崩溃

显示popover时iOS应用程序崩溃,ios,ipad,uiviewcontroller,uikit,uipopovercontroller,Ios,Ipad,Uiviewcontroller,Uikit,Uipopovercontroller,在应用程序中,rootviewController分配如下 navigationContr = [[UINavigationController alloc] initWithRootViewController:loginViewController]; loginViewController = nil; self.window.rootViewController = _navigationViewController; 登录后,我像这样按下MainViewController Main

在应用程序中,rootviewController分配如下

navigationContr = [[UINavigationController alloc] initWithRootViewController:loginViewController];
loginViewController = nil;
self.window.rootViewController = _navigationViewController;
登录后,我像这样按下MainViewController

MainViewController * mainViewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
mainViewController.isNavigateFromLogin  = YES;
/** push the Main screen*/
[self.navigationController pushViewController:mainViewController animated:NO];
mainViewController = nil;
gridViewControllerObj = [[GridViewController alloc]initWithNibName:@"GridViewController" bundle:nil];
[self.view addSubview:gridViewControllerObj.view];
在MainViewController上,我正在添加另一个viewController的视图,如下所示

MainViewController * mainViewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
mainViewController.isNavigateFromLogin  = YES;
/** push the Main screen*/
[self.navigationController pushViewController:mainViewController animated:NO];
mainViewController = nil;
gridViewControllerObj = [[GridViewController alloc]initWithNibName:@"GridViewController" bundle:nil];
[self.view addSubview:gridViewControllerObj.view];
GridViewController添加在按钮上,单击按钮时显示弹出窗口。代码如下 分配给“operationsViewController”的内存

这是显示弹出窗口的流程,若在设备上运行应用程序,我会在控制台上看到警告打印。暂停后,我返回第一视图

第1期:

BusinessApplication[8321]:不建议在分离的视图控制器上显示视图控制器。 在这种情况下,应用程序可以工作,但不会崩溃

为了修复这个警告,我在论坛上搜索了上面的警告,有如下建议的解决方案

AppDelegate *appDelegate = (AppDelegate* )[[UIApplication sharedApplication] delegate];
UIView *rootView = appDelegate.window.rootViewController.view;
向popover提供rootview后,上述警告将消失

[_orderOptionsPopOver presentPopoverFromRect:frame inView:rootView permittedArrowDirections:UIPopoverArrowDirectionDown|UIPopoverArrowDirectionUp animated:NO]; 
第二期: 在超时应用上述解决方案后,应用程序崩溃

我有下面的事故记录

BusinessApplication[511] <Warning>: Warning: sync SCNetworkReachability (by-name) query on main thread
mstreamd[513] <Notice>: (Note ) PS: MSSubscriber - 1456278278 Finished retrieving assets. Checking for errors on 0 assets...
BusinessApplication[511] <Warning>: Warning: sync SCNetworkReachability (by-name) query on main thread
BusinessApplication[511] <Warning>: Warning: sync SCNetworkReachability (by-name) query on main thread
BusinessApplication[511] <Warning>: Stack Trace: uncaughtExceptionHandler 
     (
        0   CoreFoundation                      0x25f0fd7f <redacted> + 150
        1   libobjc.A.dylib                     0x33aefc77 objc_exception_throw + 38
        2   UIKit                               0x29696533 <redacted> + 2918
        3   UIKit                               0x2969809b <redacted> + 94
        4   UIKit                               0x293c11a1 <redacted> + 72
        5   UIKit                               0x29697fcf <redacted> + 198
        6   UIKit                               0x2949c199 <redacted> + 168
        7   UIKit                               0x294c5741 <redacted> + 116
        8   UIKit                               0x294c4721 <redacted> + 120
        9   UIKit                               0x294037a3 <redacted> + 66
        10  Foundation                          0x26c16dc9 __NSFireDelayedPerform + 468
        11  CoreFoundation                      0x25ed6517 <redacted> + 14
        12  CoreFoundation                      0x25ed6099 <redacted> + 656
        13  CoreFoundation                      0x25ed4303 <redacted> + 1418
        14  CoreFoundation                      0x25e21981 CFRunLoopRunSpecific + 476
        15  CoreFoundation                      0x25e21793 CFRunLoopRunInMode + 106
        16  GraphicsServices                    0x2d1b1051 GSEventRunModal + 136
        17  UIKit                               0x29413981 UIApplicationMain + 1440
        18  BusinessApplication                 0x003ddc17 main + 170
        19  libdyld.dylib                       0x3408baaf <redacted> + 2
    )
BusinessApplication[511] <Warning>: CRASH: Application tried to present modally an active controller <MainViewController: 0x16a78b30>.
BusinessApplication[511] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <MainViewController: 0x16a78b30>.'
*** First throw call stack:
(0x25f0fd67 0x33aefc77 0x29696533 0x2969809b 0x293c11a1 0x29697fcf 0x2949c199 0x294c5741 0x294c4721 0x294037a3 0x26c16dc9 0x25ed6517 0x25ed6099 0x25ed4303 0x25e21981 0x25e21793 0x2d1b1051 0x29413981 0x3ddc17 0x3408baaf)
ReportCrash[516] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)
ReportCrash[516] <Notice>: ReportCrash acting against PID 511
ReportCrash[516] <Notice>: Formulating crash report for process BusinessApplication[511]
mediaserverd[36] <Notice>: '' com.xp.businessApp(pid = 511) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
com.apple.xpc.launchd[1] (UIKitApplication:com.xp.businessApp[0x2b0f][511]) <Notice>: Service exited due to signal: Abort trap: 6
<Warning>: Application 'UIKitApplication:com.xp.businessApp[0x2b0f]' crashed.
assertiond[54] <Warning>: pid_suspend failed for <BKNewProcess: 0x16d885d0; com.xp.businessApp; pid: 511>: Unknown error: -1, Unknown error: -1
assertiond[54] <Warning>: Could not set priority of <BKNewProcess: 0x16d885d0; com.xp.businessApp; pid: 511> to 2, priority: No such process
assertiond[54] <Warning>: Could not set priority of <BKNewProcess: 0x16d885d0; com.xp.businessApp; pid: 511> to 4096, priority: No such process
UserEventAgent[17] <Warning>: id=com.xp.businessApp pid=511, state=0
ReportCrash[516] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/BusinessApplication_2015-03-14-171423_IPad.ips
locationd[60] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
locationd[60] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
mstreamd[513] <Notice>: (Note ) mstreamd: Not monitoring for external power.
mstreamd[513] <Notice>: (Note ) PS: Media stream daemon stopping.
mstreamd[513] <Notice>: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x14e30790>: Shared Streams daemon has shut down.
mstreamd[513] <Notice>: (Warn ) mstreamd: mstreamd shutting down.
<Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
<Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
locationd[60] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
locationd[60] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
BusinessApplication[511]:警告:主线程上的同步SCNetworkReachability(按名称)查询
mstreamd[513]:(注)PS:MSSubscriber-1456278278已完成资产检索。正在检查0资产上的错误。。。
BusinessApplication[511]:警告:同步SCNetworkReachability(按名称)查询主线程
BusinessApplication[511]:警告:同步SCNetworkReachability(按名称)查询主线程
BusinessApplication[511]:堆栈跟踪:uncaughtExceptionHandler
(
0芯基础0x25f0fd7f+150
1 libobjc.A.dylib 0x33aefc77 objc_异常_抛出+38
2 UIKit 0x29696533+2918
3 UIKit 0x2969809b+94
4 UIKit 0x293c11a1+72
5 UIKit 0x29697fcf+198
6 UIKit 0x2949c199+168
7 UIKit 0x294c5741+116
8 UIKit 0x294c4721+120
9 UIKit 0x294037a3+66
10基金会0x26C16DC9,nFieldRayEddiff+ 468
11芯基础0x25ed6517+14
12芯基础0x25ed6099+656
13芯基础0x25ed4303+1418
14 CoreFoundation 0x25e21981 CFRunLoopRunSpecific+476
15 CoreFoundation 0x25e21793 CFRunLoopRunInMode+106
16图形服务0x2d1b1051 GSEventRunModal+136
17 UIKit 0x29413981 UIApplicationMain+1440
18业务应用程序0x003ddc17主+170
19 libdyld.dylib 0x3408baaf+2
)
BusinessApplication[511]:崩溃:应用程序试图以模态方式呈现活动控制器。
BusinessApplication[511]:***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因是:“应用程序试图以模态方式呈现活动控制器。”
***第一次抛出调用堆栈:
(0x25f0fd67 0x33aefc77 0x29696533 0x2969809b 0x293c11a1 0x29697fcf 0x2949c199 0x294c5741 0x294c4721 0x294037a3 0x26c16dc9 0x25ed6517 0x25ed6099 0x25ed4303 0x25e21981 0x25e21793 0x2D1B1B1051 0x29413981 0x3ddc17 0x3408baaf)
ReportCrash[516]:任务设置异常端口(B07、400、D03、0、0)失败,出现错误(4:(os/kern)无效参数)
ReportCrash[516]:针对PID 511执行的ReportCrash
ReportCrash[516]:为process BusinessApplication制定崩溃报告[511]
mediaserverd[36]:“”com.xp.businessApp(pid=511)设置DiscoveryMode=DiscoveryMode\u None,currentDiscoveryMode=DiscoveryMode\u None
com.apple.xpc.launchd[1](UIKitApplication:com.xp.businessApp[0x2b0f][511]):由于信号:中止陷阱:6,服务退出
:应用程序“UIKitApplication:com.xp.businessApp[0x2b0f]”崩溃。
断言[54]:pid_挂起失败原因:未知错误:-1,未知错误:-1
断言[54]:无法将的优先级设置为2,优先级:没有这样的进程
断言[54]:无法将的优先级设置为4096,优先级:无此类进程
UserEventAgent[17]:id=com.xp.businessApp pid=511,状态=0
ReportCrash[516]:已将报告保存到/var/mobile/Library/Logs/CrashReporter/BusinessApplication_2015-03-14-171423_IPad.ips
locationd[60]:支持手势的FortopClient:0,支持守护程序设置:0
locationd[60]:支持手势的FortopClient:0,支持守护程序设置:0
mstreamd[513]:(注意)mstreamd:不监视外部电源。
mstreamd[513]:(注意)PS:媒体流守护进程正在停止。
mstreamd[513]:(注意)AS::Shared Streams守护程序已关闭。
mstreamd[513]:(警告)mstreamd:mstreamd正在关闭。
:手势启用FortopClient:0,启用守护程序设置:0
:手势启用FortopClient:0,启用守护程序设置:0
locationd[60]:支持手势的FortopClient:0,支持守护程序设置:0
locationd[60]:支持手势的FortopClient:0,支持守护程序设置:0

你所做的事情的问题是你为自己制造了一个陷阱链

您创建了两个控制器,并展示了它们,但是展示了它们之后,您就可以取消分配它们了。你不能展示你分配的东西。这导致了第一个问题,即当当前控制器为nil时,尝试呈现另一个控制器

接下来,获取错误消息并在上下文之外搜索解决方案。这并不能解决您的问题,如果您尝试使用它,显然会导致崩溃

您需要做的第一件事是删除nil赋值。我不知道你为什么这么做,我肯定这会引起很多问题

当您有
*a=*b
*c=*a
时,如果您设置
c=nil
,所有其余变量也将为nil,因为指针是如何工作的。如果你不介意的话,我很乐意再帮你一些