ios - 绘制矩形导致错误,无法引用 myview

标签 ios drawrect self

这是我的代码。我正在尝试访问我的 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/

相关文章:

iphone - iOS Apptentive SDK - 来自 `[NSManagedObject setup]` 的 NSInvalidArgumentException

cocoa - NSScrollview 和透明、覆盖 NSScroller 子类

iOS:在 UIView 上以 LineWidth 1px 绘制文本

ios - 异步绘图和触摸

python - python中类方法的自解封

python-2.7 - 尝试调用 def 时,我得到 : parameter 'self' unfilled

ios - 使用 AudioKit AKOfflineRenderNode 保存的文件不正确

ios - 连接 2 个 NSAttributedString

iphone - 使用 Rails 应用程序验证 iPhone 应用程序

Python 类 self.variables