这是我的代码。我正在尝试访问我的 View 框架。 首先我 nslog 自己,以确保分配了 View ,然后我尝试 nslog 我的 View 框架,它返回 null。 代码:
- (void)drawRect:(CGRect)rect {
NSLog(@"%@",self);
CGRect frameads = self.frame;
NSLog(@"%@",frameads);
}
编译器输出:
2012-07-18 11:41:59.808 animation[74551:f803] <MyView: 0x68568e0; frame = (0 37; 320 321); autoresize = RM+BM; layer = <CALayer: 0x6856a50>>
2012-07-18 11:41:59.808 animation[74551:f803] (null)
最佳答案
frame
是一个结构 (CGRect
) 所以不会使用 %@ 记录,使用
NSLog(@"%@", NSStringFromCGRect(self.frame));
关于ios - 绘制矩形导致错误,无法引用 myview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11545247/