iOS 8.1 和 8.2 上的构造函数后 self.view 崩溃
Crash in self.view after constructor on iOS 8.1 and 8.2
我正在尝试执行一个简单的 SpriteKit 操作 - 向场景添加视图:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"LevelsEditorStoryboard" bundle:[NSBundle mainBundle]];
self.levelsEditor = [mainStoryboard instantiateViewControllerWithIdentifier:@"LevelsEditorId"];
[self.scene.view addSubview:self.levelsEditor.view];
在 iOS 8.0 和 8.3 上工作正常,在 iOS 8.1 和 8.2 上我收到以下错误:
SPBingo[75304:80943666] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextSelectionView name]: unrecognized selector sent to instance
我意识到这个崩溃是由 UITextField 引起的。
一旦我摆脱它,将 UITextField 替换为一些 UITextView(不是理想但无论如何)视图正在加载但是当我尝试单击 UITextView 时它崩溃了。其他输入视图工作(开关、dataPicker、tableView 等)
在深入研究之后,我发现问题已经出现在承包商身上。当我在以下代码的第二行放置断点时:
-(instancetype) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self)
{
}
return self;
}
并尝试打印 "self.view" 我收到以下错误:
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-3)..
进程已经返回到表达式求值前的状态。
奇数!
在调用 "viewDidLoad:" 方法签名之前,您无法访问视图,否则它会在所有先决条件都准备就绪之前尝试创建视图。
确保在正确设置后从 "viewDidLoad:"、"viewWillAppear:" 或 "viewDidAppear:" 调用 self.view。
所以..这是 Apple 在 8.1 中创建并在 8.3 中修复的内部错误。
解决方案是避免使用 UITextView 承包商 "initWithFrame" 并使用以下一个:
UITextView *textView = [[UITextView alloc] initWithFrame: frame textContainer: textContainer];
我正在尝试执行一个简单的 SpriteKit 操作 - 向场景添加视图:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"LevelsEditorStoryboard" bundle:[NSBundle mainBundle]];
self.levelsEditor = [mainStoryboard instantiateViewControllerWithIdentifier:@"LevelsEditorId"];
[self.scene.view addSubview:self.levelsEditor.view];
在 iOS 8.0 和 8.3 上工作正常,在 iOS 8.1 和 8.2 上我收到以下错误:
SPBingo[75304:80943666] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextSelectionView name]: unrecognized selector sent to instance
我意识到这个崩溃是由 UITextField 引起的。 一旦我摆脱它,将 UITextField 替换为一些 UITextView(不是理想但无论如何)视图正在加载但是当我尝试单击 UITextView 时它崩溃了。其他输入视图工作(开关、dataPicker、tableView 等)
在深入研究之后,我发现问题已经出现在承包商身上。当我在以下代码的第二行放置断点时:
-(instancetype) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self)
{
}
return self;
}
并尝试打印 "self.view" 我收到以下错误:
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-3)..
进程已经返回到表达式求值前的状态。 奇数!
在调用 "viewDidLoad:" 方法签名之前,您无法访问视图,否则它会在所有先决条件都准备就绪之前尝试创建视图。
确保在正确设置后从 "viewDidLoad:"、"viewWillAppear:" 或 "viewDidAppear:" 调用 self.view。
所以..这是 Apple 在 8.1 中创建并在 8.3 中修复的内部错误。 解决方案是避免使用 UITextView 承包商 "initWithFrame" 并使用以下一个:
UITextView *textView = [[UITextView alloc] initWithFrame: frame textContainer: textContainer];