xcode 我的 TextField 不可编辑
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8982918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
My TextField is not editable
提问by Roy
I know it is a very simple Question, but the TextField is not Editable.
我知道这是一个非常简单的问题,但 TextField 不可编辑。
I have three UIViews, in each UIView contains three TextFields. The TextFields in the 2nd and 3rd UIView are working perfectly. But in the TextFields in the 1st UIView are really weird.
我有三个 UIView,在每个 UIView 中包含三个 TextField。第二个和第三个 UIView 中的 TextFields 工作正常。但是在第一个 UIView 中的 TextFields 中真的很奇怪。
Let the TextFields are First, Middle , Last Name . First TextField is working fine, Middle is working only sometimes (it means i need to touch several times) and at last, the Last Name TextField is COMPLETELY not working.
让 TextFields 是 First, Middle , Last Name 。第一个 TextField 工作正常,Middle 只是有时工作(这意味着我需要触摸几次),最后,姓氏 TextField 完全不起作用。
What could be the problem ?
可能是什么问题呢 ?
EDIT:
编辑:
_bgScrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
_bgScrollView.clipsToBounds = YES;
_bgScrollView.scrollEnabled = YES;
_bgScrollView.pagingEnabled = NO;
[_bgScrollView addSubview:FirstView];
[_bgScrollView addSubview:SecondView];
[_bgScrollView addSubview:ThirdView];
[self layoutSubViews];
_bgScrollView is scrollView Object
回答by Sarah
have you connected it with XIB and also delegate it ?Also have you implemented this function?
你有没有把它与XIB连接并委托它?你也实现了这个功能吗?
- (BOOL) textFieldShouldBeginEditing:(UITextField *)textField {
return [self isEditing];
}
回答by rakeshNS
Make sure that userInteractionEnabled=YES in textField
确保 textField 中的 userInteractionEnabled=YES
回答by Prathiba
Make sure no other view is sitting on top of the text field - sorry i did not know how to comment, so put it as an answer.
确保文本字段顶部没有其他视图 - 对不起,我不知道如何评论,所以把它作为答案。
回答by Shubhank
maybe you have a transparent image view/button//or nay other thing above the text field in the nib...that might not let the text field get any touches..
也许你有一个透明的图像视图/按钮//或者在笔尖文本字段上方的任何其他东西......这可能不会让文本字段得到任何触摸......
If you have make it as an IBOutlet.. then call the
如果您已将其设为 IBOutlet .. 然后调用
[[self YourTextField] becomeFirstResponder]
in your ViewDidLoad
[[self YourTextField] becomeFirstResponder]
在你的 ViewDidLoad
If it works..then there is problem in your xib..the text field is not getting any touches.
如果它有效..那么你的xib有问题。.文本字段没有得到任何触摸。
回答by Simon Barkhuizen
You can always try to put the following in you ViewController.m:
您始终可以尝试将以下内容放入您的 ViewController.m 中:
- (void)viewDidLoad
{
//textField's Outlet should be declared in the (.h) file
//and synthesized in the (.m) class
//then add the code below.
[self textField].enabled = YES;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
or just edit the viewDidLoad that should already be there.
或者只是编辑应该已经存在的 viewDidLoad。
Then, later on, specify manually, with code, that editing should begin, if needed.
然后,稍后,如果需要,使用代码手动指定应该开始编辑。
回答by user2819502
I ended up doing this by accidentally unchecking "User Interaction Enabled" on the entire view! I had meant to do that just on the header image. Well, I am just learning the thing...
我最终通过在整个视图上不小心取消选中“启用用户交互”来完成此操作!我本来打算只在标题图像上这样做。嗯,我只是在学习这个东西......