ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.86k stars 1.7k forks source link

YYTextView使用的时候会崩溃 #747

Open QQ920924960 opened 7 years ago

QQ920924960 commented 7 years ago

我刚新建了一个空的工程,使用YYTextView的时候会直接崩溃,报错为:exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'

但是使用系统的UITextView就不会崩溃,这是什么原因呢?

同样的创建代码:

- (void)viewDidLoad {
    [super viewDidLoad];

//    UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 80, 200, 300)];
//    [self.view addSubview:textView];
//    textView.backgroundColor = [UIColor redColor];

    YYTextView *textView = [[YYTextView alloc] initWithFrame:CGRectMake(10, 80, 200, 300)];
    [self.view addSubview:textView];
    textView.backgroundColor = [UIColor redColor];

}

运行系统版本为iOS11.1

cocoay commented 6 years ago

加一个导航就不会崩溃了,不清楚具体原因

BestiOSDev commented 6 years ago

我看报错信息 好像是 UIWindow 必须有一个 rootviewController 在didFinishLaunchingWithOptions这个方法放回 YES 之前

TonyGJJ commented 5 years ago

@cocoay 用你的办法解决了