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 6735721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:02:46+00:00 2026-05-26T11:02:46+00:00

I have a problem with the new PageViewController (the one with the nifty page

  • 0

I have a problem with the new PageViewController (the one with the nifty page turn animations). As far as I understand, there is a stack of ViewControllers which you need to set up like so:

PageView *startingViewController = [self.modelController viewControllerAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];

So far so good. Then you need to set up a source (your model Controller). In your model controller, you need to have four methods:

-(PageView *)viewControllerAtIndex:(NSUInteger)index
-(NSUInteger)indexOfViewController:(PageView *)viewController
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController

The last two are called if you turn the page (to the next or the previous). The second one simply determines the page index number. The interesting one – and the one where my problem is – is the first one. The first one returns a ViewController (which in my example is called PageView). This is the very end of the method:

PageView *pView = [[PageView alloc] init];
return pView;

I am wondering where this pView ends up and how I can release it? I guess autorelease is a bad idea as I don’t know how long it is needed. If it ends up in the stack (which I guess it does), how long is it needed? Surely just for the next couple of pages. For instance, imagine setting up a pView for page 1. You then turn to page 2 and 3. By then you don’t need page 1 anymore – you could release it. If you go back to page 1 it will be reloaded.

I put log commands in my pView dealloc, but it is never called. So I guess I’m leaking every single viewControllers I’ve created.

Any ideas how and where to release them once they are not needed anymore?

  • 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-26T11:02:47+00:00Added an answer on May 26, 2026 at 11:02 am

    autorelease is exactly what you need. This is the perfect situation for which autorelease was designed i.e. you need to return an object but don’t know how long it will be needed.

    PageView *pView = [[PageView alloc] init] autorelease];
    return pView;
    

    Your PageView instance is allocated on the heap (not the stack) and PageViewController will take ownership of it and retain it if it needs to keep it around. It becomes PageViewController’s responsibility after your method has returned.

    (Otherwise just use ARC and let the compiler take care of it)

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

Sidebar

Related Questions

I have a new problem which MUST affect practically every person who uses AJAX.
I'm new in Entity Framework and i have problem with something which was quite
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I do not have problem as such but I am quite new to Ruby.
I have problem with Qt::Tool flag. When I create new widget with Qt::Tool flag
I am new on iphone development and I have problem with CoreData. I hardly
Following on from my previous question [link text][1] , I have a new problem.
I have a problem at some customer pc's (new Dell PCs) windows XP Professional
i am new in JSP,i have some problem with the following code : <%@
I have the problem I just installed the new Monodevelop 2.2.2 on Windows but

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.