ios - UITextField touch events don`t work in UIScrollView -


i have uitextfield, in textfield action not working when uitextfield subview of uiscrollview.

other wise , working fine , here code .. please ?

i using code because need fire uidatepicker right after alertview buttons click.

- (void)viewdidload { [super viewdidload];   uiscrollview *scroll = [[uiscrollview alloc]initwithframe:cgrectmake(0, 0, 320, 480)];  [self.view addsubview:scroll];  date = [[uitextfield alloc]initwithframe:cgrectmake(80, 150, 150, 50)]; date.placeholder = @"date"; date.delegate = self; [date addtarget:self action:@selector(dateclicked:) forcontrolevents:uicontroleventtouchdown]; [scroll addsubview:date];  }    - (void)dateclicked:(id)sender     {     nslog(@"clicked");      uialertview *alertview = [[uialertview alloc]initwithtitle:@"choose date format" message:nil delegate:self cancelbuttontitle:@"dd/mm/yyyy" otherbuttontitles:@"mm/dd/yyyy", nil];      [alertview show];       } 

you set uibutton same frame uitextfield , set uibutton uicontroleventtouchupinside event , update uitextfield value.

- (void)viewdidload {     [super viewdidload]; uiscrollview *scroll = [[uiscrollview alloc]initwithframe:cgrectmake(0, 0, 320, 480)];      [self.view addsubview:scroll];      date = [[uitextfield alloc]initwithframe:cgrectmake(80, 150, 150, 50)];     date.placeholder = @"date";     uibutton *btn=[[uibutton alloc]initwithframe:cgrectmake(80, 150, 150, 50)];     [btn addtarget:self action:@selector(dateclicked:) forcontrolevents:uicontroleventtouchupinside];     [scroll addsubview:date];     [scroll addsubview:btn]; } - (void)dateclicked:(id)sender {     nslog(@"clicked");     uialertview *alertview = [[uialertview alloc]initwithtitle:@"choose date format" message:nil delegate:self cancelbuttontitle:@"dd/mm/yyyy" otherbuttontitles:@"mm/dd/yyyy", nil];     [alertview show]; } 

Comments