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 07-17-2010, 06:41 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Canada
Age: 26
Posts: 51
zenox is on a distinguished road
Default UITableView didSelectRowAtIndexPath position in view?

I am handling the didSelectRowAtIndexPath and getting the cell. I am trying to figure out its location on the screen. Using the following code:

- (void)tableViewUITableView *)aTableView didSelectRowAtIndexPathNSIndexPath *)indexPath
{
UITableViewCell * cell = [aTableView cellForRowAtIndexPath: indexPath];

CGRect location = cell.frame;
}

The location however is the cells location in the tableview, not the location in the visible region. Is there anyway I can map this back to the visible region?
zenox is offline   Reply With Quote
Old 07-17-2010, 07:09 AM   #2 (permalink)
r_l
Registered Member
 
Join Date: Jul 2010
Posts: 19
r_l is on a distinguished road
Default

UITableView has a method 'indexPathsForVisibleRows' that returns an array of index paths of visible rows, or 'visibleCells' that returns array of visible table cells. Visit UITableView class reference at apple website. UITableView Class Reference
r_l is offline   Reply With Quote
Old 07-17-2010, 07:13 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Canada
Age: 26
Posts: 51
zenox is on a distinguished road
Default

Quote:
Originally Posted by r_l View Post
UITableView has a method 'indexPathsForVisibleRows' that returns an array of index paths of visible rows, or 'visibleCells' that returns array of visible table cells. Visit UITableView class reference at apple website. UITableView Class Reference
Thanks but I think you may have misunderstood. Rather than looking for the visible cells, im looking for the onscreen position of a cell.
zenox is offline   Reply With Quote
Old 07-17-2010, 07:35 AM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Boston, MA
Posts: 135
carbonbasednerd is on a distinguished road
Default

Quote:
Originally Posted by zenox View Post
I am handling the didSelectRowAtIndexPath and getting the cell. I am trying to figure out its location on the screen. Using the following code:

- (void)tableViewUITableView *)aTableView didSelectRowAtIndexPathNSIndexPath *)indexPath
{
UITableViewCell * cell = [aTableView cellForRowAtIndexPath: indexPath];

CGRect location = cell.frame;
}

The location however is the cells location in the tableview, not the location in the visible region. Is there anyway I can map this back to the visible region?
I don't think there is a quick way to do it. You will have to access the parent views and calculate your own offset I think.
carbonbasednerd is offline   Reply With Quote
Old 07-17-2010, 07:36 AM   #5 (permalink)
r_l
Registered Member
 
Join Date: Jul 2010
Posts: 19
r_l is on a distinguished road
Default

Quote:
Originally Posted by zenox View Post
Thanks but I think you may have misunderstood. Rather than looking for the visible cells, im looking for the onscreen position of a cell.
The zeroth cell in the array returned by visibleCells will be at the first position on the screen. Is this something u r referring as 'onscreen' position?
r_l is offline   Reply With Quote
Old 07-17-2010, 07:48 AM   #6 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Boston, MA
Posts: 135
carbonbasednerd is on a distinguished road
Default

Quote:
Originally Posted by r_l View Post
The zeroth cell in the array returned by visibleCells will be at the first position on the screen. Is this something u r referring as 'onscreen' position?
I think it is more a question of getting the absolute location of an object versus the relative location.
carbonbasednerd is offline   Reply With Quote
Old 07-17-2010, 07:49 AM   #7 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Canada
Age: 26
Posts: 51
zenox is on a distinguished road
Default

Quote:
Originally Posted by r_l View Post
The zeroth cell in the array returned by visibleCells will be at the first position on the screen. Is this something u r referring as 'onscreen' position?
Thats a good point. I was thinking there may of been a built in way of calculating it, but based off the zeroth visible cell should work perfect. Thanks!
zenox is offline   Reply With Quote
Old 08-18-2010, 09:37 AM   #8 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 1
gglagrue is on a distinguished road
Default

I used :

- (void)tableViewUITableView *)aTableView didSelectRowAtIndexPathNSIndexPath *)indexPath
{
CGRect location = [tableView rectForRowAtIndexPath:indexPath];
}

@+
gglagrue is offline   Reply With Quote
Reply

Bookmarks

Tags
uitableview

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: 330
14 members and 316 guests
akphyo, alexP, appservice, bignoggins, EXOPTENDAELAX, flamingliquid, guusleijsten, Hamad, mariano_donati, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

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