+4  A: 

Even if you can get this working it's not going to be very iPhone-y. The UIAlertView really is not designed for user input like this. If you look in all the Apple apps you'll see that they use a new view that displayed using the presentModalViewController: method of UIViewController.

Stephen Darlington
Ahhhh, I'll check into that. Of course, I prefer a "proper UI" solution, I just couldn't find it under "dialog" or my other searches.Thanks!
Olie
Btw, how did you get the buttons to layout 2x2? Did you subclass, or is this all done with an off-the-shelf UIAlert?Thanks!
Olie
A: 

Try putting in some (\n)s after the title in the UIAlertView initialization. That will push down the buttons. And I agree with Stephen here. There are chances that Apple might reject an app if it uses controls in a way they shouldn't be. (there's some clause in the Human Interface Guidelines about that!)

lostInTransit
+8  A: 
rpetrich
Yes. [find setmessage:@"\n"] is the call for which I was looking. Still investigating approved dailogs, but I believe this is it.Thanks!
Olie
@repetrich how did you insert 4 buttons in two columns are they custom buttons or is there some trick hidden please throw some light on this.
Madhup
+1  A: 

Most probably You would want to look into the addTextFieldWithValue method of the UIAlertView? Add the following code somewhere at the top of Your class:

@interface UIAlertView ()
- (void) addTextFieldWithValue: (NSString*) val label: (NSString*) label;
- (UITextField*) textField;
@end

It’s not official, but IMHO it’s not getting You rejected from the App store and it’s much better solution than hacking the textfield into the dialog Yourself.

zoul
This may not have been the case back then, but I've recently read about several rejections on the grounds of using this private API call. Apple has a new solution in place that is checking for any private API usage and really cracking down hard on this practice.
Mirko Froehlich
Yep, I just got rejected for this very reason.
zpasternack
+2  A: 

This simpler method works for me:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView"
    message:@"<Alert message>" delegate:self cancelButtonTitle:@"OK"
    otherButtonTitles:nil];
[alert addTextFieldWithValue:@"" label:@"Text Field"];

Hope that helps. Oh if you needed multiple button rows then it's:

[alert setNumberOfRows:3];

Cheers

Megachan
Do note that using the undocumented setNumberOfRows: method risks rejection from the AppStore.
Yang
+2  A: 

Zoul proposed the best method, to capture user input just do:

a) Add the UITextFieldDelegate protocol to your class.

b) Do something like

    UIAlertView *insertScore = [UIAlertView new];
 [insertScore setDelegate:self];
 [insertScore setTitle:@"New Title!"];
 [insertScore addButtonWithTitle:@"Cancel"];
 [insertScore addButtonWithTitle:@"Ok"];

 insertScore.message = @"\n";

 [insertScore addTextFieldWithValue:@"Input" label:@"player"];

 [[insertScore textField] setDelegate:self];

 [insertScore show]; 

 [insertScore release];

c) The crucial part was to set the delegate of the textField to self, then to access data you can simply:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{
  NSLog(@"%@",[[alertView textField] text]);
}

Hope this helps someone, since I had to think a bit to get it right.

Mr.Gando
A: 

dear rpetrich in your screenshot u have shown four buttons in two columns. how u achieved that ?? provide code example will be extra help

luckee
Any one can give idea to handle button columns in UIAlertview ???
luckee
+1  A: 

Explains how to set the number of columns, have not tested it.

http://iloveco.de/uikit-alert-types/

However there is a private method, setNumberOfRows:(int)n that will allow you to set a maximum number of rows to display the buttons in. To use this method we need to add our own additions to the UIAlertView class. We do this by adding an @interface for UIAlertView in our .m file.

// extend the UIAlertView class to remove the warning caused
// by calling setNumberOfRows.
@interface UIAlertView (extended)
- (void) setNumberOfRows:(int)num;
@end

This will allow us to call the method without the compiler throwing us a warning.

[myAlert setNumberOfRows:2];
oden
this may remove the warning, but you're still using a private-API == posible app rejection
William Denniss