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 11-01-2009, 01:36 AM   #1 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
chuck is on a distinguished road
Default UITableView won't refresh after reloadData

I'm making an app which will shuffle cards and then display them in a table view. I want to provide a refresh button in the navigation bar, so that users can update the list with a new set of shuffled cards. I started the project with the Utility Application template and have put pretty much all of the logic of the app in the MainViewController.m file which I plan to refactor out later into individual object files.

When I click Refresh, it runs the refresh action which shuffles the cards and then runs [self.tableView reloadData] and even accesses
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
for each table row since I have it print out an NSLog statement each time this is run. It even changes the textLabel.text of each cell which I've also verified with an NSLog statement right after changing it.

I've tried [self.tableView setNeedsDisplay] and [self.view setNeedsDisplay] and nothing will refresh the screen! I've looked around different forums and can't see any solution to this. Could anyone please push me in the right direction?
__________________
German Course: Learn German anywhere! Chess Player: Study Chess anywhere!
chuck is offline   Reply With Quote
Old 11-01-2009, 05:33 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 22
al31 is on a distinguished road
Default

Maybe the problem IS the cellForRowAtIndexPath method. Check your creation/release of the TableViewCell, maybe the error is in there. Start with a simple cellForRowAtIndexPath method then add your addSubview calls or whatever.
al31 is offline   Reply With Quote
Old 11-01-2009, 08:30 AM   #3 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
chuck is on a distinguished road
Default

Quote:
Originally Posted by al31 View Post
Maybe the problem IS the cellForRowAtIndexPath method. Check your creation/release of the TableViewCell, maybe the error is in there. Start with a simple cellForRowAtIndexPath method then add your addSubview calls or whatever.
Thanks for the advice, but I don't think that can possibly be the issue, because I just use the boilerplate method for that:

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	
    static NSString *CellIdentifier = @"MenuItem";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
	
	NSUInteger row = [indexPath row];
	cell.textLabel.text = [playCards objectAtIndex:row];
	NSLog( @"Card: %@", cell.textLabel.text );
	
    return cell;
}
__________________
German Course: Learn German anywhere! Chess Player: Study Chess anywhere!
chuck is offline   Reply With Quote
Old 11-03-2009, 12:18 AM   #4 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 149
Brix is on a distinguished road
Default

Will you be able to send us your program, because "reloadData" should be enough to refresh your tableView, there's no need for setNeedsDisplay or other. I have tried it a couple of times now and it is working for me.
__________________
Praise be to God
Brix is offline   Reply With Quote
Old 11-03-2009, 12:01 PM   #5 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
chuck is on a distinguished road
Default

So, it's always the stupid stuff, right? I discovered that my main view was also a UITableView, so I had two table views on top of each other! No wonder it didn't work. Anyway, thanks for trying to help, there's no way you could've figured that out.
__________________
German Course: Learn German anywhere! Chess Player: Study Chess anywhere!
chuck is offline   Reply With Quote
Old 07-06-2010, 05:47 AM   #6 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 14
manowar is on a distinguished road
Default

same problem here...
manowar is offline   Reply With Quote
Old 10-30-2010, 02:21 AM   #7 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 1
sk92129 is on a distinguished road
Default

Quote:
Originally Posted by manowar View Post
same problem here...
Did the UITableView reload correctly in the simulator? I am using 3.1.3 jailbroken iphone. Mine UITableView reloads in the simulator. But it does not reload in the real iphone.

Any ideas?
sk92129 is offline   Reply With Quote
Old 01-26-2011, 12:58 PM   #8 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 1
bwestcott is on a distinguished road
Default UITableView won't refresh

If you are making the change in cellForRowAtIndexPath, then perhaps the call:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

is not returning nil (i.e. the cell already exists), in which case the code making the mod will not be executed
bwestcott is offline   Reply With Quote
Reply

Bookmarks

Tags
refresh, reloaddata, setneedsdisplay, 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: 345
10 members and 335 guests
alexP, ClerurcifeDer, Duncan C, givensur, glenn_sayers, guusleijsten, JmayLive, Punkjumper, whitey99, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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