Re: [問題] TextField 放入alert裡面導致鍵盤無法收回
借發問一下
我也有一樣的問題
在.h中已加入UITextFieldDelegate
並宣告 UITextField *field;
在.m中
- (BOOL)textFieldShouldReturn(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (void)willPresentAlertView(UIAlertView *)alertView
{
CGRect frame = alertView.frame;
if(alertView==alert_message)
{
frame.origin.y -= 120;
frame.size.height += 80;
alertView.frame = frame;
}
//加入自訂的label及UITextFiled
field= [[UITextField alloc] initWithFrame: CGRectMake( 30,70,217, 30 )];
field.borderStyle=UITextBorderStyleRoundedRect;
[alertView addSubview:field];
field.delegate=self;
field.returnKeyType=UIReturnKeyDone;
}
奇怪的是
中斷點都有跑進 [textField resignFirstResponder];
但無法執行就是無法執行
請各位指點
謝謝
※ 引述《markzog21 (殘羽星辰)》之銘言:
: 如題
: -(BOOL) textFieldShouldReturn:(UITextField *) textField
: {[textField resignFirstResponder]
: [textField becomeFirstResponder];
: //[(UIAlertView *)[textField superview] dismissWithClickedButtonIndex:1 animated:YES];
: [myAlertView show];
: return YES;
: //[accoutPassword resignFirstResponder];
: //return YES;
: }
: 網路上是說textFieldShouldReturn:(UITextField *) textField就可以
: 但是測試發現alert裡面放下field以後叫出的鍵盤
: 似乎不適用這個function
: 因為按下retrun鍵無進入此function
: 好像是delegate的問題但不知如何修改delegate.....
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.240.183.240
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章