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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:31:42+00:00 2026-06-08T05:31:42+00:00

I’m just starting to learn objective-C and iOS development and I’ve ran in to

  • 0

I’m just starting to learn objective-C and iOS development and I’ve ran in to some trouble with trying to migrate a iPhone app to iPad.

I’ve been reading Head First iPhone & iPad Development 2nd Edition, but chapter 7 ” migrating to iPad” is out of date as of xcode 4.2.
The app is a demonstration of how to use a splitview with a table view and detail view.
They have a MainWindow-iPad.xib auto create when changing the iOS Application Target from iPhone to Universal. But this isn’t happening for me in xcode 4.2. I have created a splitview controller programmatically in AppDelegate. Here is the code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        MasterViewController *firstVC = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
        self.secondVC = [[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil] autorelease];

       UINavigationController *firstVCnav = [[[UINavigationController alloc] initWithRootViewController:firstVC] autorelease];
        UINavigationController *secondVCnav = [[UINavigationController alloc] initWithRootViewController:self.secondVC];

       UISplitViewController *splitVC = [[UISplitViewController alloc] init];
        splitVC.viewControllers = [NSArray arrayWithObjects:firstVCnav, secondVCnav, nil];

       self.window.rootViewController= splitVC;
        [self.window makeKeyAndVisible];
        return YES;
    }else {
        MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
        self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
        self.window.rootViewController = self.navigationController;
        [self.window makeKeyAndVisible];
        return YES;
    }
}

The left side of the splitview (the table view) is perform good, but I can’t get the Right side (the detail side) to change when I select different rows on the left side. Here is the code I have in the MasterViewController class.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        AppDelegate *splitVCdetails = [[AppDelegate alloc] init];
        [splitVCdetails.secondVC drinkChanged:[self.drinks objectAtIndex:indexPath.row]];

    }else {
        if (!self.editing) {
            if (!self.detailViewController) {
                self.detailViewController = [[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil] autorelease];
            }
            self.detailViewController.drink = [self.drinks objectAtIndex:indexPath.row];
            [self.navigationController pushViewController:self.detailViewController animated:YES];
        }else {
            AddDrinkViewController *editingDrinkVC = [[AddDrinkViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
            editingDrinkVC.drink = [self.drinks objectAtIndex:indexPath.row];
            editingDrinkVC.drinkArray = self.drinks;

            UINavigationController *editingNavCon = [[UINavigationController alloc] initWithRootViewController:editingDrinkVC];

            [self.navigationController presentModalViewController:editingNavCon animated:YES];
            [editingDrinkVC release];
            [editingNavCon release];
        }
    }
}

Here is the code I have in the DetailViewController class

-(void)refreshView {
    //Set up our UI with the provided drink
    self.drinkTextLabel.text = [self.drink objectForKey:NAME_KEY];
    self.ingredientTextBox.text = [self.drink objectForKey:INGREDIENTS_KEY];
    self.directionTextBox.text = [self.drink objectForKey:DIRECTIONS_KEY];
}

-(void)drinkChanged:(NSDictionary *)newDrink {
    self.drink = newDrink;
    [self refreshView];
}

Please let me know if I need to clarify anything.

Thank you

  • 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-06-08T05:31:45+00:00Added an answer on June 8, 2026 at 5:31 am

    I’m reading “Head First iPhone and iPad Development” too. With help from KevinM’s code
    I have created a UISplitController programmatically without xib. Here is my solution.

    Here is the code I have at the beginning of AppDelegate.m:

    #import "AppDelegate.h"
    #import "MasterViewController.h"
    #import "DetailViewController.h"
    
    @implementation AppDelegate
    
    @synthesize window = _window;
    @synthesize navigationController = _navigationController;
    @synthesize splitViewController = splitViewController_;
    
    - (void)dealloc
    {
        [_window release];
        [splitViewController_ release];
        [_navigationController release];
        [super dealloc];
    }
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    
        // Override point for customization after application launch.    
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
            MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
            UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
    
            DetailViewController *detailViewController = [[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil] autorelease];
            UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
    
            masterViewController.splitViewDetailView = detailViewController;
    
            self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
            self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];
    
            self.window.rootViewController = self.splitViewController;
        }
        else {
            MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];
            self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
            self.window.rootViewController = self.navigationController;
        }
    
        [self.window makeKeyAndVisible];
        return YES;
    }
    

    Here is the code I have in the MasterViewController.m:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (!self.editing) {
            if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
                [self.splitViewDetailView drinkChanged:[self.drinks objectAtIndex:indexPath.row]];
            }
            else {
                self.detailViewController = [[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil] autorelease];
                self.detailViewController.drink = [self.drinks objectAtIndex:indexPath.row];
                [self.navigationController pushViewController:self.detailViewController animated:YES];
            }
        }
        else {
            AddDrinkViewController *editingDrinkVC = [[AddDrinkViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
            editingDrinkVC.drink = [self.drinks objectAtIndex:indexPath.row];
            editingDrinkVC.drinkArray = self.drinks;
    
            UINavigationController *editingNavCon = [[UINavigationController alloc] initWithRootViewController:editingDrinkVC];
    
            [self.navigationController presentModalViewController:editingNavCon animated:YES];
            [editingDrinkVC release];
            [editingNavCon release];
        }
    }
    

    And add code from book on page 345 (method refreshView) and page 346 (property splitViewDetailView)

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.