开发者

App freezes when begin editing UITextField

开发者_如何转开发I've got two UITextFields firstname and email. I've got those as retained properties in my .h file and I synthesize them in my .m file. Editing the firstname field works fine. However as soon as I tap the email textfield to edit it, the app just freezes. It doesn't crash so there's nothing useful in the debugger.

This is what I have in viewDidLoad.

- (void)viewDidLoad
{
    [super viewDidLoad];


    firstname.delegate = self;
    email.delegate = self;
    email.adjustsFontSizeToFitWidth = YES;    

    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 20)];
    email.leftView = paddingView;
    email.leftViewMode = UITextFieldViewModeAlways;
    email.rightView = paddingView;
    email.rightViewMode = UITextFieldViewModeAlways;

    firstname.leftView = paddingView;
    firstname.leftViewMode = UITextFieldViewModeAlways;
    firstname.rightView = paddingView;
    firstname.rightViewMode = UITextFieldViewModeAlways;

    [paddingView release];
  }

Anyone got a clue?

Thanks!


Ok fixed it.

A single UIView (or UIImageView) cannot be displayed on screen twice at the same time. I fixed this by creating separate padding views for the UITextFields.


What is the leftView here? and

why you are releasing the paddingView ???

Try

[paddingView addSubView:firstname];
[paddingView addSubView:email];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜