Jua*_*uan 2 objective-c uitableview ios
我需要在我的表格视图中进行水平滚动,我搜索了所有 Google 但没有找到任何内容,我就这样做了
CGRect tableFrame = CGRectMake(15, heightView-360, widthView+50, heightView-200);
UITableView *tableView = [[UITableView alloc]initWithFrame:tableFrame style:UITableViewStylePlain];
tableView.layer.cornerRadius=7;
tableView.rowHeight = 40;
tableView.sectionFooterHeight = myData.count;
tableView.sectionHeaderHeight = myData.count;
tableView.scrollEnabled = YES;
tableView.showsVerticalScrollIndicator = YES;
tableView.showsHorizontalScrollIndicator=YES;
tableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
tableView.userInteractionEnabled = YES;
tableView.bounces = YES;
tableView.delegate = self;
tableView.dataSource = self;
[self.view addSubview:tableView];
Run Code Online (Sandbox Code Playgroud)
有什么问题吗?为什么不走横向滚动呢?
您正在寻找的是 a UICollectionView,而不是 a UITableView。在这里您可以实现单元格并向任一方向滚动。
在 Interface Builder 中,当您选择 CollectionView 时,它有一个名为“滚动方向”的属性 - 将其更改为“水平”
| 归档时间: |
|
| 查看次数: |
9679 次 |
| 最近记录: |