ios - 为什么无法使用 class_getProperty 获取 UIView.frame 属性?

标签 ios uiview frame xctest

它总是返回 NULL 而不是属性。

objc_property_t property = class_getProperty([UIView class], "frame");
XCTAssertTrue(property != NULL,
              @"UIView.frame property should be here.");

例如,与 center 配合使用时效果很好,但与 frame 配合使用时似乎不行。

有人能解释一下吗?

最佳答案

哇哦,好像确实没有这个属性,而是一个方法。文档显示为属性,但实际上它是一种方法。 https://github.com/JaviSoto/iOS7-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UIView.h

奇怪。

关于ios - 为什么无法使用 class_getProperty 获取 UIView.frame 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23462023/

相关文章:

objective-c - 更改应用程序中只有一个 UIViewController 的 UIInterfaceOrientation

ios - 如何释放不必要的应用程序内存?

ios - 无限旋转 UIView 直到调用停止方法并将 View 动画返回其起点

ios - self.view.frame.height = iPhone 5 中的 460

ios - Xcode build设置 "Build Products Path"(CONFIGURATION_BUILD_DIR) 是个谎言?

ios - OperationQueue 上的 `progress` 可以使用异步操作吗?

objective-c - 在主视图中初始化时子类 UIView 未加载

iOS:在 drawRect 中绘制 RGBA 数据而不事先转换为 UIImage

html - IE9 - 可接受的框架集替换

javascript - 找不到节点错误 - 尽管可以在控制台中找到节点