ios - 以编程方式定位 UITableView

标签 ios objective-c

我意识到这个问题已被问过几次,我已经按照答复进行操作,但它对我不起作用。

我有一个 UITableView,在 .h 文件中包含以下内容:

@interface ObViewControllerPreObsInfo : UIViewController < UITableViewDelegate, UITableViewDataSource>

并在viewDidLoad中设置delegatedataSource:

[tableViewNames setDelegate: self];
[tableViewNames setDataSource: self];

但是当我尝试时:

self.tableViewNames.frame.origin = 280;

我得到了错误

Expression is not assignable

有什么建议吗?

最佳答案

您必须创建一个新框架,然后将其分配给 View 。试试这个:

CGRect frame = self.tableViewNames.frame;
frame.origin.x = 20;
frame.origin.y = 20;
self.tableViewNames.frame = frame;

关于ios - 以编程方式定位 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32170810/

相关文章:

iphone - 从 MainViewController 传递和保存 Flip ViewController 之间的设置

iphone - 显示图像和字符串的 UIPIckerView

ios - 显示图像而不缩放查看

ios - 从 Objective-C 转换为 swift 时的 RespondToSelector 语法

ios - 自定义 UITableViewCell,一个包含两个 subview 的 UIView,并且可以滚动

ios - 如何在UICollectionView中获取选定的CollectionViewCell?

objective-c - 在 WINDOWS 上编译 Objective-C 时出现错误 "Foundation.h: no such file found"

ios - 如何以编程方式在 Swift 中使用 UISlider 更改 UIImageView 中指定的图像大小

ios - 使用 mergeChangesFromContextDidSaveNotification 时 CoreData 无法完成错误

iphone - 在编译时识别 iDevices,最佳实践