Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JoshAK

macrumors newbie
Original poster
Aug 12, 2008
19
0
I'm working on a simple app that uses a <UITabBarDelegate> and int value.

When the user clicks a button I want to change the value using "++value" and then refresh my view with an if ( value == x). Everything works except I'm unable to refresh or reload the view data. Please help.

I've got this one fixed. Thanks anyway.
 

sergio27

macrumors member
Nov 2, 2008
35
1
Hi. Good to hear you found your answer. Would you share what you did?

I'm having a similar problem, and I think the solution may be the same. I'm trying to refresh the content on a TableView when I click a button, but when I call the reloadData method nothing happens.
 

JoshAK

macrumors newbie
Original poster
Aug 12, 2008
19
0
Refresh Table View?

sergio27,

I was trying to refresh a UIView not a UITableView. Can you post your
-(void)buttonAction{
Data To Refresh
}

I'll take a look at it. Also, why are you trying to refresh a table view? Is it due to added or deleted table rows? Or new downloaded data source? I need to know more in order to help. Thanks.
 

sergio27

macrumors member
Nov 2, 2008
35
1
Thanks for your interest, Josh. I had not been able to reply until now.

I have a Text Field, a Button and a Table View. I want the user to write something in the Text Field, click on the Button, and the content of the Text Field to be added to the Table View.

This is the button method:

-(IBAction)add:(id)sender {
EstadosAppDelegate *appDelegate = (EstadosAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.states addObject:textInput.text];
[tableView reloadData];
[button setTitle:mad:"Added" forState:UIControlStateNormal];
}

The title of the button is changed to " Added", but the Table View data is not realoaded. The Table View data is correctly linked to the "states" array. Using the same instructions on the didSelectRowAtIndexPath, the data is reloaded.

I hope you can help me. Thank you.
 

russellelly

macrumors regular
Jun 23, 2006
139
41
Glasgow, UK
Thanks for your interest, Josh. I had not been able to reply until now.

I have a Text Field, a Button and a Table View. I want the user to write something in the Text Field, click on the Button, and the content of the Text Field to be added to the Table View.

This is the button method:

-(IBAction)add:(id)sender {
EstadosAppDelegate *appDelegate = (EstadosAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.states addObject:textInput.text];
[tableView reloadData];
[button setTitle:mad:"Added" forState:UIControlStateNormal];
}

The title of the button is changed to " Added", but the Table View data is not realoaded. The Table View data is correctly linked to the "states" array. Using the same instructions on the didSelectRowAtIndexPath, the data is reloaded.

I hope you can help me. Thank you.

I don't have an answer, as I'm having a similar issue, but the API for reloadData states: "the table view redisplays only those rows that are visible" ... "It should not be called in the methods that insert or delete rows,". So I don't think that's the correct call to make.

– insertRowsAtIndexPaths:withRowAnimation:
– insertSections:withRowAnimation:
– deleteRowsAtIndexPaths:withRowAnimation:
– deleteSections:withRowAnimation:

may be more appropriate? They're not enough for my needs, as I want to be able to reload all the local state in the TableView (which is loaded from a sqlite DB) on certain events.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.