error: property 'frame' not found on object of type 'UIView *'

和自甴很熟 提交于 2019-12-02 16:14:42
Chris Yim

If you hate typecasting every time, you can try this:

(lldb) expr @import UIKit
(lldb) po self.view.bounds

Since Xcode 7.2 is now available, I think we should update the answer.
I find the answer here, Why can't LLDB print view.bounds?

Try this

p (CGRect)[view frame]

Alternative to get the frame of the view:

po view

Try this,

po view.layer.frame.size.height

it should have outer bracket in the first answer,like this:

p ((CGRect)[cell frame])

output:

(CGRect) $5 = origin=(x=0, y=0) size=(width=320, height=44)
wj2061

Add a pch file , add these lines of code to the file:

#ifndef PrefixHeader_pch
#define PrefixHeader_pch

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif  

#endif /* PrefixHeader_pch */    

Next, link the pch file to your project:

Run the app again, then you should be able to use the dot notation in lldb console:

(lldb) po self.view.bounds    

For how to add a pch file , see the answer here PCH File in Xcode 6

It seems that we cannot use dot notation in the console, try to use get method.

I had same problem and i solved it. Your class might be inherited from "UIViewController". It must be inherited from "UIView" so as to make an frame object in it.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!