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

半城伤御伤魂 提交于 2019-12-03 02:41:52

问题


I'm debugging my code and trying to figure out the size of the view using this:

p view.frame.size.height

but I'm getting this error:

error: property 'frame' not found on object of type 'UIView *' error: 1 errors parsing expression

any of you knows why or how can I debug the size of my view?


回答1:


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?




回答2:


Try this

p (CGRect)[view frame]

Alternative to get the frame of the view:

po view



回答3:


Try this,

po view.layer.frame.size.height



回答4:


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)



回答5:


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




回答6:


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




回答7:


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.



来源:https://stackoverflow.com/questions/16926239/error-property-frame-not-found-on-object-of-type-uiview

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