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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:47:58+00:00 2026-05-27T06:47:58+00:00

I am trying to push an opengl UIView to my navigation controller like this

  • 0

I am trying to push an opengl UIView to my navigation controller like this

GraphViewController *gvc = [[GraphViewController alloc] initWithTicker:[listOfItems objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:gvc animated:YES];
[gvc release];

The initWithTicker method looks like this

-(id) initWithTicker:(NSString*)ticker{
self = [super initWithNibName:nil bundle:nil];
if (self) {
    self.title = ticker;
    EAGLView *eagl = [[EAGLView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    eagl.animationInterval = 1.0 / 60.0;
    [eagl startAnimation];
    self.view = eagl;
}
return self;

}

When I go back and forward in my UINavigationController, the drawView method (in EAGLView) keeps looping. Furthermore, if I pushViewController again, the first one does not stop and a new one is created! I’ve tried making this an instance variable so only one is created and it has the same effect. I would be grateful if anyone has insight as to why this is happening

sergio Suggestion:

-(id) initWithTicker:(NSString*)ticker{
   self = [super initWithNibName:nil bundle:nil];
   if (self) {
      self.title = ticker;
   }
   return self;
}
// Implement loadView to create a view hierarchy programmatically, without using a nib.

- (void)loadView {
    eagl = [[EAGLView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.view = eagl;
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    eagl.animationInterval = 1.0 / 60.0;
    [eagl startAnimation];
    [super viewDidLoad];

}

same behaviour.

—This is how I fixed my drawView looping problem–

-(void)viewDidAppear:(BOOL)animated {
    [eagl startAnimation];
    [super viewDidAppear:animated];
}

-(void)viewDidDisappear:(BOOL)animated {
    [eagl stopAnimation];
    [super viewDidDisappear:animated];

}

–Craigs solution —

if(graphView == nil){
        graphView = [[GraphViewController alloc] initWithTicker:[listOfItems objectAtIndex:indexPath.row]];
    }else{
        [graphView release];
        graphView = [[GraphViewController alloc] initWithTicker:[listOfItems objectAtIndex:indexPath.row]];
    }
  • 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-27T06:47:58+00:00Added an answer on May 27, 2026 at 6:47 am

    Are you creating a new GraphViewController every time you want to push one onto your navigation stack? If so, it doesn’t really matter how you’re handling the creation of your EAGLView instance variable, since you’re never going to be interacting with that view controller again anyway.

    For example:

    1. User taps something, a new GraphViewController is pushed on the stack
    2. User goes back, this view controller continues to run
    3. Return to 1. and repeat (thus creating a SECOND GraphViewController, and then a third, and then a fourth… etc.)

    What you should probably be doing is maintaining your GraphViewController as an instance variable, and only creating it once. This will ensure that you’re in turn only creating one EAGLView.

    if (_graphViewController == nil) {
        _graphViewController = [[GraphViewController alloc] initWithTicker:[listOfItems objectAtIndex:indexPath.row]];
    }
    [self.navigationController pushViewController:_graphViewController animated:YES];
    

    Then, be sure to release the view controller in your dealloc method if you’re going to be maintaining it as an ivar.

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

Sidebar

Related Questions

I've been trying to push an item to an associative array like this: $new_input['name']
I'm trying to push a new view on my navigation controller using: -(IBAction)switchPage:(id)sender {
I'm trying to push something to my current navigation controller, but it's not going.
I am trying to push a view controller from inside a callback block. The
Trying to push first_app to heroku. Starts out looking like it's working OK, but
I am getting this error when I am trying to push to the Heroku
I am trying to push in a new view controller with the code: [self.navigationController
So I'm trying to push a file to GitHub and I'm getting this error:
I'm trying to push my code into github, but almost everytime I meet this
I've been trying to get OpenGL-ES to do something roughly like the following to

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.