Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-23-2011, 03:02 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 8
Shake0615 is on a distinguished road
Default UITableView Switch Views

iPhone UITableView Tutorial: Grouped Table Blog : Mobisoft Infotech

I've been following Mobisoft's tutorial on how to build a grouped UITableView (link above), but they stop the tutorial without explaining how to change views. They show you how to make a UIAlertView pop up when a certain cell is pressed by using the following code:

Code:
- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	NSArray *listData =[self.tableContents objectForKey:[self.sortedKeys objectAtIndex:[indexPath section]]];
	NSUInteger row = [indexPath row];
	NSString *rowValue =[listData objectAtIndex:row];
    NSLog(rowValue);
	NSString *message = [[NSString alloc] initWithFormat:rowValue];
	UIAlertView *alert = [[UIAlertView alloc] 
						  initWithTitle:@"You selected" 
						  message:message delegate:nil 
						  cancelButtonTitle:@"OK" 
						  otherButtonTitles:nil];
	[alert show];
	
	[alert release];
	[message release];	
	[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Could anyone help me figure out how to switch views by using this tutorial?
Shake0615 is offline   Reply With Quote
Old 01-23-2011, 03:08 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

They can't tell you that because it depends on the structure of your app. There are many ways to switch a view, like pushing a new view onto the navigation stack in a navigation based app, switching with the tab bar, presenting it as a modal view controller etc.
baja_yu is offline   Reply With Quote
Old 01-23-2011, 03:23 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 8
Shake0615 is on a distinguished road
Default

Well, I'd like to push a view onto the navigation stack. I've used the following code in another tableview app that did not have any sections and it worked great:

Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSUInteger row = [indexPath row];
	SecondLevelViewController *nextController = [self.controllers objectAtIndex:row];
	[self.navigationController pushViewController:nextController animated:YES];
	[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
//The secondviewcontroller is subclassed in all of the subsequent views
//The controllers array contains all the information about the subsequent view controllers that will be shown (nib files, navigation bar title, etc).
But when I use this in a sectioned/grouped tableview app, it returns the same thing for rows in different sections, i.e. rows 1 in sections 0,1 and 2 return the same thing.

I don't know how to make this work so that every single row, no matter the section shows will display a different view.

I suppose what I need some argument akin to the following line to return both row AND section number:

Code:
SecondLevelViewController *nextController = [self.controllers objectAtIndex:row];
But I don't know how to do that.
Shake0615 is offline   Reply With Quote
Reply

Bookmarks

Tags
switch, uinavigation, uitableview, views

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 364
11 members and 353 guests
7twenty7, Clouds, dre, iAppDeveloper, jeroenkeij, Mah6447, Morrisone, sacha1996, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,899
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:42 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0