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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:11:46+00:00 2026-06-09T17:11:46+00:00

I have a split view controller for iPad with a drill-down table on the

  • 0

I have a split view controller for iPad with a drill-down table on the left. I am able to populate the tables with a drill-down without issue but I cannot seem to get the item I clicked within the UITableView on the left side to show up in detailDescriptionLabel on the right side.

I have the following code in my ProductViewController.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];

NSLog(@"Row clicked: %i", indexPath.row);

if (_delegate != nil) {
    Product *product = (Product *) [_products objectAtIndex:indexPath.row];
    [_delegate productSelectionChanged:product];
}

DetailedVC *detailView = [[DetailedVC alloc] initWithNibName:@"DetailedVC" bundle:[NSBundle mainBundle]];
NSLog(@"User clicked on: %@", [NSString stringWithFormat:@"%d",indexPath.row]);
detailView.detailDescriptionLabel.text = [NSString stringWithFormat:@"%d",indexPath.row];
[self.navigationController pushViewController:detailView animated:YES];
}

What happens here is I push the DetailedVC into the left side where my table view is and what I really want to do is see the row clicked updated in my detailed view on the right. I am able to see in the Log window that I clicked on a certain index so I know I am capturing the click event and getting a value.

Inside my DetailedVC.m I have the following code to update this label.

- (void)viewDidLoad
{
[super viewDidLoad];
[self configureView];
}

- (void) configureView {

if (self.detailItem) {

    self.detailDescriptionLabel.text = [self.detailItem description];

    NSLog(@"Item: %@", [self.detailItem description]);
}
}

If I edit the viewDidLoad I get a (null) for the [self.detailItem description]

- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Detail description label: %@", [self.detailItem description]);
}

ProductViewController.h

@interface ProductViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {

NSMutableArray *_products;
UITableView *_productsTableView;
id<ProductSelectionDelegate> _delegate;
}

@property (nonatomic, strong) IBOutlet UITableView *productsTableView;
@property (nonatomic, retain) NSMutableArray *products;
@property (nonatomic, assign) id<ProductSelectionDelegate> delegate;

@end

AppDelegate.h

@class ProductViewController;
@class DetailedVC;

@interface TabAndSplitAppAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
ProductViewController *_productViewController;
DetailedVC *_detailedViewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) IBOutlet ProductViewController *productViewController;
@property (nonatomic, retain) IBOutlet DetailedVC *detailedViewController;

@end

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

NSMutableArray *products = [NSMutableArray array];
[products addObject:[[Product alloc] initWithName:@"Product 1 Name" desc:@"Product 1 Description"]];
_detailedViewController.product = [products objectAtIndex:0];

// Override point for customization after app launch.
//create split view controller
RootVC *rvc=[[RootVC alloc] init];
rvc.title=@"Root VC";
DetailedVC *dvc=[[DetailedVC alloc] init];
dvc.title=@"Detailed VC";
_productViewController.delegate = _detailedViewController;

MySplitViewController *msc = [[MySplitViewController alloc] initwithLeftVC:rvc rightVC:dvc];
msc.title=@"First";
//create a temporary VC to show in second tab
SecondViewController *vc2 = [[SecondViewController alloc] init];
vc2.title=@"Second";

//make an array containing these two view controllers
NSArray *viewControllers = [NSArray arrayWithObjects:msc,vc2,nil];
[tabBarController setViewControllers:viewControllers];
tabBarController.view.backgroundColor=[UIColor blackColor];

for(UITabBarItem*t in tabBarController.tabBar.items)
{
    t.image=[UIImage imageNamed:@"icon.png"];
    t.badgeValue=[NSString stringWithFormat:@"%d",([tabBarController.tabBar.items indexOfObject:t]+1)];
}

//the views are retained their new owners, so we can release
[rvc release];
[dvc release];
[msc release];
[vc2 release];

// Add the tab bar controller's current view as a subview of the window
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];

return YES;
}

MySplitViewController.h

#import <UIKit/UIKit.h>

@interface MySplitViewController : UIViewController
{
UINavigationController *leftController;
UINavigationController *rightController;
}

@property (nonatomic, retain) UINavigationController *leftController;
@property (nonatomic, retain) UINavigationController *rightController;

- (void)layoutViews:(UIInterfaceOrientation)orientation initialVerticalOffset:(float)offset;

- (MySplitViewController*) initwithLeftVC:(UIViewController*)leftvc rightVC:(UIViewController*)rightvc;
@end

MySplitViewController.m

- (MySplitViewController*) initwithLeftVC:(UIViewController*)leftvc rightVC:(UIViewController*)rightvc
{
if(self=[super init])
{
    UINavigationController *lnc=[[UINavigationController alloc] initWithRootViewController:leftvc];
    lnc.navigationBarHidden=NO;
    self.leftController=lnc;
    [lnc release];

    UINavigationController *rnc=[[UINavigationController alloc] initWithRootViewController:rightvc];
    rnc.navigationBarHidden=NO;
    self.rightController=rnc;
    [rnc release];
}
return self;
}

Product.h

#import <Foundation/Foundation.h>

@interface Product : NSObject {

NSString *_productID;
NSString *_productDescription;
}

@property (nonatomic, copy) NSString *productID;
@property (nonatomic, copy) NSString *productDescription;

- (Product *)initWithName:(NSString *)productID desc:(NSString *)productDescription;

@end

Product.m

#import "Product.h"

@implementation Product

@synthesize productID = _productID;
@synthesize productDescription = _productDescription;

- (Product *)initWithName:(NSString *)productID desc:(NSString *)productDescription {

if ((self = [super init])) {

    self.productID = productID;
    self.productDescription = productDescription;
}

return self;
}

@end
  • 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-09T17:11:48+00:00Added an answer on June 9, 2026 at 5:11 pm

    Ok, please try this in ProductViewController:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
      [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
      NSLog(@"Row clicked: %i", indexPath.row);
    
      Product *product = (Product *) [_products objectAtIndex:indexPath.row];
      NSLog(@"Product: %@", product);
    
      TabAndSplitAppAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
      NSLog(@"appDelegate: %@", appDelegate);
      UITabBarController *tbc = appDelegate.tabBarController;
      NSLog(@"tbc: %@", tbc);
      MySplitViewController *msvc = tbc.selectedViewController;
      NSLog(@"msvc: %@", msvc);
      UINavigationController *rnc = msvc.rightController;
      NSLog(@"rnc: %@", rnc);
      DetailedVC *dvc = rnc.topViewController;
      NSLog(@"dvc: %@", dvc);
    
      dvc.detailDescriptionLabel.text = @"We found our DetailedVC";
    
      [dvc productSelectionChanged:product];
    }
    

    This code is not an example of how you should structure your program properly. This was just to help me (and you) understand your view controller hierarchy.

    The initial idea of notifying a delegate when a product is selected is spot on, it just didn’t work in your case because the objects weren’t wired up properly. You should try to do that though. In the code you posted, I don’t see a location where both the ProductViewControllerand the DetailedVC are both directly visible so that you could just say

    productViewControllerInstance.delegate = detailedVCinstance;
    

    The nearest to that is in AppDelegate where you have the RootVC instance rvcthat presumably eventually will create the ProductViewController and the dvc. Maybe you could give the dvcto the rvcso that it can set it as the ProductViewController‘s delegate when it’s created. Good luck!

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

Sidebar

Related Questions

I have a split view controller for iPad with a drill-down table on the
I am working on an iPad app with a split view controller. I have
I have a split view controller in my Ipad app, in which the detail
I have a split View Controller iPad app. Its a port of a iPhone
I have to create a list of list using split view controller in IPad,
I have an iPad app with split view controller. I want to programmaticaly create
I have a split view controller-based iPad app that uses a Web View to
I have an app that I just got setup with a split view controller
I have a tab bar controller in the master view of a split view
I am creating a split view ipad app. I have four buttons in the

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.