I know there has to be a simple solution for this. I want to get my tableView to update every time that viewWillAppear would run. How do I call it from within the viewWillAppear method, and get it to run as often as it needs to?
You could try using [tableView reloadData].
[self.tableview reloadData];
use it
use
[yourTableView reloadData];
Just reload the table.
Just put this line in viewWillAppear:
[tableView reloadData];
reloadData: Reloads the rows and sections of the receiver.
-Courtesy : Apple Documentation.
Related
in my iphone app i am adding data to table view on click of button but its not getting updated.It ll update only if i reopen the app.
Use [yourTableView reloadData] to tell the tableview to reload its data and be updated.
Use the [tableView reloadData] method on button click after updating the table view's data source.
So something like this:
-(IBAction) buttonPressed:(id)sender
{
// Update data source of table first
[tableView reloadData]
}
Also check this out: UITableView reload data
try [tableview reloadData]
in wiewWillApear method
Preview Controller to reload its data from its data source.
- (void) reloadData
The display is recomputed only if the current preview item has changed.
Im using a NSFetchedResultsController in my UITableView and in the
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
and
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
i have a call to beginUpdates/endUpdates per apples docs. The problem is it seems that every time it makes this call it resets the table position to the top. Any ideas why its doing this and if there is a way to avoid the table position reset?
thx
Instead of beginUpdates/endUpdates, can't you just call [myTableView reloadData];? Maybe there's something I'm not getting...
You can save the indexPath of the current row for example
NSIndexPath *pastIP=[NSIndexPath indexPathForRow:0 inSection:0]
and after update
[tableView selectRowAtIndexPath:pastIP animated:YES scrollPosition:UITableViewScrollPositionTop];
I am developing an app in which I have to delete the contacts from table ,problem is that when i delete one contact ,I have switch from one view to another then I can see the changing b/c i put the reload method in viewAppear any suggestion?
In general you should avoid to use reloadData to refresh the content of a UITableView, you should only do it if you can't avoid it (ie you replace everything in your table) or the user won't see it (ie in viewWillAppear).
I would suggest to use insertRowsAtIndexPaths:withRowAnimation: to insert single rows and deleteRowsAtIndexPaths:withRowAnimation: to remove rows.
So you get the indexPath of the row when you delete a contact and call [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:deletedIndexPath] withRowAnimation:UITableViewRowAnimationFade]
Those details make the difference between a app and a good app.
you can call [self.tableView reloadData]; to reload the table view by staying on the current view.
You can immediately reload table after deleting the contact !
Just call [self.tableView reloadData] in the UITableViewController after the data has been modified. This will update the table view to and reflect the new state of the data.
Sometimes tiny looking problem is ignored to handle in the last but you never know that will become nightmare for you, happening with me.
Thanks in advance, problem my app's settings page contains tableView and every setting element is one of the view. One of the setting item (row) offers show expands a few list of items in another listTableView. After making a selection in listTableView when i come back to my settings tableView using navigationItem.leftButton (Back), selected item value overlaps the previous item's value, in the sense [tableView reloadData] in viewWillAppear works fine but tableView rows are not fresh drawn. It doesn't refresh the cell's UI.
Note that if settingTableView has any subview like UIButton etc it has the latest value, i can use that as workaround but the only problem is when is select this row again Selection has old value that overlaps new value on selecting the row.
I will appreciate any suggestion or sample code using will be great help.
Thanks a ton
Amit Singh
Use [tableView reloadData]; in your viewWillAppear method.
or use [tableView reloadData]; in viewDidAppear method
The problem you are facing is perhaps due to portion of cell that is reusable and the one that is not reused. Check out the code you are writing inside the block of
if(cell==nil){}
components you have created inside block will not get recreated and others might be recreating causing the overlapping on the cell.
In my case, I had to use [self.tableView reloadData]; rather than [tableView reloadData]; in the viewWillAppear method.
I am trying to do something interesting.
I am pulling some JSON data and populating cells in a UITableView. How can I make the UITableView scroll ever second or so? I want to give the effect that as new data is coming in, the table is scrolling, so it is streaming.
Any ideas?
Yes, use scrollToRowAtIndexPath:atScrollPosition:animated:.
You could also use UIScrollView's scrollRectToVisible:animated: if you want to have more finegrained control and can calculate exactly what your scroll position should be in pixels. (UITableView is subclass of UIScrollView.)
But if you are just adding cells, sounds like you could also just use insertRowsAtIndexPaths:withRowAnimation:, this is also "interesting."
Just do this
[table reloadData];
NSIndexPath *myIP = [NSIndexPath indexPathForRow:[arrayIn count]-1 inSection:0] ;
[table scrollToRowAtIndexPath:myIP atScrollPosition:NULL animated:YES];
in anywhere where arrayIn is your array by which your table populate.
you can use uitableviews scrollToRowAtIndexPath to do this....heres a link reference
You can call this method whenever as youd like to scroll your tableview
And you can call performSelector:withObject:afterDelay: for the timer effect - although if you are really pulling in data every second, it's best to just reloadData as you go.