如何制作不是屏幕全宽的表格视图? [英] How to make a table view which is not the full width of the screen?

查看:32
本文介绍了如何制作不是屏幕全宽的表格视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种奇怪的原因,无论我如何为 UITableView 对象设置框架,UITableView 都会将我的单元格调整为 320 宽度.

For some strange reason, UITableView resizes my cells to 320 width no matter how I set the frame for the UITableView object.

即使我稍后再将单元格大小调整回 250,UITableView 似乎也会在某个时候再次将其调整为 320.

Even if I go in later and resize the cell back to 250, UITableView seems to resize it again to 320 some time.

是否有一些属性或方法必须额外设置/调用才能正确?

Is there some property or method that must be set / called additionally to get that right?

但是,我可以以看起来像 250 宽度的方式添加我的内容,但是我的整个布局代码一团糟,因为我不能依赖错误"的单元格框架宽度.此外,这似乎是一个很大的内存浪费,因为层树中的位图是无意义的 320 宽度而不是 250,即使 UITableView 的框架不是 320 宽度.

However, I can add my contents in a way that it looks like 250 width, but my whole layouting code is a big mess since I can't rely on the cell frame width which is "wrong". Also it seems like a big waste of memory since the bitmaps in the layer trees are nonsenseless 320 width instead of 250, even though the frame of the UITableView is not 320 width.

推荐答案

试试这个:

MyTable = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 5.0, 220.0, 385.0) style:UITableViewStyleGrouped];

这篇关于如何制作不是屏幕全宽的表格视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆