skywinder / ActionSheetPicker-3.0

Quickly reproduce the dropdown UIPickerView / ActionSheet functionality on iOS.
http://skywinder.github.io/ActionSheetPicker-3.0
BSD 3-Clause "New" or "Revised" License
3.4k stars 740 forks source link

In iOS 11 keyboard can not be stowed when the picker bounces #368

Closed leoxpx closed 6 years ago

leoxpx commented 6 years ago

when i choose a textField then choose picker, both of them couldn't down ,the view is death.

Maxatma commented 6 years ago

so just use view.endediting() ?

skywinder commented 6 years ago

Please, give provide more details about this issue. How it's going locked? SOme screenshots or code or both of them.

@Maxatma provide the good quick fix for that, but actually, it could be nice, if it should work without the extra code. (for example, we can fire endEditing from the picker) 👍

leoxpx commented 6 years ago

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ...... [cell setupTitlte:_inputInfosModel.inputLabel inputText:showArr.firstObject inputPlaceholder:_inputInfosModel.inputTip inputAction:nil selectAction:^{

[self dismissKeyboard]; // dismiss keyboard ActionSheetStringPicker * picker = [[ActionSheetStringPicker alloc]initWithTitle:@"choose" rows:showArr initialSelection:0 doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) { ...... } cancelBlock:nil origin:self.view]; }]; - (void)dismissKeyboard { [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:UIEventTypeTouches]; // [self.view endEditing:YES]; // [cell.inputText resignFirstResponder]; // no effect all of them }

image

Maxatma commented 6 years ago

@leoxpx Please, format your code, it is impossible to read. To help you, @skywinder first need to read what problem you have.

leoxpx commented 6 years ago
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell * cell =   ......

    [cell setupTitlte:@"title" inputText:@"" inputPlaceholder:@"please input" inputAction:nil selectAction:^{

    [self dismissKeyboard]; // dismiss keyboard 

    ActionSheetStringPicker * picker = [[ActionSheetStringPicker alloc]initWithTitle:@"choose" rows:showArr initialSelection:0 doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
     ......
     } cancelBlock:nil origin:self.view]; }];
}

-(void)dismissKeyboard {
     [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:UIEventTypeTouches]; 
    // [self.view endEditing:YES]; 
    // [cell.inputText resignFirstResponder]; // no effect all of them 
} `

@ UITableViewCell
- (void)setupTitlte:(NSString *)title inputText:(NSString *)input inputPlaceholder:(NSString *)placeholder inputAction:(InputAction)inputAction selectAction:(InputAction)selectAction {
      if (selectAction) {
         self.selectAction = selectAction;
         [self.inputText addTarget:self action:@selector(selectedClick) forControlEvents:UIControlEventEditingDidBegin];
    }
}
- (void)selectedClick {
    self.selectAction();
}
Maxatma commented 6 years ago

@leoxpx Not sure, if I correctly understood ur code, but we only see how u initialize ur picker, nothing about how it appears.

skywinder commented 6 years ago

Thanks, a lot for dive into and helping with this, @Maxatma 👍 Much appreciated!

@leoxpx please, show the code, that presents picker. (ie showPicker method)

skywinder commented 6 years ago

Feel free to reopen the issue, if you still need help. 👍