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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:22:02+00:00 2026-05-21T18:22:02+00:00

My app runs fine for a while in simulator, although after a few touches,

  • 0

My app runs fine for a while in simulator, although after a few touches, it crash and burn.

Here is the code

-(IBAction)extraCrisp:(id)sender
{
    myViewController *myView = [[myViewController alloc]
                                    initWithNibName:@"myViewController"
                                    bundle:nil];
    // get the view that's currently showing
    UIView *currentView = self.view;
    // get the the underlying UIWindow, or the view containing the current view
    UIView *theWindow = [currentView superview];

    UIView *newView = myView.view;

    // remove the current view and replace with myView1
    [currentView removeFromSuperview];
    [theWindow addSubview:newView];

    // set up an animation for the transition between the views
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];
    [animation setSubtype:kCATransitionFromLeft];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
    [myView release];

}

So, what am I doing wrong here? Any help would be highly praised. Thanx

  • 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-21T18:22:03+00:00Added an answer on May 21, 2026 at 6:22 pm

    Well Andy, your code certainly tells that you are a beginner..To implement your requirement there are much cleaner and safer methods available. For a multiview application, normally everyone uses either UINavigationController or UITabBarController. In your case UINavigationController is your friend and if you can spend one hour this tutorial will get you started..I recommend you learn to use those method other than continuing with the way you are doing now…and stop reading this answer..

    OK now your code..This is the first part..

    myViewController *myView = [[myViewController alloc]
                                        initWithNibName:@"myViewController"
                                        bundle:nil];
    // get the view that's currently showing
    UIView *currentView = self.view;
    // get the the underlying UIWindow, or the view containing the current view
    UIView *theWindow = [currentView superview];
    
    UIView *newView = myView.view;
    
    // remove the current view and replace with myView1
    [currentView removeFromSuperview];
    [theWindow addSubview:newView];
    

    I rewrite your code this way..

    myViewController *myView = [[myViewController alloc]
                                            initWithNibName:@"myViewController"
                                            bundle:nil];
    UIWindow *currentWindow = [[UIApplication sharedApplication]keyWindow];
    [currentWindow addSubview:myView.view];
    

    now you are releasing myView after adding it to UIWindow. If you comment that line I think your crash will go..Normally UIViewController added to UIWindow are released in dealloc of application delegate file..

    Now your animation..

    // set up an animation for the transition between the views
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];
    [animation setSubtype:kCATransitionFromLeft];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    
    [[myView layer] addAnimation:animation forKey:@"SwitchToView1"];
    

    Again..forget this code and read up UINavigationController..You are doing everything wrong there..

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

Sidebar

Related Questions

I have an iPhone app that compiles and runs fine in the Simulator on
My app runs fine on the simulator. However, when I run it on my
I created a small Android App that runs on the Android simulator/tablet just fine..
i have developed an app that runs perfectly fine on the simulator but when
My GAE app runs fine from my computer, but when I upload it, I
We have a WinForms app that runs fine on x86, but has many third-party
This is a very weird problem. My app that runs just fine but somehow
I have the below code that links and runs fine in 32bit mode -
So this code runs in an asp.net app on Linux. The code calls one
My java / jython app runs a ‘default’ SWT main loop like this: while

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.