ios - [self presentViewController : animated: completion:] 后 UITextView 和 UITextField 没有响应

标签 ios iphone ios8 xcode6

我在 Xcode 6 中使用 UITextView 和 UITextField 时遇到问题。

假设我有 View A(主视图) 按下按钮后,通过以下方法呈现另一个 View B:

B * bView = [[B alloc] initWithNibName:@"B" bundle:nil];
[bView setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentViewController:bView animated:TRUE completion:nil];

在 View B 中,按下某个 Button 并使用相同的方法呈现另一个 View C:

C * cView = [[C alloc] initWithNibName:@"C" bundle:nil];
[cView setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentViewController: cView animated:TRUE completion:nil];

View C 有两个 UITextView。在用户交互时,方法:

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView

被调用但随后什么也没有发生,应用程序卡住并且一切都停止了 + 键盘永远不会显示..

顺便说一句:在模拟器中,如果我使用硬件键盘,一切正常。在设备上,如果我正在连接蓝牙键盘,则一切正常。否则当我使用 iOS 键盘时会出现问题..

此外,在 Xcode 5 上,一切都运行得非常好

这是它卡在的函数

libsystem_kernel.dylib`mach_msg_trap:
0x194e6ce74:  movn   x16, #30
0x194e6ce78:  svc    #128
0x194e6ce7c:  ret    -----------> Thread 1 : Signal SIGSTOP

等待您的回复。

谢谢, 艾哈迈德

最佳答案

我解决了这个问题。似乎在 Xcode 6 和 iOS 8 中,调用 presentViewController 后无法再在 viewWillLayoutSubviews 方法中设置 superviewbounds。

- (void)viewWillLayoutSubviews{
    [super viewWillLayoutSubviews];
    self.view.superview.bounds = CGRectMake(0, 0, 700, 550);
}

所以通过删除

self.view.superview.bounds = CGRectMake(0, 0, 700, 550);

从上面的函数来看,它起作用了。

只需添加

VC.preferredContentSize = CGSizeMake(700, 550);

调用之前在父 View Controller 中

[self presentViewController:VC animated:TRUE completion:nil];

为 View 提供正确的框架。

谢谢大家

关于ios - [self presentViewController : animated: completion:] 后 UITextView 和 UITextField 没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28963075/

相关文章:

iphone - 解码图像属性中的 GPS 坐标

Swift 更新约束

android - 解析云代码奇怪的错误

iphone开发: changing the button image on tableviewcell

c++ - 尝试在 C++ 代码中包含 iPhone OpenGLES header

ios - 从 Storyboard 中加载 View Controller 花费了太多时间

proxy - iOS 8/Xcode 6 Simulator 不再使用 HTTP 代理

ios - 为 UILocalNotification 播放系统声音

ios - 我可以从我的 iOS 应用程序启用/禁用移动数据吗?

ios - 如何在 iOS 中使用 MQTT?