gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 12:26:30 26 4
gpt4 key购买 nike

我在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com