My TextField is not editable

耗尽温柔 提交于 2019-12-13 16:15:30

问题


I know it is a very simple Question, but the TextField is not Editable.

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.

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.

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

回答1:


have you connected it with XIB and also delegate it ?Also have you implemented this function?

- (BOOL) textFieldShouldBeginEditing:(UITextField *)textField {
    return [self isEditing];
}



回答2:


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.




回答3:


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

[[self YourTextField] becomeFirstResponder] in your ViewDidLoad

If it works..then there is problem in your xib..the text field is not getting any touches.




回答4:


Make sure that userInteractionEnabled=YES in textField




回答5:


You can always try to put the following in you 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.

Then, later on, specify manually, with code, that editing should begin, if needed.




回答6:


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...



来源:https://stackoverflow.com/questions/8982918/my-textfield-is-not-editable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!