iphone - how can I put particular action as I select any row of UIPickerView? -
i writing code
- (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { int n=row+1; if(row == 0) return [nsstring stringwithformat:@"%d minute", n]; return [nsstring stringwithformat:@"%d minutes", n]; }
now want start timer choose row, row 5 has 5 mints, want start timer 5 mints, should do, how can choose particular row , press button , timer starts event?
for future if go onto google , type in name of class , "class reference" can find information need on apple website.
for instance, went onto google , typed "uipickerview class reference" , got here: http://developer.apple.com/library/ios/#documentation/uikit/reference/uipickerview_class/reference/uipickerview.html.
on website if read description says "the delegate must adopt uipickerviewdelegate protocol" , if click there says, under tasks:
responding row selection –
pickerview:didselectrow:incomponent:
this delegate method need implement called when user selects row. if click on it gives little description , such.
if go description full method is:
- (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component
so when user selects row method called , pickerview passed method automatically.
you can row user chose. if go page uipickerview class reference see this:
selecting rows in view picker
– selectrow:incomponent:animated: – selectedrowincomponent:
the method selectedrowincomponent:
1 want. in delegate method can this:
int selectedrow = (int)[pickerview selectedrowincomponent:0];
:) thats when want find answers questions this. :)
edit:
- (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { int selectedrow = (int)[pickerview selectedrowincomponent:0]; nslog(@"%i",selectedrow); }
Comments
Post a Comment