Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何将警报消息文本字段输入值分配给按钮?_Iphone_Objective C_Ios5_Uibutton_Uialertview - Fatal编程技术网

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

如何将警报消息文本字段输入值分配给按钮

在下面的代码中,我为textfield赋值,但要求是通过警报消息将值赋值给button,而不是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;
    }
}

如果我从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];
}