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 04-08-2011, 03:57 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 18
MSP4444 is on a distinguished road
Lightbulb Loading different view controllers from a table view...

Evening all!

Loading a new view controller from a table view controller has never been an issue for me due to its simplicity. However, I'm now attempting to load different view controllers when the user taps a different cell within the table view.

For example...

Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

DetailViewController *newView = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
    [self.navigationController pushViewController:newView  animated:YES];

}
Obviously, this will load the 'DetailViewController' when any cell pressed. So, does anyone have any idea how to modify this to load a completely different view controller depending on the title of the cell?
MSP4444 is offline   Reply With Quote
Old 04-08-2011, 03:58 PM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

with indexPath.row you have the row number, use that.
__________________
dany_dev is offline   Reply With Quote
Old 04-08-2011, 04:12 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 18
MSP4444 is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
with indexPath.row you have the row number, use that.
Sorry, I'm not that experienced to be blatantly honest. I see what you're suggesting to define between the cells but I'm not quite sure how to write this up.
MSP4444 is offline   Reply With Quote
Old 04-08-2011, 04:16 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default

Code:
switch (indexPath.row)
{
    case 0:
        //load view controller 1
        break;
    case 1:
        //load view controller 2
        break;
    default:
        break;
}
architectpianist is offline   Reply With Quote
Old 04-08-2011, 04:18 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 18
MSP4444 is on a distinguished road
Default

Ahh I get you. Thanks a lot!
MSP4444 is offline   Reply With Quote
Old 04-08-2011, 04:28 PM   #6 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 18
MSP4444 is on a distinguished road
Default

Quote:
Originally Posted by architectpianist View Post
Code:
switch (indexPath.row)
{
    case 0:
        //load view controller 1
        break;
    case 1:
        //load view controller 2
        break;
    default:
        break;
}
Perfect! That's exactly what I wanted, thanks a million!
MSP4444 is offline   Reply With Quote
Reply

Bookmarks

Tags
load, table view, view controller

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: 357
13 members and 344 guests
dansparrow, dre, ilmman, LezB44, michelle, Nobbsy, Objective Zero, samdanielblr, Sami Gh, shagor012, sledzeppelin, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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