Closed TomWang1 closed 4 years ago
centerView要设置frame,stringPickerView会自动填满centerView视图------------------ 原始邮件 ------------------ 发件人: "TomWang1"notifications@github.com 发送时间: 2020年5月4日(星期一) 下午3:18 收件人: "91renb/BRPickerView"BRPickerView@noreply.github.com; 抄送: "Subscribed"subscribed@noreply.github.com; 主题: [91renb/BRPickerView] 使用[stringPickerView addPickerToView:centerView];方法不可以添加到指定View上 (#144)
//添加picker UIView *centerView = [[UIView alloc] init]; centerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; [backView addSubview:centerView];
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
设置了 Frame还是不可以。使用masonry设置布局不可以吗?我在调用addPickerToView的时候,可以看到Frame。centerView.frame = CGRectMake(0, 49.5, kScreenWidth - 24, 157);
可以使用masonry设置布局,您数据源传的是二维数组,所以必须要设置stringPickerView.pickerMode = BRStringPickerComponentMulti;
可以参考下面代码:
UIView *centerView = [[UIView alloc]init];
[_footerView addSubview:centerView];
[centerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(30);
make.right.mas_equalTo(-30);
make.top.mas_equalTo(170);
make.height.mas_equalTo(200);
}];
BRStringPickerView *stringPickerView = [[BRStringPickerView alloc]init];
stringPickerView.pickerMode = BRStringPickerComponentMulti;
stringPickerView.title = @"自定义多列字符串";
stringPickerView.dataSourceArr = @[@[@"竞拍时间"], @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", @"13", @"14", @"15", @"16", @"17", @"18", @"19", @"20", @"21", @"22", @"23", @"24", @"25", @"26", @"27", @"28", @"29", @"30", @"31", @"32", @"33", @"34", @"35", @"36", @"37", @"38", @"39", @"40", @"41", @"42", @"43", @"44", @"45", @"46", @"47", @"48", @"49", @"50", @"51", @"52", @"53", @"54", @"55", @"56", @"57", @"58", @"59"], @[@"分"]];
stringPickerView.isAutoSelect = YES;
stringPickerView.resultModelArrayBlock = ^(NSArray<BRResultModel *> *resultModelArr) {
};
[stringPickerView addPickerToView:centerView];
` //添加picker UIView centerView = [[UIView alloc] init]; centerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; [backView addSubview:centerView]; [centerView mas_makeConstraints:^(MASConstraintMaker make) { make.left.right.mas_equalTo(0); make.top.mas_equalTo(titleLabel.mas_bottom).offset(9); make.bottom.mas_equalTo(makeSureBtn.mas_top).offset(-15); }]; [self layoutIfNeeded]; BRStringPickerView stringPickerView = [[BRStringPickerView alloc]init]; // stringPickerView.pickerMode = BRStringPickerComponentMulti; stringPickerView.title = @"自定义多列字符串"; stringPickerView.dataSourceArr = @[@[@"竞拍时间"], @[ @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", @"13", @"14", @"15", @"16", @"17", @"18", @"19", @"20", @"21", @"22", @"23", @"24", @"25", @"26", @"27", @"28", @"29", @"30", @"31", @"32", @"33", @"34", @"35", @"36", @"37", @"38", @"39", @"40", @"41", @"42", @"43", @"44", @"45", @"46", @"47", @"48", @"49", @"50", @"51", @"52", @"53", @"54", @"55", @"56", @"57", @"58", @"59"],@[@"分"]]; // stringPickerView.selectIndexs = self.otherSelectIndexs; //stringPickerView.selectValues = [self.infoModel.otherStr componentsSeparatedByString:@","]; stringPickerView.isAutoSelect = YES; stringPickerView.resultModelArrayBlock = ^(NSArray<BRResultModel > *resultModelArr) {
// customStyle.selectRowTextFont = [UIFont boldSystemFontOfSize:23.0f]; // customStyle.selectRowTextColor = [UIColor br_labelColor]; stringPickerView.pickerStyle = customStyle; // [stringPickerView show]; [stringPickerView addPickerToView:centerView]; `