后公布我使用的一些源代码:将保留对象分配给弱属性;对象将分配
KGModalContainerView *containerView =
self.containerView =
[[KGModalContainerView alloc] initWithFrame:containerViewRect];
它给我:Assigning retained object to weak property; object will be released after assignment
编辑:
@interface KGModal()
@property (strong, nonatomic) UIWindow *window;
@property (weak, nonatomic) KGModalViewController *viewController;
@property (weak, nonatomic) KGModalContainerView *containerView;
@property (weak, nonatomic) UIView *contentView;
@end
KGModalContainerView *containerView =
self.containerView =
[[KGModalContainerView alloc] initWithFrame:containerViewRect];
containerView.modalBackgroundColor = self.modalBackgroundColor;
containerView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin;
containerView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
contentView.frame = (CGRect){padding, padding, contentView.bounds.size};
[containerView addSubview:contentView];
[viewController.view addSubview:containerView];
没有足够的信息来回答你的问题。如何定义'self.containerView'?用ARC编译KGModalContainerView吗? – trojanfoe 2013-02-27 10:47:39
我编辑我的问题,我正在使用ARC – pengwang 2013-02-28 01:51:45
你真的必须在一行中有两个任务吗?如果你不这样做会发生什么?为什么你必须将一个本地'containerView' *和*分配给一个属性'self.containerView'?那应该是什么意思? – matt 2013-02-28 02:04:05