In one tableView I have 4 rows on section0 and 3 rows on section1. If I tap the row at indexPath (1,2) another row appears with a UIPickerView inside it. I want the tableView to scroll so that the pickerView moves at the top of the screen. To do that I implemented
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
but this only scrolls it up a little bit, not much.
Is there anything I'm missing here? Any help would be much appreciated. Thanks in advance.
well, that's embarasing. As it so happens you do not need the above code to be between
[self.tableView beginUpdates];
...
[self.tableView endUpdates];
I'm gonna leave the answer here in case somebody has the same issue.
Related
I have an issue with expanding and collapsing UiTableView rows and not sure how to troubleshoot or what may be the cause. When the section expands it causes a jerking motion and other rows seem to move up and down.
Here is the issue:
https://www.useloom.com/share/14c1cdd27e7844dcad31dad30d4aa1ce
When the row is toggled the following code is executed:
section.showPrompts = !section.showPrompts;
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationFade];
You could try batching the updates within
[self.tableview beginUpdates];
... your code ...
[self.tableview endUpdates];
so that all of the animations are synchronized.
I have a UITableView where I move a row from outside the visible scroll area to the top of the UITableView. The animation works as intended but it ends up showing a duplicate cell of what was previously at index 0.
Code looks something like this except for the hardcoded index:
[self.tableView beginUpdates];
[self.tableView moveRowAtIndexPath:[NSIndexPath indexPathForItem:16 inSection:0] toIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
[self.tableView endUpdates];
I have this problem on both iOS 8 & iOS 7. Anyone have an idea how to solve this?
The cause of the problem was a bug in the re-ordering of my data provider. I moved a cell in the tableview but the data array did not reflect that change.
While writing a UITableView in iOS8 I've implemented swipe left/right gestures similar to that in Mail. I would now like to implement a cell that slides down below the cell which the user has just swiped left and tapped a button on. Can anyone point me in the right direction?
You need to add the row that should slide out to the data model (UITableViewDataSource) of your UITableView, then tell the tableview section to update with an animation:
[self.tableView beginUpdates];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationTop];
[self.tableView endUpdates];
all I am doing one chat application, i which i am using UITable view to display reply and response from user.in this case after some interval of time i am reloading my tableview to fetch new data from server. But the problem is that after adding new content to table view it will go at the bottom of table view and i have to scroll table view to see that one.or in other case whenever i am reloading my table it will show its first cell on view. Now my question is "is it possible to load last cell of UITableview after view gets load or reload table view?"
on search I find this line but it give me error
[sTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:sender.tag inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
what is sender.tag in this line? // use of undeclared identifier sender
This line working well but scrolling the page which i dont want
[table_readText scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES ];
Any idea or suggestion would be highly welcome.
Thanks in advance..
You can also look at the scroll view's setContentOffset:animated: method.
Going to the top would mean,
[self.tableView setContentOffset:CGPointZero animated:YES];
and the bottom would be,
CGFloat height = self.tableView.contentSize.height - self.tableView.bounds.size.height;
[self.tableView setContentOffset:CGPointMake(0, height) animated:YES];
SECOND option:
scrollToRowAtIndexPath:atScrollPosition:animated:
Scrolls the receiver until a row identified by index path is at a particular location on the screen.
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
I've implemented a tableView on the iPhone with the ability to search using the searchBar. I'm trying to mimic the effect that hides the searchBar in my tableView when it first loaded.
The behavior is expected when the tableView contains more than one row. However, it doesn't scroll to the first row when there is only one row. It shows the searchBar.
- (void)viewDidLoad {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
}
Actually I didn't understand all the things (may be something wrong, when you add cells to the table - where is search bar, in what cell?)
but you can try
[self.tableView scrollRectToVisible:CGRectMake(0, yValue, 10, 10) animated:YES];