0

変数 x が 1000 より大きい場合にアラート ビューをポップアップさせたいと考えています。

これまでの私のコードは次のとおりです。

if (x>1000) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Title", nil)
                                message:NSLocalizedString(@"Message", nil)
                                delegate:nil
                                cancelButtonTitle:NSLocalizedString(@"OK", nil)
                                otherButtonTitles:nil];
    [alert show];
    [alert release];
}
4

1 に答える 1

0

それが私自身の質問への答えです:

- (void)textFieldDidEndEditing:(UITextField *)textField {

float x = ([numberOfPeople.text floatValue]);

if (x>1000) {
    UIAlertView *objAlert = [[UIAlertView alloc] 
initWithTitle:@"Fehler" message:@"The entered Number should not be higher than 1000." 
delegate:nil 
cancelButtonTitle:nil 
otherButtonTitles:@"Close",nil];
    [objAlert show];

    textField.text=@""; // clears the text field
}

}

于 2013-01-17T09:37:18.590 に答える