سؤال

My app was recently rejected due to using a private API (addTextField: method for UIAlertView, which is quite useful, might I add).

Is there any non-private alternative to UIAlertView's undocumented addTextFieldWithValue:label:?

Thanks SO much in advance!

هل كانت مفيدة؟

المحلول

create the text field as a subview of the UIAlertView

// Ask for Username and password.
alertView = [[UIAlertView alloc] initWithTitle:_title message:@"\n \n \n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
// Adds a username Field
utextfield = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)]; 
utextfield.placeholder = @"Username";
[utextfield setBackgroundColor:[UIColor whiteColor]];
utextfield.enablesReturnKeyAutomatically = YES;
[utextfield setReturnKeyType:UIReturnKeyDone];
[utextfield setDelegate:self];
[alertView addSubview:utextfield];

// Show alert on screen.
[alertView show];
[alertView release];

نصائح أخرى

Check out this Open Source code on GitHub for adding UITextFields to a UIAlertView.

http://github.com/enormego/EGOTextFieldAlertView

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top