How to put images in action sheet button? - iphone

I have created an action sheet which contains more than one button, and I want to put different images on different buttons, how can I do that?

You can't, the "buttons" (actually a special class called a three part button, IIRC) in UIActionSheet are not directly accessible and you can't subclass it either. However it is pretty easy to write your own, see http://blog.corywiles.com/custom-uiactionsheet-using-core-animation for an example or inspiration. It's only a view with some buttons as subviews, and a bit of code to handle sliding it up from the bottom of the screen.

Related

Can I put my buttons into a separate view?

I am saving a picture of my base UIView via UIImageWriteToSavedPhotosAlbum.
I have not created a separate UIImageview, everything is in the same base view, including my buttons, therefore when I save the picture, it includes my buttons too.
Is there any way I can put the buttons in a separate view, so that they are still visible in the app, but do not appear in the picture that I save via UIImageWriteToSavedPhotosAlbum?
Have you tried hiding the buttons with .isHidden just before you call UIImageWriteToSavedPhotosAlbum? Then re-enable them afterwards.
Alternatively you'd have to put the buttons on a separate view that's not part of the one you're saving.

Differentiate between multiple UIButtons with empty titles

I have a bunch of UIButtons (10-15 of them) in one of my Views. I want to display them as an image without the title text, so what I did was set the image for the Button through the storyboard, and then set an empty title for the button.
I want to react differently when each button is pressed. There are a couple of solutions that I can think of off the top of my head, and I'm wondering which would make the most sense, software engineering-wise:
Each button is connected to a different IBAction (too many methods added)
Each button is connected to a different IBOutlet (how to differentiate between the buttons, still? Use ===?)
Single IBAction, unique tags for each button (this is what I'm doing for now as it's simplest and it works, but aren't tags a bit hacky?)
Give each button a different title, but find a way to hide the titles, and then connect them all to an [UIView] outlet array (is it possible to hide the titles from the storyboard, or must I do it programmatically from the View Controller?)
Some solutions you thought of are viable, some others aren't (connecting #IBOutlets and trying use the equal operator, or hiding the button's title).
I would recommend you to simply keep using UIButton tags (as that's what tags are there for) and use a single entry-point #IBAction. You will then be able to identify each button by their tag.
Subclassing your buttons might seem a bit overkill if you're only trying to identify them...

Can my custom tabbar be created like so for iPhone?

I have designed a custom tabbar and the developer says the design I created can't be done.
The screen is made up of a usual background with a tabbar. I'd like my tabbar to look a little different to the usual iPhone style. I would like at the bottom of the tabbar a grass illustration (transparent) and on top would sit all the separate buttons and on top of those would be the icons. All of these images (as seen in link below) are separate .png files.
When the user scrolls the content, it will scroll under the transparent grass. The buttons of course will be clickable and have a different view for an active state.
Please see the link below to see a mock-up of the image:
http://www.stuartkidd.com/dummy.jpg
I'd appreciate if the community could explain to me if this could be done and if so, how. I thought it would have something to do with 'creating a custom tabbar'.
And a further question, if it can be done, can also the tab buttons be horizontally
scrollable with a swipe action?
Thanks,
It all can be done but you are going against the Iphone UI guidelines. You won't be able to leverage the UITabbarView to do what you want so you'll basically have to write the whole thing from scratch. Your tab bar would be a scroll view with a row of buttons representing each tab. When a button is clicked you load in the appropriate view. The UITabBar controller gives you a lot of functionality for free and I suspect once you start working towards this you'll see exactly how much extra work this will end up costing you. Going against the way Apple does things can be a slippery slope.
Another idea might be to keep a hidden UITabBar to manage the tabs and call it from your custom tab bar. This would free you from a lot of the hassle of swapping views/controllers in and out.
You can create a row of custom buttons and have 2 subviews. One for the bottom navigation bar and one for the content view where you will be swapping your content based on what is pressed.
You can have a state which maintains what was clicked. Based on that you can set the button enabled state for every button in your bottom bar.
button.selected = YES
It will be easy to handle the touch up inside events and properly load appropriate views in and out of the bigger subview as they will be part of the same view controller.
I have implemented a similar functionality and it works well but still in process of submitting it to the app-store.

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 to implement this UI

Just curious if the tab bar UI element in screenshots is some built in class or customized.
If it is customized, then please give me a hint on what classes I might check to have something like that.
The first screenshot is initial tab bar. When I tap on the last icon the tab bar smoothly(animated) resize itself as on second screenshot. If I press the edit button the icons are shaking(as on iPhone home) and I'm able to arrange them.
first
tab bar http://img686.imageshack.us/img686/3899/photo2aw.jpg
second
more buttons http://img38.imageshack.us/img38/5673/photo3kq.jpg
The tabbar in the top image could just be a standard tabbar with a non-standard color scheme.
The bottom image is a custom element most likely implemented in an UIActionSheet.
Gotta say, this is a butt ugly UI using non-standard (and therefore confusing) elements. I wouldn't suggest trying to emulate it.
Looks like it's custom. You might just want to look at subclassing UIView and putting a bunch of buttons it stored in a NSArray. That way, when you re-arange them, you just have to move the objects to a new position in the array.
You should be able to achieve the shaking by using simple UIView animations.