开发者

how to set validation on button current title

开发者 https://www.devze.com 2023-03-08 06:48 出处:网络
hi i am new in iphone development,and i have task to develop the uibutton and picker relational application.

hi i am new in iphone development,and i have task to develop the uibutton and picker relational application.

i have to develop the one view which have the button 1 uipicker view. when i run the application at that time the title of the button is blank. if the user directly click to submit the button at that time user will get the error message.

but i can get the error msg and my following code is not working it is submiting the form without checking the button text validation.

following is my code:

if ([btnPicker.currentTitle isEqualToString:@" "]) {

     UIAlertView *alertPicker = [[UIAlertView alloc] initWithTitle:@"Required" message开发者_JS百科:@"Please,Select Month & Date." delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No",nil];
     [alertPicker show];
     NSLog(@"%@", alertPicker);
     [alertPicker release];
 }


[btnPicker.currentTitle isEqualToString:@""];

or

if ([btnPicker.currentTitle length]==0)


Actually a blank string is an empty string @"" not a space @" ". You have to test an empty string like this,

[btnPicker.currentTitle isEqualToString:@""];


Shouldn't it be [btnPicker.currentTitle isEqualToString:@""] ? String without the space?

0

精彩评论

暂无评论...
验证码 换一张
取 消