帶UITextField的UIAlertView無法在iOS 7中工作。如何解決?iOS 7中的UITextField問題
下面是截圖:
這裏是我的代碼:
我怎樣才能在iOS7得到UITextFeield在UIAlertView中?
-(void)takeUserName
{
mChangePlayerAlert = [[UIAlertView alloc] init];
mChangePlayerAlert.title = title;
mChangePlayerAlert.message = @"\n";
mChangePlayerAlert.delegate = self;
[mChangePlayerAlert addButtonWithTitle:@"Save"];
[mChangePlayerAlert addButtonWithTitle:@"Cancel"];
CGRect frame;
frame = CGRectMake(20, 45, 245, 27);//(200, 500, 400, 120);
mTextFeild = [[UITextField alloc] initWithFrame:frame];
mTextFeild.textColor = [UIColor blueColor];
mTextFeild.borderStyle = UITextBorderStyleRoundedRect;
mTextFeild.keyboardType = inType;//;
mTextFeild.returnKeyType = UIReturnKeyDone;
mTextFeild.autocorrectionType = UITextAutocorrectionTypeNo;
mTextFeild.autocapitalizationType = UITextAutocapitalizationTypeNone;
mTextFeild.delegate = self;
[mChangePlayerAlert addSubview:mTextFeild];
mTextFeild.delegate = self;
[mTextFeild becomeFirstResponder];
[mChangePlayerAlert show];
}
請參閱編輯我的答案。 –
哇..其工作感謝...一個小問題,上次我使用shouldChangeCharactersInRange textFeild委託來限制文本的數量。現在,代表不打電話...我怎樣才能限制文本的數量在這個文本框? – iPhoneProcessor
你可以。在顯示警報視圖之前,將'[alertView textFieldAtIndex:0]'的委託設置爲您自己的。現在,像以前一樣,當用戶添加字符時,您將會被調用。 –