Button to choose among three images - iphone

What is the best/easiest way to choose an image among three with a button.
It will be a button ( or a label, or anything about 40x40) that you click to choose an image. I know normally you use a custom picker, but its only for three images, maybe there is a simpler way. ( a tableview?)
the image will be about 50x50 p on the view.
Could someone give the piece of code for it please?
thanks a lot

Have you looked at UISegmentedControl? You could either use that directly or perhaps present it modally from a button if the space is limited.

Related

iOS: Search Options UI

I am building an iPhone app for a library and I want to give few options to the user to search books by. A user can search a book by title, author, topics, or date of publication.
What I want to know what's the best way to display these search options to the user? In terms of HTML, it would be easy - either use a drop down list or radio buttons. I tried using UIPickerView but honestly, that looks terribly ugly and destroys the aesthetics of the view of my app.
The other option I was thnking was using segmented control, but is it possible to have a vertical segment control in stead of horizontal one? The selection texts can be too long.
Any ideas?
If you want a vertical segmented control, you'll have to make it yourself. Create a textured image with dividers. I would export each section as a PNG separately. Then create a picture of each section with the "pressed down" gradient and export each segment as a separate PNG again.
I would then make a new class. If there is a specific number of objects in your segmented control or this is a one time thing, the class may not even be necessary. If not, then in the class constructor pass an array with the titles of the segments in your segmented control. For the first and last objects, use the pictures you made with rounded corners. For the objects in between, use the standard pictures. Then put the titles on top. When a segment is tapped (perhaps use hidden UIButtons), you can use a delegate method to tell the main search class which one was tapped, and then the class can replace the normal picture of that segment with the pressed down one.
Thanks for the options.
I ended up creating a simple table to show my choices.
User clicks on "search by", which opens up the table with options and then when you select any option, you return back to main view with the chosen search option.

XCode 4 Interface Builder: A better way to work with lots of overlapping views

In IB I have quite a few views that are shown. Many of them are hidden when the app loads, but are shown later when buttons are pressed. This is all fine, but when building this layout in IB it is extremely difficult to layout anything because there are so many overlapping views, some of which are partially transparent (ones that are set to hidden) and other are completely overlapping and covering others. This makes layout very hard.
What is the best method when laying out lots of views like this? Is there another way to break things up? Or better yet, can I hide a a view completely (like in photoshop) so that I can edit the ones underneath, then turn that layer back on?
Another option when trying to select a view that is obscured by another is the shortcut:
'ctrl' + 'shift' and click
It displays a list of all the views under the cursor.
I'm not aware of any way to hide objects in the canvas, but a useful trick for complex layouts is to double-click an item in the document tree to the left - this selects the item and puts focus on the canvas, you can the use the cursor keys to nudge it about.
This doesnt solve the problem of not being able to see things because there are, for example, five or six labels occupying the same space, but if that is the situation it may be a better idea to have a single label and change its contents in code.
I ran into this issue for an app I'm building that has an arial-view image of a park with clickable hotspots. When a hotspot is clicked a popup UIview is displayed with information about that spot in the park. I use the same VC/XIB for three parks. This makes the XIB really busy and hard to work with (i.e the same issue that you have) The detail UIViews make it hard to work with the views underneath. My workaround was to pick each detailed UIView that was hiding the part of the XIB I wanted to work on, and add 1000 to the UIView origin.x in the size inspector. This moved those UIViews enough out of the way for me to do what I needed to with the XIB. Then when I was done, I moved them back by x 1000. (I just needed to move them out horizontally to do what I needed to)
I know its clunky but given that XCode does not have a convenient way to hide portions of an XIB - it was the quickest approach I could think of!
One approach to handling overlapping items in IB is:
Ensure the groups of items that you want to hide are grouped into Views.
Give these Views names: e.g. ViewOptionA, ViewOptionB and ViewOptionC.
Can do this by clicking on name of view in the tree while it is selected and then typing new name.
When you want to hide one of those groups of items:
a) Select the View by either:
i) Clicking on it in the tree at the left or
ii) Ctrl-Shift Clicking in the layout editor and then select the view from the list.
b) In the Attributes Inspector set Alpha to 0.
When you want to unhide one of those groups of items:
As for 2) but set Alpha back to 1
[You do need to remember to unhide all views before you publish!
If you are forgetful like me then perhaps you could subclass UIView and set Alpha to 1. I haven't tried this subclassing idea yet.]

Sliding UITabBarItems in UITabBarController

I have a UITabBarController as my rootController with 8 UITabBarItems. and I want to show just 4 UITabBarItems in my screen. By default all my other tab bar items appear in a small tabBarItem called "More" and you can select the other 4. But I have seen some apps that implement a sliding UITabBarItems with a slide icon instead of a "More" icon.
How can I show just 4 at a moment, and I slide the TabBarItems, and so that I can select the other tab bar items ?
~ Something like this ~
And then I can slide to the next 4 sets by dragging
It would be helpful if someone could point me in the right direction.
There is a nifty little github project that could help you... check it out: https://github.com/iosdeveloper/InfiniTabBar
This is not currently a built-in option for UITabBarContoller.
One way to approach the problem is to add a UIGestureRecognizer to the tabBar.view, and programmatically adjust which 4 options are available on the screen. You can add an animation to make it smooth or have a little bounce as it slides.
iPhone users are usually very picky and attached to Apple's UI Guidelines. Although you can pass the Apple verification, you probably wont be able to pass users' (meaning bad reviews and ratings). So I recommend you to re-consider your tabbar structure and use "..." More instead of sliding it... You can always override stuff in code, but then they wont work smooth with InterfaceBuilder and in the end you will have more trouble than you'd expect.
If you have similar tab items merge them and use maybe a segmented control or something to visually distinguish them. Or use a central navigation screen in which you can put 9 maybe more icons in a grid...
The first solution to your problem may not always be the best way. Well, it is very rare actually...
You have to write a custom control for this.
I wrote one for showing a horizontal menu. You can probably modify that to fit your needs.
http://blog.mugunthkumar.com/coding/ios-control-mkhorizmenu/

Tab Like Selection

Can anybody please tell me how they have implemented the below thing whick looks to me like a TabBar but has something different from a simple tabbar.
The thing having "Offer" and "Wall", when each one is clicked, presents a different view.
Any sample code will be appreciated
Its a custom UIButton.
EDIT: What UI element might this be? (Custom tab-bar?). I had asked the same question a few weeks ago. There are two good answers there.
And google up for custom UIButton. You can find a few samples on your search
Its a custom view. You can always implement this kind of thing by using images. Say you have 2 different images. In one image offer is selected, and in another wall is selected. And you are using an image view to show them. An invisible button is placed in proper place. After tapping the button you can set the right image. And also if the images are not overlapping then you can use custom button.

selection Menu like Tap Tap Revenge 3

I am wondering how to achieve selection menu like tap tap revenge 3 have.Do I need to make a whole custom class or any help which class should I drive my subclass.I tried to modify UIPickerView but I cant change background image and frame(both is private).
Thanks
Mrigank Gupta
Here is the link of image(not having reputation to post image)
http://www.freeimagehosting.net/uploads/345aed3aee.jpg
Making a custom control class will be easier than trying to shoehorn one of the existing ones.
Tapbots put together a little article on their work.
http://tapbots.com/blog/design/designing-convertbot
You should be able to use a few images, a button, graphics transforms and touch event handling to pull it off.