Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] 关闭动画无效果的原因 #440

Open
boboxiaodd opened this issue Mar 25, 2023 · 0 comments
Open

[iOS] 关闭动画无效果的原因 #440

boboxiaodd opened this issue Mar 25, 2023 · 0 comments

Comments

@boboxiaodd
Copy link

boboxiaodd commented Mar 25, 2023

Picker.hide() 方法提前执行了hidden,导致动画无效,
onPickerCancel 提前执行了 hidden ,也会导致动画无效并且闪烁

改动如下:

RCT_EXPORT_METHOD(hide){

    if (self.pick) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView animateWithDuration:.3 animations:^{
                [self.pick setFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, self.height)];
            } completion:^(BOOL finished) {
                [self.pick removeFromSuperview];
                self.pick = nil;
            }];
        });
    }

//    self.pick.hidden=YES;

    return;
}

建议注释掉下面的2块代码,让点击取消,确定,和hide一样的效果

dispatch_async(dispatch_get_main_queue(), ^{

    /*
    dispatch_async(dispatch_get_main_queue(), ^{
        [UIView animateWithDuration:.2f animations:^{
            
            [self setFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 250)];
            
        }];
    });

    self.pick.hidden=YES;
   */

dispatch_async(dispatch_get_main_queue(), ^{

 /*
  dispatch_async(dispatch_get_main_queue(), ^{
        [UIView animateWithDuration:.2f animations:^{
            
            [self setFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 250)];
        }];
    });
*/
RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
    // ...
     _pick.bolock=^(NSDictionary *backinfoArry){
            dispatch_async(dispatch_get_main_queue(), ^{
                if(![[backinfoArry valueForKey:@"type"] isEqualToString:@"select"]){
                    [weakSelf hide]; //调用hide方法实现一样的动画效果
                }
                [weakSelf sendEventWithName:@"pickerEvent" body:backinfoArry];
            });
        };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant