views:

5774

answers:

4

Anyone have code to make this:

http://booleanmagic.com/uploads/UIAlertViewHack.png

or better yet, a 3x2 grid of buttons with images using the UIAlertView object.

I dont care about the textfield, its the buttons in a grid i want (preferably with images rather than text)

+9  A: 

I think your best bet is to forget customizing UIAlert view and build a custom view yourself.

For one, what you're showing really isn't an "alert" so it's counter to what UIAlertView is designed to be for. This means that you're changing the UI paradigm on the user which is never a good idea.

Second, it would be much easier to animate a custom view into place than to try and hack UIAlertView to get it to do what you want.

August
Not only that, but trying to customize UIAlertView is one of the things that can get your app rejected by Apple pretty consistently.
Chris R. Donnelly
+2  A: 

There are no in-built components for this. UIAlertView should just have text and buttons as per the HIG document.

You will have to create your own view and add controls to it. The HeadsUpUI example in the SDK shows how to show a custom menu-like view as an overlay.

Hope that helps.

lostInTransit
+4  A: 

First you need to make the alert box bigger to accomodate your controls, yet it has to be placed at the center.

For this, instead of setting the frame size, your the message text with "\n"s as necc. e.g.:

alert = [[UIAlertView alloc] initWithTitle:@"Rate this picture."
message:@"Tap a star to rate.\n\n\n\n " /*------ look at here!!----*/
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];

Then use a UIAlertViewDelegate for the alertview.

override its, viewWillAppear: add your buttons and set their frames manually at desired position.

OR: create a entire view with a view controller, and add the view to the alert box like:

[myalertview addSubvew:mycomplexalert];

Hope this will come into your help :)

I am using alert boxes for rating input with star images,twitter,fb feedback etc.

Shaikh Sonny Aman
+1  A: 

This tutorial covers how to subclass UIAlertView to achieve an input text box. It explains how to enlargen the view, add subviews (like text boxes or images) and make a transform to move the box up higher on the screen.

Hauke