UIAlert button size - iphone

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.

Related

How to add two custom rightBarButtonItems without a margin between them?

I create UIToolbar with interface builder and want to add two custom right buttons, but without a space between them. I don't want solution to reset a margin from the right edge, because I found it here but want only reset margin between buttons.
How should I do this?
Thanks.
Instead of a button, use an UISegmentedControl and set its momentary property to yes.
Add one segment for each button you want (in this case two segments)
Then add an IBAction and use a switch to know what index has been selected.
Index 0 first button, index 1 second button.
Create a bar button item with a custom view where that custom view has 2 UIButtons as subviews. In this way you can exactly size and position the buttons as you require.
To adjust space between UIBarButtonItem's you can use a UIBarButtonItem with style UIBarButtonSystemItemFixedSpace and setting its width property.
You can move items closer to eachother than the default spacing by setting the width of the spacer item to be a negative value.
One thing to consider is future-proofing whichever solution you choose. Buttons in iOS6 have nice borders and shading. They may not in the near future...

Change UIAlertView button layout

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.

How to change UIActionSheet view?

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.

iPhone UIActionSheet with UISwitch and UITextField

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.

Add extra button to ABPersonViewController

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