b3rge
b3rge

Reputation: 5009

My app crashes after navigating backwards from a scrolled UIScrollview in a Navigation controller

It is a bit tricky to explain, but I will try. When I navigate backwards from the "Mercurial page" (see picture) when the scrollview is scrolled, my app crashes. But when it is not scrolled, the app does not crash... I have implemented <UIScrollViewDelegate> Any help would be greatly appreciated! Here are some pictures and some code that I have in my app:

-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    [self.scrollView layoutIfNeeded];
    self.scrollView.contentSize=self.contentView.bounds.size;
}

- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat yPos = -scrollView.contentOffset.y;
    if (yPos > 0) {

        CGRect imgRect = self.imageView.frame;
        imgRect.origin.y = scrollView.contentOffset.y;
        imgRect.size.height = HeaderHeight+yPos;
        self.imageView.frame = imgRect;
}

enter image description here

enter image description here

enter image description here

Upvotes: 3

Views: 872

Answers (1)

Paresh Dudhat
Paresh Dudhat

Reputation: 1246

this worked for me.

-(void)viewWillDisappear:(BOOL)animated{
    [self.scrollView setDelegate:nil];
}

Upvotes: 6

Related Questions