2014-09-11 110 views
0

我想顯示一個基於警報窗口上的確定按鈕的UITextField。所以,當用戶按OK按鈕時,另一個文本框應該到達用戶可以輸入配置文件名稱的位置。但是,根據下面的代碼,我看到在單擊OK後立即看到「沒有指定配置文件名稱」,因爲它發現profile.txt爲空。這是一段代碼,它顯示彈出警報,提示用戶保存配置文件名稱的配置文件。值添加到UITextField

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello, User ! Save Profile" message:@"Provide a profile Name" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK" ,nil]; 

profileName = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 2600.0, 25.0)]; 

[profileName setBackgroundColor:[UIColor whiteColor]]; 

[alert addSubview:profileName]; 

CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0); 

[alert setTransform:myTransform]; 

[alert show]; 

[alert release]; 

感謝您的回覆!

在此先感謝!

+0

通過使用UIAlertViewStyleDefault警報視圖,我能夠繼續。謝謝! – 2014-09-11 13:59:29

回答

0

我能得到它的工作iOS7用,

alert.alertViewStyle = UIAlertViewStylePlainTextInput; profileName = [alert textFieldAtIndex:0];

謝謝