UITableViewCell彼此相邻

时间:2014-01-19 16:54:28

标签: ios objective-c

如何制作一个表格视图,其中单元格彼此相邻。每排有2个。像这样的例子?在第二行中,有2个图像彼此相邻。可以通过制作自定义tablevieCells在桌面视图中完成吗?

enter image description here

3 个答案:

答案 0 :(得分:0)

您需要使用UICollectionViewController(https://developer.apple.com/library/ios/documentation/uikit/reference/UICollectionViewController_clas/Reference/Reference.html

使用UICollectionView,您可以实现自定义布局,在布局中布局元素

答案 1 :(得分:0)

是的,这可以在UItableViewCell中完成但是首选使用这种视图的集合视图。

只是uitableviewcell的子类,添加新方法

-(void)setCellWithNumberOfImages:(NSInteger)images withImage1:(UIimage *)image1 withImage2:(UIImage *)image2;
if(image2 ==nil)
//add only one UIimageView with image1
else
//add two imageviews.

答案 2 :(得分:0)

您可以使用UICOllectionView这样更容易和可自定义,例如,您可以选择一行中包含多少项目。

有关更多信息,请查看:UICollectionView类参考