【发布时间】:2012-03-12 04:39:38
【问题描述】:
如何将警报消息文本字段输入值分配给按钮?
在下面的代码中,我为 textfield 赋值,但要求是通过警报消息为按钮而不是 textfeild 赋值,帮助我解决 iPhone 中的问题。
-(IBAction)alertmessage{
[self setingValue];
}
-(void)setingValue{
myAlert = [[UIAlertView alloc] initWithTitle:@"Enter year" message:@"alert message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[myAlert addTextFieldWithValue:@"" label:@"entervalue"];
alertTextField=[myAlert textFieldAtIndex:0];
alertTextField.keyboardType=UIKeyboardTypeAlphabet;
alertTextField.clearsOnBeginEditing=YES;
alertTextField.clearButtonMode=UITextFieldViewModeWhileEditing;
alertTextField.keyboardAppearance=UIKeyboardAppearanceAlert;
[myAlert show];
[myAlert release];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSString *buttonTitle=[alertView buttonTitleAtIndex:buttonIndex];
if ([buttonTitle isEqualToString:@"Ok"]) {
yearSelection.text= alertTextField.text;
}
}
如果我从警报文本字段输入键盘值作为必须分配或出现在按钮上的输入类型。
【问题讨论】:
-
请确保在发布代码后格式化代码。
-
您想为按钮分配什么值..?你的问题不是很清楚..
标签: iphone objective-c ios5 uibutton uialertview