Any non-private API alternative for this?

被刻印的时光 ゝ 提交于 2019-12-22 11:29:55

问题


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!


回答1:


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];



回答2:


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

http://github.com/enormego/EGOTextFieldAlertView



来源:https://stackoverflow.com/questions/3784134/any-non-private-api-alternative-for-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!