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

  • SEARCH
  • Home
  • 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 7506477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:16:24+00:00 2026-05-29T22:16:24+00:00

I have a scroll view with paging control. It loads several pages according to

  • 0

I have a scroll view with paging control. It loads several pages according to an array, and each page has its table view.

   for(id name in categories) {

        NSLog(@"Loading Page.%i",i);
        NSLog(@"categories count:%i",[categories count]);

       TasksPageViewController *tasks = [[TasksPageViewController alloc] init] ;

       tasks = [self.storyboard instantiateViewControllerWithIdentifier:@"TasksPageViewController"];

        CGRect frame = scrollView.frame;
        frame.origin.x = frame.size.width * i;
        frame.origin.y = 0;
        tasks.view.frame = frame;

        [tasks populateWithData:(i-1) categoryName:name];

        [self.scrollView addSubview:tasks.view];

        i++;

    }

the .h file is:

#import <UIKit/UIKit.h>
#import "MainPageViewController.h"
#import "TasksPageViewController.h"

@interface ViewController : UIViewController{

    UIScrollView *scrollView;
    IBOutlet UIPageControl *pageControl;

    // To be used when scrolls originate from the UIPageControl
    BOOL pageControlUsed;
}

@property (nonatomic, strong) IBOutlet UIScrollView *scrollView;
@property (nonatomic, strong) IBOutlet UIPageControl *pageControl;

- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
- (IBAction)changePage;

@end

The UITableView though is returning

*** -[TasksPageViewController tableView:numberOfRowsInSection:]: message sent to deallocated instance 0x68efac0

(originally it was a EXEC_BAD_ACCESS, but got this with NSZombiesEnabled)

I don’t know how to proceed, I think I have to retain the tasks but how?

  • 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-05-29T22:16:26+00:00Added an answer on May 29, 2026 at 10:16 pm

    When adding the view of a view controller as a subview of a view you control, you need to retain the controller. keep it as a property with retain/strong, or an array of view controllers if there are many of them

    in this case adding the view as a subview has retained it, so you still have a reference to the table view. but the view controller has been dealloc’d which is why the datasource (which is the view controller for UITableViewController) method is being sent to a deallocated instance

    Also, why do you initialise the view controller, and then immediately instantiate it from the storyboard?

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

Sidebar

Related Questions

I have a table view controller which doesn't let me manually scroll to the
I am new to programming. I have a paging enabled scroll view with many
I have scroll view with page controll i have images in scroll view i
in the main view controller i have a scrollview and paging control. i have
I have: 1 paging scroll view at the bottom (like a panel) that is
Hi i made an application which has 2 views one paging scroll view which
I have set paging property of scroll view to 'scrollview.pagingEnabled = YES'. When tested
I have a view controller with a paging scrollview displaying pages of data to
I have an scroll view with some sophisticated animations happening during scrolling. Although after
I have a scroll view with transparent background that covers most of the screen.

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.