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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:20:51+00:00 2026-05-23T21:20:51+00:00

I would like to know how can I load a new nib file after

  • 0

I would like to know how can I load a new nib file after finishing with UIImagePicker Controller. So after the user takes a picture from the camera or albums, i would like to load a new nib for the user to do some editing. Below is the didFinishPickingMediaWithInfo. I can load an image to the current UIImageView or even send out and alertview, but even if I tried loading a new nib, it just goes back to currentview nib and no errors. Bear in mind that I’m a total ios noob, so if the method use is wrong, please let me know. Thanks in advance.

p.s. Just to add, even if I manage to load new nib, how do I pass the information from the previous nib? E.g. if I choose an image from nib2, how to pass it to nib3?

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info   {
imageOverlay.image = [UIImage imageNamed:@"mask_overlay1.png"];
[imageOverlay release];

// Displaying image to the imageView
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

// Tried to load a new nib
UIView *currentView = self.view;

// Get the underlying UIWindow, or the view containing the current view.
UIView *theWindow = [currentView superview];


//remove the current view and replace with myView1
[currentView removeFromSuperview];

// 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:@"createPhotoView"];

}
  • 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-23T21:20:51+00:00Added an answer on May 23, 2026 at 9:20 pm

    I have no idea what your app’s workflow is like, but if you need to display a new view after an image is chosen, you should probably do it by either pushing a new view controller on to a navigation controller, or by presenting it as a modal view.
    This allows you to easily return to the previous screen where you were asked to pick a photo.

    Let’s say that for your app, you decide to use a UINavigationController.

    You would initialize a navigation controller with your first view controller as the root view controller.

    Then, in your UIImagePicker delegate method, you would have something like this:

    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    
        // Initialize your new view controller
        CustomViewController *controller = [[CustomViewController alloc] initWithNibName:@"SecondView" bundle:nil];
    
        // Pass your custom view controller the image you just selected
        controller.valueToPass = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    
        [self.navigationController pushViewController:controller animated:YES];
    
        [controller release];
    
    }
    

    You create a subclass of UIViewController called CustomViewController, and pass it values by creating properties you can assign to (like valueToPass in my example).

    EDIT:

    It is possible to just switch the visible view of a view controller. It is as simple as changing the value of self.view. You could put two UIViews in the same XIB file, and put IBOutlets for both in your controller. You could have a header that looks like this:

    @interface MyController : UIViewController {
    
        IBOutlet UIView *view1;
    
        IBOutlet UIView *view2;
    
    }
    
    // Follow this with properties for all of those IBOutlets as well
    

    Then, in your controller code:

    - (IBAction)switchViews {
    
        if ([self.view isEqualTo:view1]) {
            self.view = view2;
        } else {
            self.view = view1;
        }
    
    }
    

    This works, but as far as I am aware, does not allow transitions. You could instead do this:

    - (IBAction)switchViews:(id)sender {
    
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
    
        if ([[secondaryView superview] isEqual:mainView]) {
            [secondaryView removeFromSuperview];
        } else {
            [self.view addSubview:secondaryView];
        }
    
        [UIView commitAnimations];
    
    }
    

    Both of these options work, and allow you to use the same view controller to control both views. However, if the views perform different tasks, they should be associated with different controllers. Using different controllers is similar if you set up a controller as a property in your header:

    - (IBAction)switchViews:(id)sender {
    
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
    
        if (self.secondaryController) {
            [self.secondaryController.view removeFromSuperview];
            self.secondaryController = nil;
        } else {
            self.secondaryController = [[SecondaryController alloc] initWithNibName:@"SecondView" bundle:nil];
            self.secondaryController.valueToPass = @"I am passing this value!";
            [self.view addSubview:self.secondaryController.view];
        }
    
        [UIView commitAnimations];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Android programming. I would like to know if I can load
I would like to know where can I find the code which eclipse uses
I would like to know how Can I paas Page as Ref Parameter to
I would like to know if I can open 2 different diagrams using MS
I would like to know if I can install say Visual Studio 2008 Pro
I would like to know how I can refer to a list item object
I have a generator and I would like to know if I can use
I'm using SQL Server 2005 and would like to know how I can get
I would like to know which one is the best material that I can
I would like to know if there are any tools that can help me

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.