PDA

View Full Version : Refresh A View?




JoshAK
Dec 9, 2008, 06:21 PM
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
Dec 14, 2008, 08:10 PM
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
Dec 15, 2008, 12:50 PM
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
Dec 26, 2008, 08:47 PM
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:@"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
Dec 27, 2008, 03:22 AM
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:@"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.