UITextField in UIView in UIAlertView not working?
In my iPhone application, If I add uitextfield in uialertview it works fine bt if i add it into uiview and if uiview is added into uialertview it is nt working. Getting strange behiviour?
Please help, If any one know about that! Thank you. Note:开发者_如何转开发 here UItextField not working means- it is not taking any input but interesting is that if click on it keyboard appears, also its delegate are not gets calling.just add a temp textField in ur alerView below the view of yours
tf = [[[UITextField alloc] initWithFrame:CGRectZero] autorelease];
[alertView addSubView:tf];
in your alertView and every thing will work good ..... this is just to inform alertView that there is some view in it that need to be first responder at some point of time
i had the same problem. i tried change size of frames. this code isn't really good, but works for me:
- (void)drawRect:(CGRect)rect {
self.bounds = CGRectMake(0, 0, 284, 248);
int i = 0;
for (UIView*classW in self.subviews) {
if ([NSStringFromClass([classW class]) isEqualToString:@"UIThreePartButton"]) {
classW.frame = CGRectMake(11+135*i, 189, 127, 43);
i++;
}
if ([NSStringFromClass([classW class]) isEqualToString:@"UIView"]) {
classW.backgroundColor = [UIColor redColor];
CGRect f = classW.frame;
f.size.height += 30;
classW.frame = f;
}
}
}
I just created a post, which can solve your problem.
Key: You need to add a fake UITextfield via coding behind your view, in order to make your other UITextfields in your customized view to capture inputs from Keyboard. I don't why, but it works.
http://creiapp.blogspot.com/2011/08/how-to-add-uitextfield-to-uialertview.html
精彩评论