Skip to content

ios,picker点击取消按钮后再次打开picker会导致无法显示数据,附解决办法。 #439

@swb2016

Description

@swb2016

iOS系统,调用Picker.init方法初始化后,点击选择可以正常打开选择框。当点击取消按钮后,再次点击选择打开选择框,选择框内无法显示数据。此问题在Android系统中不存在,经过检查插件源码发现,点击取消按钮的逻辑与点击确定按钮的逻辑相似,但取消按钮的逻辑最下方多出一行代码

self.pick.hidden=YES;

该行代码位置在BzwPicker.m文件的cancleAction方法中,位于该方法逻辑的最后一行。
注释掉此行代码后,iOS的取消选择逻辑就正常了,取消选择后再次打开Picker也可以显示数据了。

完整修改:

//按了取消按钮
-(void)cancleAction
{
    NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
    
    if (self.backArry.count>0) {
        [dic setValue:self.backArry forKey:@"selectedValue"];
        [dic setValue:@"cancel" forKey:@"type"];
        
        [dic setValue:[self getselectIndexArry] forKey:@"selectedIndex"];
        
        self.bolock(dic);
    }else{
        [self getNOselectinfo];
        
        [dic setValue:self.backArry forKey:@"selectedValue"];
        [dic setValue:@"cancel" forKey:@"type"];
        [dic setValue:[self getselectIndexArry] forKey:@"selectedIndex"];
        self.bolock(dic);
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [UIView animateWithDuration:.2f animations:^{
            
            [self setFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 250)];
            
        }];
    });

//    self.pick.hidden=YES; //注释此行代码,否则点击取消按钮后再次打开Picker会导致没有数据
}

该解决办法仅供参考。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions