Skip to content

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

@boboxiaodd

Description

@boboxiaodd

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];
            });
        };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions