iPhone - adjusting the size of a UIActionSheet - iphone

I need to present a UIActionSheet that will show 10 buttons. When I do that on iPad, the UIActionSheet shows on a popover that is very long vertically (not aesthetically pretty). Is that possible to specify the UIActionSheet size to a maximum size?
I have tried this
myActionSheet.frame = CGRectMake(0,0,300,300);
myActionSheet.bounds = CGRectMake(0,0,300,300);
and have also tried to put these lines inside
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
without success.
any clues?
thanks

I think this is one of the cases where you can't really use a built-in class like the UIActionSheet to accomplish your goal. I don't think it is designed to be used for cases where you have as many buttons as 10. It just doesn't scale very well, just as you have discovered.
But let's pretend that it would be possible to change the size. What should happen when you change the size? There is a minimum size for each button for it to be tapable. And you also need some space between the buttons as to not cause a misstap. So even if you could change the size it couldn't be reduced by very much. And since it's not intended to be able to change the size you would have to try and access all the buttons and resize and move them as well. One could argue that perhaps the buttons could be placed in columns but since that is not implemented it would still not help if you made the UIActionSheet any wider.
I would recommend that you either:
Create your own custom view with all 10 buttons placed just as you liked.
Use a table view to present the options. Since the table view can be scrolled you can get the size you like.
If you set modalInPopover to YES on the UIViewController you present in the popover the user must make a choice before she can move on.

try with `- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated
because in apple documentation they said:
"On iPad, this method displays the action sheet in a popover whose arrow points to the specified rectangle of the view. The popover does not overlap the specified rectangle."
`

Related

How to implement UIPopover kind of functionality in iPhone?

In my app i have a PieChart which has certain divisions denoting different areas or region. Every partition has its own color but there are like 10 partitions and i want to show which part shows which region. It would have been an easy task with iPad as we have UIPopover but here in iPhone i don't know what to do, so i thought if there is any suggestion any one can make. I want to PieChart be visible with the detail about each partition.
Thanks,
You need to make a UIview with tableview and imageview inside it .
You can make your own custom Popover type control by making a UIView then adding the desired elements to it and making it as a subview or keeping this view hidden from the start then making it visible on button press.
Here you will find many popover controllers http://cocoacontrols.com/search?q=popover

iPhone keyboard on UiPopOverController (iPad)

i would to know if there is a way to show(call) an iphone-uikeybord-like inside a UIPopOverController. I've an ipad app with several functions, in one of these there is a button that show a popoover, inside the popover there are a uitableviewcontroller and a search controller for search functions inside the table; search stuff is numeric only and i want show a keyboard(like numberpad in iphone) inside the popover instead show the maxi ipad keyboard.
Thanks in advance.
Sure you can do that - but you'll have to build a custom keyboard.
I did exactly the same thing to create a numeric keypad after playing around trying to use a different UIControl for the text field input without much success.
My solution was specific to our app because we also wanted - and + keys to adjust the value without by tapping, but what I ended up doing was:
extend UITextField
add - and + buttons next to it
add a transparent button on top of the numeric field
trigger UIPopOverController when the transparent button was tapped
the popover loaded a NumericKeypad with it's own view
Although I usually try to use IB as much as possible in this case all buttons and target assignments were done in code (for easy of calculating relative positions in code)
The creation of the keyboard itself is really easy - it's just a bunch of buttons. You can either build in IB or programmatically - quite simple either way.

How to change the width of UIActionSheet in iPad?

I want to change the width of UIActionSheet in iPad, and I tried to set a new frame size for the UIActionSheet, but nothing changed.
Any idea ?
Thanks.
I believe that is not accomplished with the built in onw, you need to create your own custom view.
Create your own custom view with all 10 buttons placed just as you liked.
Use a table view to present the options. Since the table view can be scrolled you can get the size you like.
Reference: adjusting the size of a UIActionSheet

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.

How do I create a combobox type control on the iphone?

All I see is a list (which looks like a rolodex), how do I make this like the combo box option?
I haven't tried this, so I can't say that it will 100% work, but ths is what I would attempt to do:
Extend UIPickerView and initially give it only enough height for one row
In the new class, intercept touchesBegan: so that if the control is in the 1 row mode it will first expand to the full height (using an animation of course). I would probably NOT pass touches on to the super class in this mode
If the control is already in the full height mode, let the touch pass on through to the super class.
Add some other communication with other components on the screen so that when the user touches them, the extended UIPickerView shrinks back to it's 1 line height form, with more animation.
To make all of that work you probably need all your controls in a scroll view that does proper auto layout so that as you change the frame size of the UIPickerView thingie the other controls move around appropriately.
I agree with Henrik that this is very non-Apple however. It seems the prescribed Apple implementation would involve a tableview cell with a disclosure button that takes you to another screen containing the picker. I know the Apple HUI guidelines don't cover all cases, but it seems they probably cover this one.