Checkable UIPickerView in iPhone Safari -
i try custom pickerview checkable when click dropdownlist on webview in picture (youtube website).
http://img830.imageshack.us/img830/3747/screenshot20101004at606.png
i use viewforrow method customize view each row in picker.
- (uiview *)pickerview:(uipickerview *)pickerview viewforrow:(nsinteger)row forcomponent:(nsinteger)component reusingview:(uiview *)view { uiview *rowview = [[[uiview alloc] initwithframe:cgrectmake(0, 0, 280, 44)] autorelease]; rowview.backgroundcolor = [uicolor clearcolor]; rowview.userinteractionenabled = no; uiimageview *checkmarkimageview = [[uiimageview alloc] initwithframe:cgrectmake(5, 10, 24, 19)]; uifont *font = [ uifont boldsystemfontofsize:18]; uilabel *titlelabel = [[uilabel alloc] initwithframe:cgrectmake(35, 0, 240, 44) ]; nsstring *pickertext = [[itemlist objectatindex:row] objectforkey:@"name"]; titlelabel.text = pickertext; titlelabel.textalignment = uitextalignmentleft; titlelabel.backgroundcolor = [uicolor clearcolor]; titlelabel.font = font; titlelabel.opaque = no; if ([selected_property_id intvalue] == row) { titlelabel.textcolor = [uicolor bluecolor]; checkmarkimageview.image = [uiimage imagenamed:@"checkmark.png"]; }else { titlelabel.textcolor = [uicolor blackcolor]; checkmarkimageview.image = nil; } [rowview addsubview:checkmarkimageview]; [rowview addsubview:titlelabel]; [titlelabel release]; [checkmarkimageview release]; return rowview; } - (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { [m_pickerview reloadallcomponents]; }
when select row want, add checkmark selected row when scroll picker up/down picker auto select row @ middle of picker. so, auto add checkmark in middle row.
my question how disable auto select on middle row. should add checkmark when user tab on row want (like in youtube).
should use touch event method pickerview?
thanks help.
yes, should use touch events. however, standard uipickerview captures touches , won't forward them, viewcontroller never receives events.
i've created project on github uipickerview subclass allow touches escape it. forwards them superview , handles selection in viewcontroller's touchesended method. implements mentioned checkmark.
Comments
Post a Comment