Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

spoolup

macrumors newbie
Original poster
Sep 1, 2010
14
0
Hey guys.
does anyone have a way to do this? or a sample?

i am trying to find a way to add another view to the master (left) side of the uisplitview.
After the second view is loaded (from a table selection), then we can select a row on this new view and update the detail view....

stuck....
 
One way would be to assign a new array of view controllers to the UISplitViewController's viewControllers property. Another way, since the master is a navigation controller, is to push a new view controller on its stack.
 
i pushed a vc on the stack with no probs.
now i can't open my url in the detailview once i select a row in the new vc.
the new vc i pushed into the stack is from another app i made that did open the url in the detail view.
what do i need to change in the didselectrow delegate?
 
Code:
detailViewController.detailItem = [[wxData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row];

I'm using an NSMutableArray to populate my tables...
 
What does your new viewController know about detailViewController and wxData? That is, are both of these non-nil when the line you supplied is executed?
 
here's the whole .m file

Code:
@implementation NewNavViewController


@synthesize detailViewController;

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


/*
 - (void)viewWillAppear:(BOOL)animated {
 [super viewWillAppear:animated];
 }
 */
/*
 - (void)viewDidAppear:(BOOL)animated {
 [super viewDidAppear:animated];
 }
 */
/*
 - (void)viewWillDisappear:(BOOL)animated {
 [super viewWillDisappear:animated];
 }
 */
/*
 - (void)viewDidDisappear:(BOOL)animated {
 [super viewDidDisappear:animated];
 }
 */

// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView {
    // Return the number of sections.
    return [wxSections count];
}


- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
	return [[wxData objectAtIndex:section] count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"CellIdentifier";
    
	// Dequeue or create a cell of the appropriate type.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
		// cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    
    // Configure the cell.
	[[cell textLabel] setText:[[[wxData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"name"]];
	// Add subview to cells
	[[cell detailTextLabel] setText:[[[wxData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"subtitle"]];
	[[cell imageView] setImage:[UIImage imageNamed:[[[wxData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"picture"]]];
	cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
	return [wxSections objectAtIndex:section];
}


- (void)createWxData {
	
	NSMutableArray *pirep;
	
	wxSections=[[NSMutableArray alloc] initWithObjects:
				@"PIREPs",nil];
	
	pirep=[[NSMutableArray alloc] init];
	
	[pirep addObject:[[NSMutableDictionary alloc]
					  initWithObjectsAndKeys:@"Alaska",@"name",@"from aviationweather.gov",@"subtitle",
					  //@".png",@"picture",
					  @"http://aviationweather.gov/adds/data/pireps/pireps_AK_TB.gif",@"url",nil]];
	
	wxData=[[NSMutableArray alloc] initWithObjects:
			pirep,nil];
	
	[pirep release]; 
}



/*
 // Override to support conditional editing of the table view.
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the specified item to be editable.
 return YES;
 }
 */


/*
 // Override to support editing the table view.
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 
 if (editingStyle == UITableViewCellEditingStyleDelete) {
 // Delete the row from the data source
 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
 }   
 else if (editingStyle == UITableViewCellEditingStyleInsert) {
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 }   
 }
 */


/*
 // Override to support rearranging the table view.
 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
 }
 */


/*
 // Override to support conditional rearranging of the table view.
 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the item to be re-orderable.
 return YES;
 }
 */

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath  {
    return 50.0;
}


#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    /*
     When a row is selected, set the detail view controller's detail item to the item associated with the selected row.
     */
	detailViewController.detailItem = 
	[[wxData objectAtIndex:indexPath.section] 
	 objectAtIndex: indexPath.row];	//detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];

}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Relinquish ownership any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
	[wxData release];
	[wxSections release];
    [detailViewController release];
    [super dealloc];
}


@end
 
.h

Code:
@class DetailViewController;

@interface NewNavViewController : UITableViewController {
    DetailViewController *detailViewController;
	NSMutableArray *wxData;
	NSMutableArray *wxSections;
}

-(void) createWxData;

@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;

@end
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.