0

我在表单视图上有多个文本字段。我想在用户单击按钮时附加它们。但其中只有一个返回文本字段中的值,其余的返回 null。

。H

@property (nonatomic, strong) IBOutlet UITextField *textMonth;
@property (nonatomic, strong) IBOutlet UITextField *textDay;
@property (nonatomic, strong) IBOutlet UITextField *textYear;
@property (nonatomic, strong) IBOutlet UITextField *textMeetingName;

.m

@synthesize textDay=_textDay;
@synthesize textMonth=_textMonth;
@synthesize textYear=_textYear;
@synthesize textMeetingName=_textMeetingName;


- (BOOL)disablesAutomaticKeyboardDismissal {
    return NO;
}
//this dismiss keyboard on ios
- (BOOL)textFieldShouldReturn:(UITextField *)textField {

        [_textMonth resignFirstResponder];
        [_textDay resignFirstResponder];
        [_textYear resignFirstResponder];
        [_textMeetingName resignFirstResponder];


    return YES;
}
//submit create folder request to dropbox
- (IBAction)sendCreateFolderRequest:(id)sender{

    if ([_textMonth.text intValue]>12 ||[_textMonth.text intValue]<1 ) {
        //alertview choose a number between 1 and 12
        [self popUpAlertview:@"Please choose a month between 1 and 12"];
    }
    else if ([_textDay.text intValue]>31 || [_textDay.text intValue]<1){
        //alert view choose a number between 1 and 31
        [self popUpAlertview:@"Please choose a day between 1 and 31"];
    }
    else if ([_textYear.text intValue]<0){
        //alert view please enter a correct year
        [self popUpAlertview:@"Please enter a correct year"];
    }
    else if ([_textMeetingName.text length]<=1){
        //alert view meeting name is too short please enter a longer name
         [self popUpAlertview:@"Name is too short. Please enter a longer name"];
    }
    else{

        NSString *sendFolderName=[NSString stringWithFormat:@"/Up2Date/%@.%@.%@.%@",_textMonth.text,textDay.text,textYear.text,textMeetingName.text];

        NSLog(@"Send folder name %@",sendFolderName);

    }

}

输入是11,12,13,asdaad 输出是Send folder name /Up2Date/11.(null).(null).(null)

奇怪的是,如果字段值错误(例如 11、45、20),我的 if else 方法会捕获它,它会按我的预期弹出警报视图。

那么似乎是什么问题?也许我不应该一次性辞去他们的第一响应者?

4

1 回答 1

3

改变

NSString *sendFolderName=[NSString stringWithFormat:@"/Up2Date/%@.%@.%@.%@",_textMonth.text,textDay.text,textYear.text,textMeetingName.text];

NSString *sendFolderName=[NSString stringWithFormat:@"/Up2Date/%@.%@.%@.%@",_textMonth.text,_textDay.text,_textYear.text,_textMeetingName.text];

你忘了加下划线。

于 2012-10-31T19:39:15.557 回答