objective c - Link UIPickerView to NSTimer iOS -
i building app similar snapchat take picture or video , destructs after amount of time.
i implementing uipicker within camera module , once user take picture select time how long recipient sees picture, user sends image self destructs after 1-10 seconds.
how can link uipicker nstimer class?
camera.h @property (strong, nonatomic) iboutlet uipickerview *timepicker; @property (nonatomic, strong) nsarray *pickerdata; picker data in camera.m file: interface // { int secs; } @end - (void)viewdidload { [super viewdidload]; self.pickerdata = @[@"1 second", @"2 seconds", @"3 seconds", @"4 seconds", @"5 seconds", @"6 seconds", @" 7 seconds", @" 8 seconds", @" 9 seconds", @" 10 seconds"]; self.timepicker.datasource = self; self.timepicker.delegate = self; } -(long)numberofcomponentsinpickerview:(uipickerview *)pickerview { return 1; } -(long)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component { return self.pickerdata.count; } - (nsstring*)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { return self.pickerdata[row]; } -(void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { //help here please } - (ibaction)next:(id)sender { //goes select friends page }
image.m file image displayed user: image should destruct after amount of time user selects picker.
-(void)viewdidappear:(bool)animated { [super viewdidappear:animated]; if ([self respondstoselector:@selector(timeout)]) { [nstimer scheduledtimerwithtimeinterval:7 target:self selector:@selector(timeout) userinfo:nil repeats:no]; } } [timeout pops root view]
i need let user select time on picker , image in image.m file destruct after amount of time.
the user take picture below picture pickerview user selects time , presses next go select friends. half of screen picture other half uipickerview
just pass data second view controller, 1 displaying image. :
-(void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component { // leave empty } - (void)buttonhandler:(uibutton *)sender { image *ivc = [[image alloc] init]; ivc.seconds = [self.timepicker selectedrowincomponent:0]; [self presentviewcontroller:ivc animated:yes]; }
and in imageviewcontroller.h
you'd need :
@interface image : uiviewcontroller @property (nonatomic, assign) nsuinteger seconds; @end
then use value passed in seconds
property time timer in viewdidload
in camera.m
Comments
Post a Comment