UITableViewScrollPositionTop on the last UITableViewCell - iphone

I am having a hard time trying to make the very last UITableViewCell from my table to get to the UITableViewScrollPositionTop.
The behavior I would expect is:
On didSelectTableAtindexPath:lastindex, the table would bring the last cell all the way up to the top position... I would do whatever is needed, then, I could resume the positioning (pretty much like what happens when we use a textField inside the cell and the keyboard fires up)
Does anyone know how can we get that kind of behavior?

I got it by myself actually...
If anyone is having the same issue, here is what you should do:
right before using the scrollToRowAtIndexPath:atScrollPosition:animated:
use:
aTableView.contentInset = UIEdgeInsetsMake(aTableView.contentInset.top,
aTableView.contentInset.left,
aTableView.contentInset.bottom+300,
aTableView.contentInset.right);
do what you have to do and then:
aTableView.contentInset = UIEdgeInsetsMake(aTableView.contentInset.top,
aTableView.contentInset.left,
aTableView.contentInset.bottom-300,
aTableView.contentInset.right);
the only problem is that the comming back from the inset is not animated, but I guess you can set an animation to smooth the transition...

Use this delegate methods to scroll top or bottom
scrollToNearestSelectedRowAtScrollPosition:animated:
scrollToRowAtIndexPath:atScrollPosition:animated:
selectRowAtIndexPath:animated:scrollPosition:

Related

iOS- TableViewCell expand/collapse

i want to create a a TableView with expand/collapse cells, and i thought 2 ways to achieve that:
Play with the heightForRowAtIndexPath
Create 2 different cell, with different identifier, and each time load the right one.
I want the cell to expand/collapse with animation, and the user can expand more then one cell.
Which one is better?
Thanks in advance!
Depends on your cell, before and after collapsing, and whether you want to animate it or not.
Options:
If the contents are the same, or with some small additions, and you wanna animate it. Use this option.
If the contents changes dramatically, go with this option. And I'm not sure if animation in this case is easy.
Good luck, need more help, let me know! ;D
I think you want this: https://github.com/seletz/CocoaTreeViewExample
I have made a expandable/collapsable treeview using the same code that is looking like this in my application now:
I was after something similar, I wanted to be able to show and hide contextMenu for a table view cell. So I ended up using just one cell for both expanded and collapsed state, and I had a "context menu subview" (that's what I wanted for the expanded look) and updated it's frame for the animation.
The trick is that when you want to expand/collapse you cell with a nice animation you'd better use beginUpdates and endUpdates instead of reloadData or reloadRowsAtIndexPaths:withRowAnimation: methods. Something like that:
// setContextMenuHidden:animated: updates frame and alpha for the context menu
// view (which is a subview of cell content view)
[cell setContextMenuHidden:NO animated:YES];
[self.tableView beginUpdates];
[self.tableView endUpdates];

making insertItemsAtIndexPath in UICollectionView not to animate

I am using UICollectionsView insertItemsAtIndexPath and it is very annoying such that when I am scrolling on the UICollectionView and then it calls insertItemsAtIndexPath it slides with the item. I want this inserting to be seamless and just append it to the top without user knowing that something has been appended on top. How can I do this?
I suppose you will have to subclass the UICollectionViewFlowLayout and then in the - (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath just return nil. That way, it will directly place it to the final position and hence no animation should take place.

custom uitablviewcell does not call didSelectRowAtIndexPath in the controller

I have a custom UITableViewCell completely written in code (no IB), it has an accessory button that simply calls didSelectRowAtIndexPath on the table view, and it works correctly and the method is called without problems.
However, when I tap on the cell itself (not on the accessory view) nothing being called, why ?
EDIT: the code is huge to put here ... however, the custom cell contains a ton of labels, couple images and scroll view ...
This is a shot in the dark, but if each cell has many different objects on it (i.e. images, labels, etc) then it may not be working because those objects are what the user is hitting when they try to click a cell. Does the cell turn blue (indicate selection) at all? If not, try hiding/removing those objects for now and see if it works.
If that is the case, then what you may want to do is create an invisible cell or button that sits on top of the other objects and calls didSelectRowAtIndexPath from behind the scenes.
This should solve your problem:
Raise selection event (didSelectRowAtIndexPath) when subview of UITableViewCell is tapped
Try setting your view's userInteractionEnabled property to NO.
This will make it ignore all touch events, and then the views under it will be able to catch these events. - Felipe Sabino
I'd partially answer my question: the wide scroll view is preventing the cell from calling didSelectRowAtIndexPath, removing the scrollView will solve the problem, however, I want to call this method with the existence of the scrollView ... anyone got ideas would be highly appreciated ...
You must post your code to understand what have you done...You have to check out this example to understand whether your code is correct or not...
http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-a-custom-accessory-view-for-your-uitableview-in-iphone/

iPHONE SDK - tableview, remembering how much it is scrolled?

i was wondering how do i do this?
I wish to make a tableview configured in a way that if i scroll down a tableview and click on one row, i will be brought to another view. But when i click a back button of some sort. i return to the tableview but still viewing that particular row. kinda like the iPod table in the iPhone? Remembering scrolled position?
i just want to know how to do the 'remembering scrolled position' part.
Save your index path in tableView:didSelectCellAtIndexPath: before pushing the new view, use it later. This will give you the NSIndexPath pointing at the cell that was selected by the user, not necessarily give you the same position it was at before they tapped the item. So keep that in mind.
Continue from jer's answer. You can use indexPath when calling this method in tableView:
UITableView selectRowAtIndexPath:animated:scrollPosition:

How are touches handled by a UITableView?

I'm trying to better understand how UITableView and UITableViewCell work, and one part of that is touch handling.
So when I touch a row on a table view, what exactly happens? My basic understanding is:
UITableView is a UIScrollView, so first it checks if it's a touch or a scroll
If it's not a scroll then the touch gets analyzed to see which row is under the touchpoint
It gets the cell at this indexPath (how?) and tells it to setHighLighted, setSeletected
Is that it? Does anybody have a more thorough understanding of it than that?
Probably somethign along the lines you mentioned, you never know though until you see t he source, why do you want to know anyway? you making your own tableview?
One last step is that the touch gets passed to the cells content view. That way any subviews in the cell will receive touch events. I'm pretty sure this comes after your step 3 and actions from cell selection will be processed first.