hugo411
hugo411

Reputation: 346

Objective-C : iphone programming 'UITextField while editing method'

I got a UITextField and I want to send a UIAlertView if the user enter nothing in the UITextField.

Upvotes: 0

Views: 427

Answers (1)

ennuikiller
ennuikiller

Reputation: 46965

First capture the input:

NSString *text = myTextField.text;

Then test for null string and present alertview:

if (title == [NSNull null] || title.length == 0 ) {

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:button1 otherButtonTitles:button2, nil];
    [alertView show];
}

Upvotes: 1

Related Questions