我在我的应用程序中添加了一个 UIAlertView
来获取用户输入,但我不确定如何添加第三个按钮。理想情况下,三个按钮将水平穿过警报,或者两个将位于“取消”按钮上方。下面的代码片段是我用来添加 UIAlertView
的。
- (IBAction)initiateSave{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Archive"
message:@"Enter a name to save this as:"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Save Session",@"Save",nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField * alertTextField = [alert textFieldAtIndex:0];
alertTextField.keyboardType = UIKeyboardTypeDefault;
alertTextField.placeholder = @"eg. My awesome file...";
alert.tag = 1;
[alert show];
[alert release];
self.name = [[alert textFieldAtIndex:0]text];
}
最佳答案
Apple 真的不想让你弄乱 UIAlertView。如果它自然格式化的方式不能满足您的需求,请考虑改用自定义呈现(“模态”) View 。
关于iphone - 如何使用 UIAlertStylePlainTextInput 样式在 UIAlertView 中格式化两个以上的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9754777/