iphone - display pickerview along with action sheet -
i have textfield. once tap on want uipickerview
pop out , select item uipickerview
, after once done selection want confirm selection tapping on uiactionsheet
has confirm button on it.so requirement have uiactionsheet
, beneath picker view. beginner in ios development , still not familiar technical terminologies. please bear informal way of asking questions.
here block of code:
creating uipickerview , uiactionsheet
uiactionsheet *confirmroomselectionas =[[uiactionsheet alloc]initwithtitle:@"" delegate:self cancelbuttontitle:@"cancel" destructivebuttontitle:nil otherbuttontitles:@"done",nil]; uipickerview *roomtypepicker=[[uipickerview alloc]init]; [confirmroomselectionas addsubview:roomtypepicker]; [confirmroomselectionas showinview:self.view]; [confirmroomselectionas setbounds:cgrectmake(0, 0, 320, 600)]; [roomtypepicker setframe:cgrectmake(0, 170, 320, 216)]; [roomtypepicker setdatasource:self]; [roomtypepicker setdelegate: self]; roomtypepicker.showsselectionindicator = yes;
try this,
uiactionsheet *actionsheet = [[uiactionsheet alloc] initwithtitle:nil delegate:self cancelbuttontitle:nil destructivebuttontitle:nil otherbuttontitles:nil]; [actionsheet setactionsheetstyle:uiactionsheetstyleblacktranslucent]; [actionsheet showinview:[self.view window]]; [actionsheet setbounds:cgrectmake(0, 0, 320, 390)]; [actionsheet addsubview:[self createtoolbar:@"test"]]; uipickerview *picker = [[uipickerview alloc] init]; picker.frame = cgrectmake(0, 44, 320, 162); picker.showsselectionindicator = yes; picker.datasource = self; picker.delegate = self; [actionsheet addsubview:picker]; - (uiview *)createtoolbar:(nsstring *)titlestring { uitoolbar *inputaccessoryview = [[uitoolbar alloc] init]; inputaccessoryview.barstyle = uibarstyleblackopaque; inputaccessoryview.autoresizingmask = uiviewautoresizingflexibleheight; [inputaccessoryview sizetofit]; cgrect frame = inputaccessoryview.frame; frame.size.height = 44.0f; inputaccessoryview.frame = frame; uibarbuttonitem *donebtn =[[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemdone target:self action:@selector(done:)]; uibarbuttonitem *flexiblespaceleft = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil]; uibarbuttonitem *cancelbtn =[[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemcancel target:self action:@selector(cancel:)]; uilabel *titlelabel = [[uilabel alloc] initwithframe:cgrectmake(0 , 11.0f, 100, 21.0f)]; [titlelabel setfont:[uifont fontwithname:@"helvetica" size:14]]; [titlelabel setbackgroundcolor:[uicolor clearcolor]]; [titlelabel settextcolor:[uicolor whitecolor]]; [titlelabel settext:titlestring]; [titlelabel settextalignment:uitextalignmentcenter]; uibarbuttonitem *title = [[uibarbuttonitem alloc] initwithcustomview:titlelabel]; nsmutablearray *array = [nsmutablearray arraywithobjects:cancelbtn,flexiblespaceleft,title,flexiblespaceleft, donebtn, nil]; [inputaccessoryview setitems:array]; [donebtn release]; [title release]; [titlelabel release]; [flexiblespaceleft release]; [cancelbtn release]; return [inputaccessoryview autorelease]; } - (void)done:(id)sender { } - (void)cancel:(id)sender { }
it like,
Comments
Post a Comment