Iphone 如何将警报消息文本字段输入值分配给按钮?
如何将警报消息文本字段输入值分配给按钮 在下面的代码中,我为textfield赋值,但要求是通过警报消息将值赋值给button,而不是textfeild,以帮助我解决iPhone中的问题Iphone 如何将警报消息文本字段输入值分配给按钮?,iphone,objective-c,ios5,uibutton,uialertview,Iphone,Objective C,Ios5,Uibutton,Uialertview,如何将警报消息文本字段输入值分配给按钮 在下面的代码中,我为textfield赋值,但要求是通过警报消息将值赋值给button,而不是textfeild,以帮助我解决iPhone中的问题 -(IBAction)alertmessage{ [self setingValue]; } -(void)setingValue{ myAlert = [[UIAlertView alloc] initWithTitle:@"Enter year" message:@"al
-(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;
}
}
如果我从alert textfield中输入键盘值作为必须分配或显示在按钮上的输入类型。请确保在发布代码后对其进行格式化。要分配给按钮的值是什么。。?你的问题不太清楚。。
-(void)setingValue{
myAlert = [[UIAlertView alloc] initWithTitle:@"Enter year" message:@"alert message"
delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
alertTextField=[UITextfiled alloc]initwithFrame:CGRectFrame:(5,25,200,35)]; //set the frame as you need.
alertTextField.Placeholder=@"Enter Value";
alertTextField.keyboardType=UIKeyboardTypeAlphabet;
alertTextField.clearsOnBeginEditing=YES;
alertTextField.clearButtonMode=UITextFieldViewModeWhileEditing;
alertTextField.keyboardAppearance=UIKeyboardAppearanceAlert;
[myAlert addSubview:alertTextFiedl];
[alertTextField release];
[myAlert show];
[myAlert release];
}