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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 03-17-2010, 12:55 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 135
Default Duplicate a UITableViewCell

Hi everyone, I would like to create an effect to a cell of a UITableView. The effect is: duplicate the cell and move the duplicated cell (the original stays at its place). My problem is to duplicate the cell...

I've tried:

Code:
UITableViewCell *animatedCell = [[UITableViewCell alloc] init];
animatedCell = [[self cellForRowAtIndexPath:indexPath] copy];
but UIView doesn't seem to implement the copy... How can I do it?

Thanks
ncohen is offline   Reply With Quote
Old 03-17-2010, 04:44 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 63
Default

Quote:
Originally Posted by ncohen View Post
Hi everyone, I would like to create an effect to a cell of a UITableView. The effect is: duplicate the cell and move the duplicated cell (the original stays at its place). My problem is to duplicate the cell...

I've tried:

Code:
UITableViewCell *animatedCell = [[UITableViewCell alloc] init];
animatedCell = [[self cellForRowAtIndexPath:indexPath] copy];
but UIView doesn't seem to implement the copy... How can I do it?

Thanks
You do create a duplicated cell but you did not integrate it into your tableview
firearasi is offline   Reply With Quote
Old 03-17-2010, 08:49 PM   #3 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 4,814
Default Don't try to do it this way

Quote:
Originally Posted by ncohen View Post
Hi everyone, I would like to create an effect to a cell of a UITableView. The effect is: duplicate the cell and move the duplicated cell (the original stays at its place). My problem is to duplicate the cell...

I've tried:

Code:
UITableViewCell *animatedCell = [[UITableViewCell alloc] init];
animatedCell = [[self cellForRowAtIndexPath:indexPath] copy];
but UIView doesn't seem to implement the copy... How can I do it?

Thanks
You shouldn't try to manipulate the cells in a table view directly. That's not how it works.

What you do is to tell the table view that you want to add a new cell, and let it ask your for the cell.

Instead, you should duplicate the data your data source delegate's -cellForRowAtIndexPath method uses to create the cell you want to copy, and then call insertRowsAtIndexPaths:withRowAnimation: to tell the table view that you are adding extra cells for your table view.

The table view will then call -cellForRowAtIndexPath for the cell you just created, and you create/dequeue a new cell at that point and fill it with the data you duplicated.


Regards,

Duncan C
Duncan C is offline   Reply With Quote
Reply

Bookmarks

Tags
duplicates, iphone, objective-c, uitableview, uitableviewcell

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: 266
19 members and 247 guests
2WeeksToGo, @sandris, AdamL, ADY, Dani77, diyora, F_Bryant, GHuebner, HDshot, headkaze, mer10, Oral B, prchn4christ, Rudy, smithdale87, Thompson22, timle8n1, Touchmint, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,748
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

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