I want to show two buttons in 'UIAlertview'. Because the button text is very long, I want the buttons to appear one above the other in a vertical stack instead of side by side. Is it possible to do this?
You would need to subclass UIAlertView and create your own custom alert with the buttons as you described.
Unfortunately your only choices are to either make the button text shorter or to add another button. UIAlertView only lays out rows of buttons when there are more than two.
Aside from that, you can subclass UIAlertView, but it would probably be easier to simply create your own custom view / view controller at that point.
Related
As I observed that UIActionSheet is always appearing from down side in iPhone,
but in some app, as I saw in AlarmClock, then two button became visible, one from upside and second from downside of iPhone,
What is that exactly, I can't understand, as far as I feel, it looks UIActionSheet,
I want such appearance for one of my app....
Help!
Yes just like Ole said, you can't customize UIActionSheet . But since it is just a simple subview you can create your personal "action sheet" by subviewing and animating. So if you want a button to appear on the top and one on the button, then create two UIViews resize them to the right size for your button, add your action sheet style background or any other background, add your button, connect your IBActions to the buttons and your IBOutlets to the views. Then when you want the buttons to appear animate them onto the screen (using sone CGRect, animation time and finally [UIView commitAnimations])
Probably just one or two custom views with a custom animation. UIActionSheet is not customizable so if you want something else than the default behavior you have to write it yourself. It's not that difficult.
I'm just looking for advice with this as I have no idea where to start but I think a UIActionSheet is probably best.
What I'd like to have is a pop up window (in my head I picture it as being translucent and dark gray). It will not take up the whole screen and the view underneath will still be visible.
In the pop up section there will be a textfield (with several lines) and underneath this there will be a number of UISwitches.
The pop up will be scrollable and will end with OK/Cancel buttons at the bottom.
Like I said, I really have no idea where to start with this but any advice is more than welcome!
A UIActionSheet is probably not what you are after in this case (although you may want a similar look and feel). Think of an action sheet as a traditional modal OK/cancel/Yes/No type dialog box:
Use the UIActionSheet class to present the user with a set of alternatives for how to proceed with a given task.
From the sound it of it, you need to create a UIView in InterfaceBuilder with a semi-transparent background and various child controls (UISwitches and UITextFields). You create your view using the XIB you have configured and add it as a subview of your UIViewController's view. If you want to mimic the animation you get from an action sheet, you can do that with an AnimationBlock.
Im working on a small app that displays contact and biography details.
You can see two screenshot here: contactDetails, biogDetails.
At the moment I have an Action button on the right hand side of the NavigationBar that displays an ActionSheet where the user can perform various actions like:
"add to favorites"
"update data",
"Biog Details", etc.
I feel the "Biog Details" is not an action as the others and I would like to display it on a different way.
I was wondering if there is a way to add an extra custom button to the PersonViewController.
I dont really want to create a lookalike of the PersonViewController, because i would lose functionality that I can replicate with the public APIs.
The other option could maybe be to have a segmentedController on the center of the NavigationBar that would switch between the two viewsControllers. How could I do that?
Im open to ideas.
Thanks,
The only way you'll be able to add that extra button is if you use the UIToolBar instead of the UINavigationBar.
If you decide to use the UISegmentedControl you'll also have to use the UIToolBar.
You can duplicate the UISegmentedControl on both views but with the appropriately selected segment on either.
Or you could use one "base" view, add the other two as subviews and hide/unhide the appropriate view depending on the segment that is selected. This would however mean that you change the position of the subviews (by adjusting their rect parameters) so that they appear just below the UIToolBar
Is there a way to specify the size of a UIAlert button?
Is there a way to specify the layout of buttons on UIAlert? Like having three buttons next to each other and a cancel button on the buttom?
Is there a way to specify the size of a UIAlert button?
No easy way. The buttons must fill the whole dialog horizontally unless you heavily override its internal -layout method, or mess with the frames of the UIAlert's subview after it's shown.
Is there a way to specify the layout of buttons on UIAlert? Like having three buttons next to each other and a cancel button on the buttom?
There used to be an int numberOfRows property to specify how the buttons distribute, but this is now ignored for UIAlertView.
You can add a subview with any buttons you'd like to the UIAlertView and grow its height to match. It is difficult to get it to lay out properly if you use any standard alert buttons, titles, or messages.
In a UIAlertView I need to align buttons into rows so that there are either 2 in each row or 3 in each row. This is for an appstore app so I need to use documented methods. So obviously I can't use setNumberOfRows: for this. Suggestions on how I could achieve the same effect?
You can't customize UIAlert to any meaningful extent.
In any case, it sounds like you don't want an alert view but rather sheet or a modal view.
UIAlert is restricted for a reason. It's supposed to present a simple, standardized (and easy to call) view to draw the users attention to a specific issue. You don't want to use it for complex choices.
If you create your own view and present it modally. It will popup above the other views just like an alert but you will be able to customize its appearance and behavior as you wish.