2013-01-04 94 views
0

我一直在將此屬性作爲未聲明時應該在框架中可用。UIAlertViewStylePlainTextInput未聲明

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Email Alert" message:@"Enter your Email Address" delegate:self cancelButtonTitle:@"Hide" otherButtonTitles:nil]; 
[alert setAlertViewStyle:UIAlertViewStyleSecureTextInput]; 
[alert show]; 
[alert release]; 

回答

0

您是否正確實施了UIAlertViewDelegate的方法?

像這樣(沒有重命名它)?

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
+0

是啊,多數民衆贊成宣佈已經 – redoc01

+0

好我壞了!如果這是由於您使用iOS4,請查看此答案:http://stackoverflow.com/questions/4805637/uitextfield-inside-an-uialertview-not-working-in-ios4-1-and-works-in- 3-0 –

1

我以這種方式使用了UIAlertViewStylePlainTextInput。請根據需要修改代碼。

    alertType = @"phoneNumberAlert"; 
       UIAlertView *phoneNumberAlert = [[UIAlertView  
       alloc]initWithTitle:@"Notice"  
       message:@"Please enter your Phone Number" delegate:self 
       cancelButtonTitle:nil otherButtonTitles:@"Ok", nil]; 
       [phoneNumberAlert setAlertViewStyle:UIAlertViewStylePlainTextInput]; 
       UITextField *alertTextField = [phoneNumberAlert textFieldAtIndex:0]; 
       alertTextField.keyboardType = UIKeyboardTypeNumberPad; 
       [phoneNumberAlert show]; 
       [phoneNumberAlert release]; 
0
> alertView.alertViewStyle = UIAlertViewStylePlainTextInput; 
>  [alertView textFieldAtIndex:0].keyboardType = UIKeyboardTypeNumberPad;