How to create an Custom picker?? Or - iphone

I need to create an app that contains something like this image:
When the user changes the label it should change an image above..
There is more option after the number "24", like a picker.
I have the idea to implement an picker in horizontal mode, but I don t now how to change the design of it to be like the image (without the effect well).
Any one have an idea how to do that, or something that works like this???
Thanks

use UIScrollView

You can't alter a UIPickerView object much so you should consider a rotated UITableView object. More than subclass, you will need to build a composite view that basically mirrors some of the methods of the UITableView object. And you will have to add appropriate methods that handle the selected value.

Related

xcode 4 - Date picker

is there a way to have the date picker smaller or with different size?
I have been trying to make it small programatically but it seems like there is no luck.
any help?
no you cannot
if you want you may customize your own date picker using pickerview
Date picker is not customizable.
If you have lots of time you could create your own UIView object (with your custom background) with one (or more, better if configurable) UITableView scrolling-paged inside (and other object, like the light blue indicator) and show this UIView inside a UIActionSheet (you will get animation in/out for free).
It's not a easy solution, but it is.
If you'll create this component, any code released open source is really appreciated.

iOS Creating a list of tags

I'm currently trying to implement a feature in my app that shows tags for a post. I want it to work very similar to that of tags here on StackOverflow, in that they have a colored background.
Another example, are the Inline Labels here.
I'm just not quite sure on how to get it implemented. My first guess would to create an array of UILabels... Any suggestions?
Figure out what you want the tags to look like. If you can achieve that appearance with existing components like labels or tokens, then great, problem solved. If not, creating your own UIView subclass that draws a background and bit of text is pretty simple -- you wouldn't need to write much more code than a custom -drawRect: method, and even that should be easy. For example, if you wanted something that looks like the Twitter-ish inline labels, you could start with a resizable image and then draw your text on top.
Don't be afraid to create your own view classes... it's fun!
You probably need to write two classes.
The first (let's call it HorizontalLayoutView) will extend UIView. It will serve as the container view to hold all of the tags. It would override the layoutSubviews method to arrange the subviews by setting their frames. Create one instance of this and add it as a subview to your existing view.
The other (let's call that TagView) will also extend UIView, or perhaps UILabel. Instances of this class will represent each tag. Create one instance for each tag and add it as a subview to your horizontalLayoutView instance. In the initWithFrame: method, you would customize the tag to look the way you want. You can also override the drawRect: method to further customize its look.
If you are adding the tags dynamically after the view is already displayed, you may need to call setNeedsLayout on the horizontalLayoutView instance to get it to adjust properly.
Hope this will get you started in the right direction.

Can you mix custom-view and non-custom view components in a single UIPickerView?

I have a multi-component UIPickerView in my application. Two components are plain and completely served by the pickerView:titleForRow:forComponent: method. My third component however requires a custom view via the pickerView:viewForRow:forComponent:reusingView: method. I don't see any way in the documentation to have a "partially customized" UIPickerView where some components use ...titleForRow... and some use ...viewForRow.... Is this possible? If so, how does one do that?
You've got to go all or nothing. The plain, boring default views are pretty much just a UILabel. You should be able to easily recreate this view.

can i add an ivar (or property) to an existing class in objective-c?

I'm wondering if it's possible to add an ivar to the UIButton class? A bit like categories but not for a method(s) but for ivars.
I am programmatically creating and displaying an array of UIButton's which I then all link up to a single action method using –addTarget:action:forControlEvents: for a touchup event.
Now, my receiver method needs to know which of all the buttons was pressed but using the "(id)sender" approach doesn't cut it because the only thing differentiating all the buttons is the image its displaying and there is no way to get to that (I need a string). The buttons are all in different places so I could do some math to convert the position data into an "id" but if I change the positioning of the buttons down the line, I will need to change the math as well and I don't like that.
Can I just subclass UIButton and change nothing except for adding a (NSUInteger)idCode property? Then when I create the buttons I set the idCode, and when the target-action mechanism fires the action method, I can just do sender.idCode. Is this the way to do it?
Is there a better standard/elegant way of implementing this kind of multiple target-action see-where-it-came-from behaviour?
P.S.: Is there a quick way to type the backtick on a Mac?
You could do it this way. But this is not necessary - every UIView (and subclasses which includes UIButton) has the tag property which is just what you want.
UIButton as well as all UIView subclasses already has an integer property for exactly that purpose: tag

Three20 TTSectionedDataSource row height

I'm using Three20 to create a table with several textfields for user registration. I've found two possible methods using Three20. The first uses the TTSectionedDataSource's tableDidLoadModel method to manually add UI components and the second adds custom items that contains pre formatted UI components. The second option seems way more complex and I'm having a difficult time accessing the individual fields. So if one field is a textfield for the username, I need to access the field to submit the username and it doesn't seem like there's an easy answer. The first option gives me a lot of flexibility, but I can't figure out how to set the individual row heights. One row may have a label above a text field, another may have an image, etc. Is there a method that can be used in TTSectionedDataSource that will allow me to set the height for each row? Thus far, I'm using method one and creating UIViews to hold a label field and a text field. I've tried changing the frame of the uiview before it is added to the items array, but it has no affect.
Any ideas?
I believe I may have figured it out. Not sure if this is the correct solution, but it seems to be working.
First in my custom item class I pass the datasource as a delegate. Now that the delegate is part of the item, I can pass it to my textfield as the delegate. As long as I include UITextFieldDelegate in my data source class, it will respond as the delegate to my textfield. So that's getting the content from the textfield.
If I want to change the content in a textfield from the datasource, I can leverage the method:
- (void)tableView:(UITableView*)tableView cell:(UITableViewCell*)cell willAppearAtIndexPath:(NSIndexPath*)indexPath
I can check the row using indexPath.row then type the cell as the corresponding custom cell class. From there I can access any public methods in my cell class. So I created one that returns a reference to the textfield. So I can say:
[[(MyCustomTextFieldCell *)cell theTextField] setText:#"hello world"];
Next step is to assign it to a local ivar and then I'm assuming I should be able to access it at any time.
The main reason I want to be able to modify the content of the textfield is that in certain instances by clicking on the textfield, a picker will come up and the results of the picker are formatted and inserted back into the textfield.
Please let me know if my approach is too convoluted. Perhaps I'll create a sample and post it for everyone to rip apart and tell me I'm a moron and there's a better way.
thanks,
howie