【发布时间】:2015-01-23 16:51:17
【问题描述】:
我在这个博客http://themainthread.com/blog/2014/02/building-a-universal-app.html找到了这段代码
static void initSimpleView(SimpleView *self) {
// Configure default properties of your view and initialize any subviews
self.backgroundColor = [UIColor clearColor];
self.imageView = ({
UIImageView *imageView = [[UIImageView alloc] init];
imageView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:imageView];
imageView;
});
self.label = ({
UILabel *label = [[UILabel alloc] init];
label.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:label];
label;
});
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
initSimpleView(self);
}
return self;
}
它是如何工作的?
static void initWithSimpleView(SimpleView *self) 是什么意思?
为什么imageView 和label 在某种块中初始化?
【问题讨论】:
标签: ios objective-c c static objective-c-blocks