Memory not being released for MKMapView w/ ARC

前端 未结 3 1992
悲哀的现实
悲哀的现实 2021-01-02 07:58

I have a custom UIView called ActivityDetailView that I instantiate and then add to a scrollview within a parent view controller. When this custom

3条回答
  •  再見小時候
    2021-01-02 08:32

    This is not really the best way to create a custom view from your nib file. What I suggest you do is to add the view that you take from the .nib file as a subview to self. The code should look something like this.

    -(id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self)
        {
            NSArray *xibViews = [[NSBundle mainBundle] loadNibNamed:@"ActivityDetailView" owner:nil options:nil];
            if ([xibViews count] < 1) return nil;
            ActivityDetailView * xibView = [xibViews objectAtIndex:0];
            [xibView setFrame:frame];
            [self addSubview:xibView]; // This is where I have changed your code
        }
        return self;
    }
    

提交回复
热议问题