Re: [問題] TextField 放入alert裡面導致鍵盤無法收回

看板MacDev作者 (.....)時間14年前 (2011/07/19 21:04), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
借發問一下 我也有一樣的問題 在.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
文章代碼(AID): #1E9O3dGZ (MacDev)
文章代碼(AID): #1E9O3dGZ (MacDev)