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 08-12-2010, 04:05 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 51
Dan the Man is on a distinguished road
Send a message via Yahoo to Dan the Man Send a message via Skype™ to Dan the Man
Default tableView didSelectAtRowIndex:?

hello I'm am trying to do 2 things.
I have a Table View and when i click on a cell how can I:
1. get the cell number and alert it in a UIAlertView
2. push the view to the left, to go to a detail View?
Dan the Man is offline   Reply With Quote
Old 08-12-2010, 05:29 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Quote:
Originally Posted by Dan the Man View Post
hello I'm am trying to do 2 things.
I have a Table View and when i click on a cell how can I:
1. get the cell number and alert it in a UIAlertView
2. push the view to the left, to go to a detail View?
didSelectRowAtIndex passes in an IndexPath. it has two properties row and section. If you only have one section then the row is the row.

TableViews work with NavigationControllers, when someone selects the row, you create a new viewController and push it onto the nav controller's viewController's stack.

Hope that helps explain it.

Code:
-(void)didSelectRowAtIndexPath:(IndexPath *)indexPath {
    int row = [indexPath row];
    [someMethodToShowAlert:row];
    MyViewController *detailView =[[MyViewController alloc] init…..]
    [detailView setDataToPass:dataToPass];
    [navController pushViewController:detailView];
    [detailView release];
}
Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Old 08-13-2010, 02:20 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 51
Dan the Man is on a distinguished road
Send a message via Yahoo to Dan the Man Send a message via Skype™ to Dan the Man
Default

Um... I tried that but, it doesn't want to write the...
Code:
[indexPath row]
...into the alert view. How do I do that?
Dan the Man is offline   Reply With Quote
Old 08-13-2010, 02:52 PM   #4 (permalink)
CAM
Registered Member
 
Join Date: Feb 2009
Posts: 157
CAM is on a distinguished road
Default

Put this in the alertview code
Code:
[NSString stringWithFormat:@"Selected Row is %d",indexPath.row];
CAM is offline   Reply With Quote
Old 08-13-2010, 03:03 PM   #5 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 51
Dan the Man is on a distinguished road
Send a message via Yahoo to Dan the Man Send a message via Skype™ to Dan the Man
Default

All right cool , it works. But how do I make it work between multiple sections?
Dan the Man is offline   Reply With Quote
Old 08-13-2010, 05:03 PM   #6 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Quote:
Originally Posted by Dan the Man View Post
All right cool , it works. But how do I make it work between multiple sections?
Usually with multiple section you have an NSDictionary to hold the data. Each key is a section. You can get an array of keys from the NSDictionary. The get the key at index from the NSArray objectAtIndex method, passing in the [indexPath section] value. Then you get the values out of the Dictionary under that key. That is usually an NSArray. So in that last NSArray get objectAtIndex [indexPath row]

Now you have the data for that particular row.

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Reply

Bookmarks

Tags
cell, detail view, table view

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: 351
5 members and 346 guests
bignoggins, Chickenrig, givensur, linkmx, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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