我有一个静态表格和3个单元格。我随机在每个单元中放置一些标签和其他控制器并运行它。它显示很好。但是,当我放置一张图像时,它一次只能覆盖两个或三个单元格。在UITableViewController
我评论所有tableView
方法。为什么发生这种情况?UIImage没有正确定位在静态单元格中
0
A
回答
1
- 这听起来像你正在使用静态单元格与
UITableViewDelegate
方法从你的描述,这不加起来。您不需要为静态表视图实现这些方法。 - 检查您的细胞高度以及是否启用了
clipsToBounds
。 - 检查您的
UIImageView
大小以及是否启用了clipsToBounds
。
+0
感谢评论。我得到了解决方案。:) – Tulon 2015-02-08 08:53:06
0
我一直在寻找的是这样的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
if ((indexPath.row)==0)
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"one"];
UIImageView *backgroundView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 170)];
backgroundView.image=[UIImage imageNamed:@"default-cover-image.jpg"];
[cell.contentView addSubview:backgroundView];
}
if ((indexPath.row)==1)
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"two"];
UIImageView *backgroundView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
backgroundView.image=[UIImage imageNamed:@"sectionHeader.png"];
[cell.contentView addSubview:backgroundView];
}
if ((indexPath.row)==2)
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"three"];
UIImageView *backgroundView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
backgroundView.image=[UIImage imageNamed:@"sectionHeader2.png"];
[cell.contentView addSubview:backgroundView];
}
if ((indexPath.row)==3)
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"four"];
UIImageView *backgroundView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 170)];
backgroundView.image=[UIImage imageNamed:@"default-cover-image.jpg"];
[cell.contentView addSubview:backgroundView];
}
return cell;
}
如果我只是刚落静态表格单元格内的imageView
,并在其中添加图片,然后定位不准确的行动。虽然差异只出现在真实的设备上。不在故事板上。 感谢每一位评论我的帖子。祝你有美好的一天。 :)
相关问题
- 1. Openpyxl没有正确写入单元格
- 2. 表格单元格没有在Chrome中正确包装文字
- 3. Swift:创建静态自定义单元格没有dequeueReusableCellWithIdentifier
- 4. 在C中没有正确设定静态变量值#
- 5. GridBagLayout没有正确定位
- 6. 确定DataGridView中的单元格位置
- 7. Abs。内部按钮定位的元素没有正确定位
- 8. Segue没有在Swift中发送正确的单元格信息
- 9. 如何在tableview中创建动态单元格(没有自定义单元格)?
- 10. UITableView与两个自定义单元格没有正确显示
- 11. 动态表单元格未正确确定IE/Edge
- 12. ImagePickerController没有正确定位在视图
- 13. 在自定义静态单元格内按UIButton时没有采取行动
- 14. 有条件地显示静态单元格表格中的单元格
- 15. HTML表格单元格没有正确对齐
- 16. 表格单元格没有正确地跨越
- 17. uiimage没有正确放入子视图
- 18. XCode storyboard中的自定义静态表格单元格?
- 19. 单元格宽度在静态UITableView
- 20. 在静态单元格上使用UIDatePicker
- 21. Cocoa中的静态NSTableView单元格
- 22. 在静态行中创建自定义单元格UITableView
- 23. Segue从静态单元格动态TableViewController
- 24. 在Xcode中动态调整UITableView单元格内的UIImage宽度
- 25. 静态表格视图单元格标签正陷入页眉
- 26. 在Excel中确定单元格中的#
- 27. UINavigationController导航栏没有正确定位
- 28. android:layout_alignParentBottom,android:layout_alignParentRight没有正确定位
- 29. 嵌套的DIV没有正确定位
- 30. 划分框没有正确定位
“当我把图像” - 但你怎么做?很明显,你这样做的方式是错误的。但是你不是在展示你在做什么,那么人们怎么能够“理解”它呢? – matt 2015-02-07 19:14:00
Pease分享一些代码,所以我们可以帮助你。如果您使用故事板或XIB设计您的单元格,请张贴它的一些截图。 – Romain 2015-02-07 19:15:20
拖放。没有代码。没有CGRect。我现在不是正确的方式吗? : -/ – Tulon 2015-02-07 19:28:59