简体   繁体   中英

UITextView in UIModalPresentationFormSheet freezes app iOS 10

I have a UITextView inside a view controller which I present using modal form sheet

vc.modalPresentationStyle = UIModalPresentationFormSheet;
[AppDelegate.rootController presentViewController:vc animated:YES completion:nil];

All was well till iOS 9.3. Then came iOS 10/10.0.1

With this, every time user taps inside the text field to bring up the keypad, the app freezes. I can't figure out why. I tried making the UITextView as first responder. That fires up the keyboard just fine, I can type and hit a button on VC to take action. The VC and keyboard both gets dismissed. But again, if without hitting the button, if I try to simply dismiss the keyboard, app freeze.

Any ideas at all from anyone?

Was experiencing something like this earlier today. The fix for me was as follows (unsure why, something must have changed in iOS 10).

In legacy code:

- (void)viewWillLayoutSubviews {
    self.view.superview.bounds = CGRectMake(0,self.view.superview.bounds.origin.y, 768, 256);
    [super viewWillLayoutSubviews];
}

Removing it fixed my issue.

I moved my code to viewDidLayoutSubviews from viewWillLayoutSubviews. And it does not freeze anymore. Looks like an iOS 10 bug to me.

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    self.view.superview!.bounds = CGRectMake(0,0, 500, 300)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM