0

我有一个 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。为什么会出现这个错误?

4

1 回答 1

0

采用

@property (nonatomic,retain) IBOutlet UIView *formView;

代替

@property ( unsafe_unretained, nonatomic) IBOutlet UIView *formView;

于 2012-06-15T12:35:09.383 回答