所以我最近做了一個iOS 6的應用程序,它讀取PDF文件。它在我的iPhone 3GS上運行良好,但是當我在新版本的Xcode(最初使用4.5,現在使用6.01)中重新編譯iOS 8時,輸入您要加載的PDF名稱的文本字段不再顯示在它的位置應該。UITextField沒有出現在iOS8中
當用戶按下打開時,問題中的文本字段出現在警告框內。
繼承人它在iOS 6中
alert = [[UIAlertView alloc]initWithTitle:@"Please enter a valid PDF name below:" message:@"(Please add .PDF on the end!) \n \n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"ok", nil];
textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 200, 300, 40)];
[textField setBackgroundColor:[UIColor whiteColor]];
textField.delegate = nil;
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.placeholder = @"PDF name";
textField.tintColor = [UIColor colorWithRed:98.0/255.0f green:98.0/255.0f blue:98.0/255.0f alpha:1.0];
textField.keyboardAppearance = UIKeyboardAppearanceAlert; //set up an alert box with a text feild
[textField becomeFirstResponder];
[alert addSubview:textField];
[alert show];
[alert release];
在你的情況是設置alert.alertViewStyle = UIAlertViewStylePlainTextInput;這將爲您添加一個文本字段。您可以使用UITextField * textField = [alertView textFieldAtIndex:0];在UIAlertView委託回調中訪問它。 –