Reputation:
i'm having a couple of problems when i try to alloc a UITextView on an AlertView. Here is my code:
UIAlertView* minhaCritica = [UIAlertView new];
minhaCritica.title = @"7Arte";
[minhaCritica addButtonWithTitle:@"Cancelar"];
[minhaCritica addButtonWithTitle:@"Enviar"];
minhaCritica.message = @"Escreve a tua crítica:\n\n\n\n";
minhaCritica.delegate = self;
[minhaCritica show];
CGRect frame = minhaCritica.frame;
frame.origin.y -= 100.0f;
minhaCritica.frame = frame;
criticaTxtView = [UITextView alloc];
[criticaTxtView setFont:[UIFont systemFontOfSize:16.0f]];
[criticaTxtView initWithFrame:CGRectMake(20.0, 80.0, 245.0, 40.0)];
[minhaCritica addSubview:criticaTxtView];
[criticaTxtView becomeFirstResponder];
my problem is when i start inputing text, the text view doesn't scroll as i type. It should scroll one line up, when the first 2 rows are full.
Can anyone help me with this? Here's a video showing the problem: http://www.welove.com.pt/7arte.swf
Also, i'm having trouble getting the text the user inputed into a fiel. i worked with: criticaText = [[alertView textField] text]; but now it doesn't work with the code above.
Upvotes: 1
Views: 18127
Reputation: 283
It sounds like the relatively benign undocumented UIAlertView API's aren't being allowed anymore, so whether you're using a text field or a text label, you're going to need to use a different mechanism. I'd recommend the following blog posts are good examples of how to address this issue:
Custom UIAlertView (Color chooser)
Embedding UITables into UIAlertViews
These techniques appear to be legitimate from an App Store perspective and address how to embed any sorts of controls into alert views.
Upvotes: 4
Reputation: 52565
I think you're trying to solve the wrong problem. According to the API docs, an Alert View is used "to display an alert message to the user." You shouldn't be using it for input. Use a modal view or something similar instead.
Following the UI conventions of a platform is generally good practice and not doing so here could get your application rejected by Apple.
Upvotes: 7