當前的代碼工作完美的iOS 7之前,在iOS 7沒有字段輸入用戶的名稱,從掃描這些論壇我發現在iOS7上更改與addsubview函數有關的東西,這裏是當前的代碼;UIAlert與iOS 7的AddSubview替換
任何人都可以協助將這個與iOS7(最好不破的iOS 6的環節寧願保持應用程序既OS版本兼容)工作
- (void) createScoreInput {
changePlayerAlert = [UIAlertView new];
changePlayerAlert.title = @"Enter your name";
changePlayerAlert.message = @"\n\n";
changePlayerAlert.delegate = self;
[changePlayerAlert addButtonWithTitle:@"Save"];
[changePlayerAlert addButtonWithTitle:@"Cancel"];
CGRect frame = changePlayerAlert.frame;
frame.origin.y -= 100.0f;
changePlayerAlert.frame = frame;
changePlayerTextField = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 245, 27)];
changePlayerTextField.borderStyle = UITextBorderStyleRoundedRect;
[changePlayerAlert addSubview:changePlayerTextField];
changePlayerTextField.keyboardType = UIKeyboardTypeNamePhonePad;
changePlayerTextField.returnKeyType = UIReturnKeyDone;
changePlayerTextField.autocorrectionType = UITextAutocorrectionTypeNo;
changePlayerTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
changePlayerTextField.delegate = self;
}
需要輸入由於有文檔中的iOS 7蘋果公司指出,你不能改變[中'UIAlertView'](https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html):'視圖層次結構是類是私人的,不能被修改。' – rckoenes
@rckoenes我也相信這也是iOS 6和iOS 5的情況,但蘋果現在實際上對它更加嚴格。 – Popeye