tags:

views:

596

answers:

3

How does one code this scenerio in iphone sdk?

In an expense app, when you want to add an expense, this view comes up.

alt text

After selecting "Clothing," another view slides up with a UIPickerView control that has a "done" button which will dismiss the UIPickerView. Below is a screen shot after hitting "Clothing."

alt text

I'm trying to figure out how one would slide up the UIPickerView half way up the screen with a "done" button on top of the "New Expense" view?

thank you in advance!

A: 

Hi

You implement the UIPickerDelegate, then implement the methods that belongs to the UIPickerView.

So your interface file must contain this:

@interface YourViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> {

Your viewController them implements these, or more, methods:

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;

t´You would then instantiate the picker, set its delegate and all other properties you need it to conform to.

You could then hook up a "listener" for keeping track on when it changed.

[datePicker addTarget:self action:@selector(didChangeDate) forControlEvents:UIControlEventValueChanged];

A good place to start is the UICatalog example from the Apple developer site. This has a lot of Picker code and a bunch of other stuff that could help getting in the mindset Apple uses for building stuff with UIElements.

Hope it helps:) it is a large subject.

RickiG
thx for answering. I understand using UIPickerView. My question was how I can animate or slide up a view that contains the UIPickerView and toolbar halfway up the screen on top of another view.
Joo Park
+3  A: 

Use CoreAnimation and make the UIView with move from bottom to top.. and change the hidden property to true from false when required and vice versa..

Multiple UIViews can be nested as required take advantage of this to achieve what u need

Quakeboy
A: 

This post helped me; might help others: http://sdhillon.com/animated-uipickerview

petert