【发布时间】:2023-03-25 14:50:01
【问题描述】:
在应用程序 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;
在 MainViewController 上,我正在添加另一个类似这样的 viewController 的视图
gridViewControllerObj = [[GridViewController alloc]initWithNibName:@"GridViewController" bundle:nil];
[self.view addSubview:gridViewControllerObj.view];
GridViewController 添加在按钮上,在按钮单击时我们显示弹出框。下面的代码 分配给“operationsViewController”的内存
self.optionsPopOver = [[UIPopoverController alloc]initWithContentViewController:operationsViewController];
[_orderOptionsPopOver presentPopoverFromRect:frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown|UIPopoverArrowDirectionUp animated:NO];
这是显示弹出框的流程,如果在设备上运行应用程序,我会在控制台上看到警告打印。超时后我回到第一个视图
问题 1:
BusinessApplication[8321]:不鼓励在分离的视图控制器上呈现视图控制器。 对于这种情况,应用程序可以工作但不会崩溃
为了解决这个警告,我在论坛上搜索了上述警告,有类似的解决方案建议
AppDelegate *appDelegate = (AppDelegate* )[[UIApplication sharedApplication] delegate];
UIView *rootView = appDelegate.window.rootViewController.view;
在向弹出窗口提供 rootview 后,上面的警告消失了
[_orderOptionsPopOver presentPopoverFromRect:frame inView:rootView permittedArrowDirections:UIPopoverArrowDirectionDown|UIPopoverArrowDirectionUp animated:NO];
问题 2: 在超时应用上述解决方案后应用程序崩溃。
我收到了以下崩溃日志
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
【问题讨论】:
-
你为什么要设置为零?您通过将 nil 分配给它来释放对象。当您将对象作为参数传递时,这并不意味着该对象是重复的。
-
@Schemetrical 我将对象分配给 nil 以解除分配对象,我认为这不是问题。你有没有收到我与弹出警告相关的问题
标签: ios ipad uiviewcontroller uikit uipopovercontroller