我遇到了UIView的问题。这是代码:
@property ( unsafe_unretained, nonatomic) IBOutlet UIView *formView;
- (IBAction)createNewProfile:(id)sender {
[self loadDialogForm];
}
-(void) loadDialogForm{
NSLog(@"load form");
CGRect frame = self.view.bounds;
CGPoint center = CGPointMake( frame.origin.x + ceil(frame.size.width/2),frame.origin.y + ceil(frame.size.height/2));
CGFloat width = floor(1 * frame.size.width) - OFFSET * 2;
CGFloat height = floor(1 * frame.size.height) - OFFSET * 2;
_formView.frame=CGRectMake(OFFSET, OFFSET, width, height); //here the error EXC_BAD_ACCESS (code=1 address=0xe07eca10)
_formView.center=center;
[self.view addSubview:_formView];
[self performSelector:@selector(initialDelayEnded) withObject:nil afterDelay:1];
}
通过NSLog,_formView的帧是x = 0,y = 0,width = 300,height = 390。为什么这个错误?
答案 0 :(得分:0)
使用
@property(非原子,保留)IBOutlet UIView * formView;
而不是
@property(unsafe_unretained,nonatomic)IBOutlet UIView * formView;