ios - SDScrollview与Masonry配合使用无法显示轮播器?
伊谢尔伦
伊谢尔伦 2017-04-17 18:01:34
0
1
637

我想实现的效果是这样的:
首页上显示一个轮播器,轮播器用Masonry实现,轮播器下面是一个tableview,并且用Masonry进行自动布局。
UI用代码实现。

NSArray* imageNames = @[@"checked", @"test1"]; _vCycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, 180) imageNamesGroup:imageNames]; [self.view addSubview:_vCycleScrollView]; [_vCycleScrollView mas_makeConstraints:^(MASConstraintMaker* make){ make.top.equalTo(self.view); make.left.equalTo(self.view); make.right.equalTo(self.view); make.width.equalTo(self.view.mas_width); }]; _vCategoryTableView = [[UITableView alloc] init]; _vCategoryTableView.separatorStyle = UITableViewCellSeparatorStyleNone; _vCategoryTableView.delegate = self; _vCategoryTableView.dataSource = self; [self.view addSubview:_vCategoryTableView]; [_vCategoryTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view); make.top.equalTo(_vCycleScrollView).with.offset(10); make.width.mas_equalTo(self.view.mas_width); make.height.equalTo(self.view); }];

轮播器完全显示不出来。

如果单把scrollview的constraint注释掉,可以显示出图片的底边

如何解决?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all (1)
Ty80
[_vCycleScrollView mas_makeConstraints:^(MASConstraintMaker* make){ make.top.equalTo(self.view.mas_top); make.left.equalTo(self.view.mas_left); make.right.equalTo(self.view.mas_right); make.height.equalTo(@168); }]; [_vCategoryTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.mas_left); make.right.equalTo(self.view.mas_right); make.top.equalTo(_vCycleScrollView.mas_bottom).with.offset(10); make.bottom.equalTo(self.view.mas_bottom); }];

Such a carousel image is fixed at the top. If you want the carousel image to slide with the tableview, then you can use the carousel image as the header of the tableview and set the frame of the carousel image.

When I use masonry, make.right.equalTo(self.view) will constrain right to the left of the view.
If it is make.top.left.bottom.right.equalTo(self.view), it is the correct position. I guess it corresponds to UIEdgeinsets

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!