TableView is not refreshing the first time - iphone

First of all, I'm sorry for my English, but I hope you'll understand what I wan't to ask ;)
I'm creating an Iphone-App . There is a Table-View with Subjects ( like Maths, English, etc.). When I select a row, a new TableView appears with my grades ( A, A+, etc.). In this TableView, I can add new tests.
My problem is, when I created a test in a subject and I go back to the Subject-TableView and go again to the subject itself (So that I can see my individual tests), the TableView doesn't refresh every cel. So there are cells which aren't filled, until I add a new test.
Do you have any idea what I can do? :)
Thank you very much!

rry to put [myTableView reloadData]; inside your viewWillApear as below:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[myTableView reloadData];
}

in your viewWillAppear do this
[myTableView reloadData];

Related

How to display an update to a UITableView before a the view closes

I have a UITableView displaying a set of options from which the user will select. When a row is selected the table will update to add a checkmark to that row (and remove it from all others). All is good so far.
What I want to do is close the view after the user makes the row selection but I want the tableview to update first so that the user can see the checkmark move to the correct row (however briefly this may display for).
If I do the following:
[myTableView reloadData];
[parentView closeDialog];
the table update will not show, the dialog will simply close. Any help would be appreciated.
Use this technique to call closeDialog after a delay
//afterDelay parameter represents number of seconds to delay the method call
[parentView performSelector:#selector(closeDialog) withObject:nil afterDelay:1.0 ];
Add self prefix and add some delay using performselector
[self.myTableView reloadData];
[parentView closeDialog];
Hope, this will help you..

iphone - scrollRectToVisible issue

This functions perfectly, but I want to make it an once-function, not fixed-function. When I change tableview with other data, the data displays at the index from previous tableview. So my solution to this is implementing the code below. When I implement this, it works, but when I scroll down, it scrolls up all the time, so it is virtually impossible to scroll down further. Any idea how to make it performs only once when I change tableview?
The code:
[tableView scrollRectToVisible:CGRectMake(0,0,1,1) animated:NO];
Edit 21 august:
Guys, thank you very much! The code was in cellforrowatindexpath. I moved it to inside the function which changes tableview and it works like a charm :D
You could override the reloadData method if that is how you are reloading the Table View with new data and put the code in there. Something like this in your table view controller should suffice:
- (void)reloadData {
[super reloadData];
[tableView scrollRectToVisible:CGRectMake(0,0,1,1) animated:NO];
}
If it's scrolling up every time you scroll down, I assume you put the code in the cellForRowAtIndexPath method which will get called every time you want to present the cell. This is not the correct place to put that code.
It IS a once-function. Most probably, this code of yours is executing again & again. If you have kept this in a function such as cellForRowAtIndexPath:, which is called frequently, that may be the cause of this problem. Where have you put it?
HTH,
Akshay

TableView's viewWillAppear() called but data is not refreshed

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.

How to auto-scroll UITableView?

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.

UITableview Selection Hide

I want to hide(or notshowing) Selected row in tableview....
i am using [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
But its doesnot work.
Can anyone help me?
Do you want to remove it or deselect it? To remove it, you need to remove it from your datasource reference, then call
[myDelegate tableViewSelectionDidChange:NSTableViewSelectionDidChangeNotification];
More info is in the Table View programming guide:
http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/Tasks/UsingTableDataSource.html#//apple_ref/doc/uid/20000117