0

I want that when user enter wrong value in the textfiled it shows alert and it makes textfield emty and also the button title to empty.In my code textfield empty is done but button is not getting the empty values

below is the my code

     if (monthText>totalnumber) {
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Value Must Be Less than total number of dogs " delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];

    NSString *titleMonth =@"0";
    [cereniaButton setTitle:@"" forState:UIControlStateNormal];






    cereniaTextField.text=@"";


  }


int year=12;
int monthButtonTitle=monthText*year;
NSString *titleMonth =[NSString stringWithFormat:@"%d",monthButtonTitle];
[cereniaButton setTitle:titleMonth forState:UIControlStateNormal];
4

4 に答える 4

0

タイトルをリセットしていますが、タイトルがリポポレートされた後です。

試す

if (monthText>totalnumber) {
    //...yourcode...

   return;
}

お知らせ下さい

于 2012-06-06T10:46:49.690 に答える
0

タイトルをボタンに設定してからこの行を書きます

[self.view setNeedsDisplay];
于 2012-06-06T10:39:12.147 に答える
0

like を直接割り当てるとどうなるか

[btn setTitle:@"" forState:UIControlStateNormal];

于 2012-06-06T10:29:40.003 に答える