【发布时间】:2021-08-10 14:24:09
【问题描述】:
我正在 XCode 12.0 上运行我的 Objective-C 项目之一。我有 UIControl 子类“SeatingPanelControl”,从中创建了另一个名为“IpadSeatingPlanControl”的子类,其中我在执行以下代码时遇到了崩溃,但标题中提到了异常(也在屏幕截图中给出):
//IpadChamberViewController.m
self.seatingPlanControl = [[[IpadSeatingPlanControl alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height * 4/7,[self.view bounds].size.width,[self.view bounds].size.height * 3/7 + 20.0)] autorelease];
更新(解决方案):
我找到了问题的原因。在修复 XCode 12 的 IMP 问题时,我错误地删除了一行代码。根据当前的代码设置,它在 iPhone 上运行良好,但在 iPad 上运行不正常。恢复这行代码解决了这个问题。
【问题讨论】:
-
请提供更多代码
-
你没有提到这个 IpadChamberViewController。它的初始化器返回 nil。
标签: ios objective-c uitraitcollection initwithframe