i new both objective-c , xcode. trying implement simple uipickerview + toolbar setup shows when user taps on label element on right , when user selects option pickerview, label element gets replaced value of selected option.
currently have uipickerview , toolbar inside uiview element. have got slide , down animation uiview work. problem having issue positioning of animation. please see screenshot:

when click 'cancel' or 'done' buttons on toolbar above uipickerview, hides whole uiview correctly when click 'show' button bring uiview up, doesn't reposition high enough whole uiview visible. know why happening?
when force uiview re-position higher setting animation y axis value 144 instead of 244, looks this:

it seems height of uipickerview being changed during animation. how fix this?
here code .h , .m files:
.h
#import <uikit/uikit.h> @interface newinvoiceviewcontroller : uiviewcontroller <uipickerviewdelegate, uipickerviewdatasource> { nsarray *storedclients; nsstring *selectedclient; } - (ibaction)cancel:(id)sender; - (ibaction)clientselectcancel:(id)sender; - (ibaction)clientselectdone:(id)sender; - (ibaction)clientpickershowbtn:(id)sender; @property (strong, nonatomic) iboutlet uipickerview *clientpicker; @property (strong, nonatomic) iboutlet uilabel *clientlabel; @property (strong, nonatomic) iboutlet uiview *clientpickerviewcontainer; @end .m
#import "newinvoiceviewcontroller.h" @interface newinvoiceviewcontroller () @end @implementation newinvoiceviewcontroller @synthesize clientlabel, clientpicker, clientpickerviewcontainer; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. storedclients = [nsarray arraywithobjects:@"joe smith",@"john doe",@"bob johnson",@"joel smith", nil]; clientpickerviewcontainer.frame = cgrectmake(0, 522, 320, 261); } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (ibaction)cancel:(id)sender{ [self.navigationcontroller dismissviewcontrolleranimated:yes completion:nil]; } - (ibaction)clientselectcancel:(id)sender { [uiview beginanimations:nil context:null]; [uiview setanimationduration:0.5]; [uiview setanimationcurve: uiviewanimationcurveeaseinout]; clientpickerviewcontainer.frame = cgrectmake(0, 520, 320, 260); [uiview commitanimations]; } - (ibaction)clientselectdone:(id)sender { [uiview beginanimations:nil context:null]; [uiview setanimationduration:0.5]; [uiview setanimationcurve: uiviewanimationcurveeaseinout]; clientpickerviewcontainer.frame = cgrectmake(0, 520, 320, 260); [uiview commitanimations]; } - (ibaction)clientpickershowbtn:(id)sender { [uiview beginanimations:nil context:null]; [uiview setanimationduration:0.5]; [uiview setanimationcurve: uiviewanimationcurveeaseinout]; clientpickerviewcontainer.frame = cgrectmake(0, 244, 320, 260); [uiview commitanimations]; } // returns number of 'columns' display. - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview { return 1; } // returns # of rows in each component.. - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component { return [storedclients count]; } -(nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { return [storedclients objectatindex:row]; } -(void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { selectedclient = [storedclients objectatindex:row]; } @end screenshot of xcode storyboard: http://i.imgur.com/j8q6t9n.png have selected uiview position , dimension values visible.
tutorial used: http://i-software-developers.com/2012/05/27/xcode-4-2-show-and-hide-pickerview/
is best way implement setup this? have seen other examples using called actionsheet, better use that?
actionsheet example: http://pastebin.com/5mc9jjc0
all or advice appreciated!
thanks
try use animation syntax blocks, way better old way using
it's not practice hard-code values of frame want animate. instead, try relative frame something, parent's frame.
use show picker:
[uiview animatewithduration:.5 animations:^{ cgrect newframe = clientpickerviewcontainer.frame; newframe.origin.y = self.view.frame.size.height - newframe.size.height; clientpickerviewcontainer.frame = newframe; } completion:nil]; to hide it, change line newframe.origin.y = self.view.frame.size.height - newframe.size.height; newframe.origin.y = self.view.frame.size.height;.
this way work if change values of frame inside interface builder, or if using 3.5 or 4 inch display.
i don't know if problem this, it's worth point out.