Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8032059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:16:49+00:00 2026-06-05T01:16:49+00:00

Okay.. here is the whole scenario The concept is to show multiple orders on

  • 0

Okay.. here is the whole scenario

The concept is to show multiple orders on a screen with user being able to slider left or right to see the next one. Once the order is accepted or declined the order view slides down and is replaced by the one next to it or previous if the order is at end.

I have a tabbar view that contains a simple UIScrollView and Couple of Buttons (Accept & Decline). In the ViewDidLoad I prepare an array of Orders, initialize ViewControllers (equal to total orders) with Nib files and add these these ViewController’s views to the ScrollView and Set the ScrollView’s content size etc.. (for vertical & horizontal scrolling)

When the user taps the AcceptButton an animation is performed sliding the Visible View in the UIScrollView down and then removing it from super view.

The animation code is performed as follows.

    BOOL lastPage = NO;
    BOOL ordersEmpty = NO;
    if (self.views.count == 1){
        ordersEmpty = YES;
        lastPage = YES;
    }

    UIViewController *controller2;
    if (self.views.count == page+1 && !ordersEmpty){
        lastPage = YES;
        controller2 = [self.views objectAtIndex:page-1];
    } else if (!ordersEmpty){
        controller2 = [self.views objectAtIndex:page+1];
    }
    [UIView animateWithDuration:1.5 animations:^{
        CGRect frame = controller.view.frame;
        frame.origin.y = frame.size.height + 100;
        controller.view.frame = frame;

        if (lastPage == NO){
            CGRect frame2 = controller2.view.frame;
            frame2.origin.x = frame.origin.x;
            controller2.view.frame = frame2;
        }else{
            // [self.scrollView scrollRectToVisible:controller2.view.frame animated:YES];
        }

    } completion:^(BOOL value){
        [controller.view removeFromSuperview];
        [self.views removeObject:controller];
        totalPages.text = [NSString stringWithFormat:@"%i", self.views.count];
        // currentPage.text = [NSString stringWithFormat:@"%i", 
        self.pageControl.numberOfPages = self.views.count;
        if (lastPage && !ordersEmpty){
            [self.scrollView scrollRectToVisible:controller2.view.frame animated:YES];
            lastPageMoving = YES;
        }else if (ordersEmpty){
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
            label.text = @"There are currently no notifications";
            label.textAlignment = UITextAlignmentCenter;
            label.center = CGPointMake(self.scrollView.frame.size.width/2, self.scrollView.frame.size.height/3);
            [self.scrollView addSubview:label];
            [label release];
            ofPages.text = @"";
            totalPages.text = @"";
            currentPage.text = @"";
            self.scrollView.contentSize = CGSizeMake(320, 267);
        }

        int i = 0;
        for (UIViewController *c in self.views)
        {
            c.view.frame = CGRectMake(self.scrollView.frame.size.width * i, 0, c.view.frame.size.width, c.view.frame.size.height);
            i++;
        }

        if (controller2 != nil)
        {
            if ([controller2 isKindOfClass:[CancelledController class]]) {
                self.acceptButton.hidden = YES;
                [self.declineButton setTitle:@"Close" forState:UIControlStateNormal];
                [self.declineButton setTitle:@"Close" forState:UIControlStateHighlighted];
            }else{
                self.acceptButton.hidden = NO;
                [self.declineButton setTitle:@"Decline" forState:UIControlStateNormal];
                [self.declineButton setTitle:@"Decline" forState:UIControlStateHighlighted];
            }
        }
    }];

The animations work fine and views removed are deallocated however

when the last view is accepted the application crashes with exc_bad_access exactly at [UIView animateWithDuration:animations:completion] method call.

NSZombies does not detect exact leak point / cause..

After extensive research, I think it might be due to using blocks .. the memory management is fine because if I were overreleasing anything, NSZombies would have indicated it.

(THE CODE WORKS FINE IN SIMULATOR THOUGH – NO ERRORS WHAT SO EVER)

I made a video to demonstrate how animations work.. It’s of the simulator so no error here however, when I run it on a device, application crashes as soon as I press the close button.

An interesting thing is if I close second order first and accept first order after, code works fine too =( Very Confusing Indeed..!!

http://www.mediafire.com/?w1up9g9u6w0ucrn

The project targets iOS 4.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:16:51+00:00Added an answer on June 5, 2026 at 1:16 am

    You can start by changing the declaration UIViewController *controller2 to UIViewController *controller2 = nil;, then it’s a good idea to use only properties, so the lines:

    [controller.view removeFromSuperview];
    [self.views removeObject:controller];
    

    would be replaced by calling accessor methods of this property and you and we will have an exact idea if the ivar controller is retained or not. This is valid for all other ivars you’re using: lastPageMoving, ofPages, totalPages, currentPage etc.. – just change them to properties and be sure about their proper memory management.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so here's, the scenario I have a thumbnail that contains an artists profile
Okay here's my situation. I have the following branches development development-kirby (270 commits ahead
Okay here is what I'm trying to do: I have a model object that
Okay so here is what I want to do. I want to add a
Okay so here's what I'm doing. I'm making a request to a server to
Okay so here is the deal. As the question states, I'm trying to POST
Okay basically here's where I'm at. I have a list of PropertyDescriptor objects. These
Okay so here's my algorithm for finding a Cut in a graph (I'm not
Okay, here's the situation: I've created a class extending Android's SQLOpenHelper class. I've also
Okay this is definitely a n00b question but here goes. The way I understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.