【问题标题】:UITextView responding to touches, but keyboard doesn't appearUITextView 响应触摸,但没有出现键盘
【发布时间】:2014-09-09 13:45:02
【问题描述】:

我无法理解。我有一个 uitextview,当它开始编辑为键盘腾出空间时,它会向上动画。我点击 uitextview 并注册它已经开始编辑并且它动画但键盘没有出现。这种情况以前从未发生过,我已经对该应用程序进行了数百次测试。我什至让 textview 在构建视图时成为第一响应者,但键盘仍然不显示。

我有 .m 文件和 .h 文件,所以这不是问题..

这里是设置代码:

self.addDescriptionTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 470, 320, 100)];
[self.addDescriptionTextView setBackgroundColor:[UIColor colorWith8BitRed:0 green:0 blue:0 alpha:.5]];
[self.addDescriptionTextView setTextColor: [UIColor whiteColor]];
[self.addDescriptionTextView setFont:[UIFont fontWithName:@"Verdana" size:16]];
[self.addDescriptionTextView setDelegate:self];

self.addDescriptionTextView.textContainer.maximumNumberOfLines = 10;
[self.addDescriptionTextView.layoutManager textContainerChangedGeometry:self.addDescriptionTextView.textContainer];

[confirmView addSubview:self.addDescriptionTextView];

【问题讨论】:

  • 什么版本的iOS?哪个设备?

标签: ios objective-c


【解决方案1】:

我在我的 iOS 设备上运行了你的代码,然后键盘出现了,

这是我运行的 viewDidLoad 代码,

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.addDescriptionTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 470, 320, 100)];
self.addDescriptionTextView.backgroundColor = [UIColor redColor];
[self.addDescriptionTextView setTextColor: [UIColor whiteColor]];
[self.addDescriptionTextView setFont:[UIFont fontWithName:@"Verdana" size:16]];
[self.addDescriptionTextView setDelegate:self];

self.addDescriptionTextView.textContainer.maximumNumberOfLines = 10;
[self.addDescriptionTextView.layoutManager textContainerChangedGeometry:self.addDescriptionTextView.textContainer];

self.addDescriptionTextView.editable = YES;

[self.view addSubview:self.addDescriptionTextView];
}

尝试添加 UIView.editable 行,但它应该自动设置为 yes。

可能和confirmView有关?

还可以尝试更改 UIColor 背景颜色线,我遇到了你的错误。

编辑:在 iPhone4s 上运行后,您的问题是您启动 UIView 的位置(尝试将 CGRect 中的 470 更改为 0 以查看错误)

【讨论】:

  • 如果它有帮助我的设备是具有最新 ios 的 iPhone5s
  • 感谢您的帮助,但我也在使用最新 ios 的 iPhone5s 上运行它。再说一遍,以前从未发生过,所以我完全感到困惑。
  • 你在运行时看到 textView 了吗?
  • 您不是在 iOS 8 上运行吗?我注意到测试版的这种行为。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多