sách gpt4 ai đã đi

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

In lại 作者:行者123 更新时间:2023-11-29 12:26:30 26 4
mua khóa gpt4 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

等待您的回复。

谢谢,艾哈迈德

1 Câu trả lời

我解决了这个问题。似乎在 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
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com