Skip to content

Commit 6bd8b69

Browse files
committed
修改收货地址自动换行
1 parent 044accd commit 6bd8b69

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

Coding_iOS/Controllers/Shop/ShopViewController.m

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,28 +164,17 @@ - (void)setUpSegmentControl
164164
_oldSelectedIndex = index;
165165
_shopObject.shopType = index;
166166
[_collectionView reloadData];
167+
if (_collectionView.contentOffset.y > CGRectGetHeight(_collectionHeaderView.frame) ) {
168+
[_collectionView setContentOffset:CGPointMake(0, CGRectGetHeight(_collectionHeaderView.frame)) animated:NO];
169+
}
167170

168-
// [weakCarousel scrollToItemAtIndex:index animated:NO];
169171
}];
170172
_shopSegmentControl.backgroundColor = [UIColor whiteColor];
171173
[_collectionHeaderView addSubview:_shopSegmentControl];
172174
[self.view bringSubviewToFront:_shopSegmentControl];
173175
}
174176

175177

176-
#pragma mark - UIScrollViewDelegate
177-
178-
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
179-
{
180-
CGFloat offsetY = scrollView.contentOffset.y + scrollView.contentInset.top;
181-
CGFloat _shopSegmentControlY = CGRectGetHeight(_collectionHeaderView.frame) - kMySegmentControl_Height - 5;
182-
if (offsetY > _shopSegmentControlY) {
183-
_shopSegmentControl.frame = CGRectMake(0, offsetY, kScreen_Width, kMySegmentControl_Height);
184-
}else
185-
{
186-
_shopSegmentControl.frame = CGRectMake(0, _shopSegmentControlY , kScreen_Width, kMySegmentControl_Height);
187-
}
188-
}
189178

190179
#pragma mark - UICollectionViewDataSource
191180

@@ -239,6 +228,27 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
239228
[self.navigationController pushViewController:exChangeViewController animated:YES];
240229
}
241230

231+
232+
#pragma mark - UIScrollViewDelegate
233+
234+
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
235+
{
236+
CGFloat offsetY = scrollView.contentOffset.y + scrollView.contentInset.top;
237+
238+
CGFloat _shopSegmentControlY = CGRectGetHeight(_collectionHeaderView.frame) - kMySegmentControl_Height - 5;
239+
240+
if (offsetY > CGRectGetHeight(_collectionHeaderView.frame)) {
241+
242+
_shopSegmentControl.frame = CGRectMake(0, 0, kScreen_Width, kMySegmentControl_Height);
243+
[self.view addSubview:_shopSegmentControl];
244+
}else
245+
{
246+
_shopSegmentControl.frame = CGRectMake(0, _shopSegmentControlY , kScreen_Width, kMySegmentControl_Height);
247+
[_collectionHeaderView addSubview:_shopSegmentControl];
248+
}
249+
}
250+
251+
242252
- (void)didReceiveMemoryWarning {
243253
[super didReceiveMemoryWarning];
244254
// Dispose of any resources that can be recreated.

Coding_iOS/Views/Cell/ShopOderCell.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,20 +303,23 @@ - (void)setUpContentView
303303
_addressLabel.font = FONT(14);
304304
_addressLabel.backgroundColor = [UIColor clearColor];
305305
_addressLabel.numberOfLines = 0;
306-
_addressLabel.textAlignment = NSTextAlignmentLeft;
306+
// _addressLabel.lineBreakMode = NSLineBreakByWordWrapping;
307307
_addressLabel.textColor = [UIColor colorWithHexString:@"0x666666"];
308308
[superView addSubview:_addressLabel];
309309

310310
[addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
311311
make.top.equalTo(sendTimeLabel.mas_bottom).offset(9);
312312
make.left.equalTo(_goodsInfoView.mas_left);
313+
make.right.equalTo(_addressLabel.mas_left);
314+
make.width.mas_lessThanOrEqualTo(@70);
313315
}];
314316

315317
[_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
316318
make.top.equalTo(addressLabel.mas_top);
317319
make.left.equalTo(addressLabel.mas_right);
318320
make.right.equalTo(_goodsInfoView.mas_right);
319-
321+
make.width.equalTo(@(kScreen_Width - 26 - 70));
322+
make.bottom.equalTo(superView.mas_bottom).offset(-15);
320323
}];
321324

322325
[superView mas_makeConstraints:^(MASConstraintMaker *make) {

0 commit comments

Comments
 (0)