Use scrollToItemAtIndexPath in UICollectionView with paging - ios

I have an uicollectionview with paging enabled. One cell per page which is full screen basically. The thing is that when I want to use scrollToItemAtIndexPath and move one cell forward/backward along with animation it will do a swipe but it will go back instantly to the cell/page where I called scrollToItemAtIndexPath. There is really nothing special besides stuff I've described. When I omit animation it's working.
For faster debugging I've setup test project on github - ScrollToItem
EDIT: This might be a bug. Bugreport (18864560) submitted. If someone can provide me a workaround or even solve this issue it will be still appreciated.

Related

How to avoid didSelectRowAtIndexPath being trigged when user tries to scroll bounce-disabled UITableView?

In my application, there's a View controller with bounce-disabled UITableView that covers the entire screen.
However, there is a situation where the table view contains only few items, which the sum of their heights is pretty equals to the screen's height.
As a result the table doesn't scroll (which is fine).
When the user tries to scroll in this situation, it triggers the didSelectRowAtIndexPath of the start scrolling point. How can I avoid this?
One easy solution is to allow bounce effect :D
Couldn't find any other solution :(
to make a better experience make the bounce situational
only allow tableView bounce if the (cellHeight * numberOfCells) < self.tableView.frame.size.height
Looks like some sort of bug in framework (excuse me if it is not). I got this issue today morning and now I am not getting it.
Try adding the below line of code to the cell.
cell.selectionStyle = UITableViewCellSelectionStyleNone
That is the only change I made to the tableview today, and not getting the issue any more. Reverting the change is not reintroducing the issue. Hence I am suspecting a framework issue.

Strange UITableView Selection behavior, selection only after long tap

I've run into a strange UITableViewController behavior.
For explanation:
I have a quite simple UITableView. Just 3 Default Cells with a Text.
But it behaves like shown in the GIF below. (The GIF is a little bit slower than reality)
Normal "short" taps are neither highlight or select something.
A longer press highlights the cell until released.
And only after a long long tap the cell is selected.
I have no idea what can cause these issue and I don't know where to search.
Some Code: TableViewController + DataSource
Have anyone a hint where to start debugging ?
You've probably set up a tap gesture recognizer somewhere else in the view hierarchy which is eating your tap gestures.
Since you're presenting a plain vanilla table view, you really don't want to do that.
(apologies in advance to the community -- this should've been a comment but I can't comment because I've got a bad reputation)
I've got it ;)
I've found a TapGestureRecognizer within a self written sub framework.
After commenting this out it works well.
So I have to search the issue within my sub framework.
A lot of thanks to you, without your hint I never thought about it again 🙈

UIScrollView multiple page confusion

So I have an existing app I'm working on for a friend...
and let's say I double click on animals_real and I get this screen...
Basically all I want to do is create a back button back to the home page on the animals_real page and all the other ones like it(body_parts_real, cleaning_real, etc.) but for whatever reason I can't find the xib file or the code for it and I'm not entirely sure what file it would be in. Also, since I am fairly new I'm not entirely sure how to implement the back button. Any help is greatly appreciated.
----------------------------------EDIT 1------------------------------------------
The main page works under ViewControllerForIphone.xib and the settings page is under SettingViewControllerIphone.xib. This led me to believe that the other pages would be under the SubPECSViewController_iPhone.xib. However, if I go in and edit that it doesn't change anything when I run the simulator. So, basically I have been trying to understand UIScrollView better and how it works but I am kind of just stuck.
Welcome to iOS. Other commenters will point out that you should start here at the UICollectionViewDelegate Reference (which you can also get to through Xcode (shift+command+0)
Basically, a uicollection view populates itself based on some array of data.Look here to see what's going on
(void)insertItemsAtIndexPaths:(NSArray *)indexPaths
When you tap on animals, this method is called:
– collectionView:didSelectItemAtIndexPath:
Some logic happens here, and I'm presuming you load the collectionview from yet another array.
To solve your original problem of a "back button," you might simply want to reload the viewcontroller's original datasource or possibly "pop" back up the navigation stack. Again, without seeing at least part of the code, there's very little we can do except speculate :)

tap action on UICollectionView's cell

I want a cell in UICollectionView can be tapped(not selected,because selected cell would be add to the [cllectionView indexPathsForSelectedItems]), what means: when I tap a cell I can show a detail view of the cell and it would not be add to [cllectionView indexPathsForSelectedItems].
AFAIK, there is no way to do this at this time -- other than to deselect the item after the selection is made. I spent a lot of time trying to make this happen and it just doesn't work.
The problem is this: You have to get hold of the default gesture recognizer for the collectionView tap to require it to fail, and you can't. Apple gives some instructions, but they don't work as advertised. See page 36 of:
http://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/CollectionViewPGforIOS.pdf
The problem is that the sample code in this article doesn't work. On inspecting the default gesture recognizers, you'll find there isn't one of the class type UITapGesureRecognizer. It may be you can figure out what's going on with it, but I never could (if you figure it out, I'd sure like to know how to do it).
Ultimately, everyone workaround I tried failed, and I ended up having to settle for using a long press. There are some other posts on this subject, but I never could find anything else that actually worked. This was all on iOS 6.0.
Someone had also asked about using a double tap, and I could not get the select to consistently fail on that. At first I thought that was the solution, but found that it would sporadically select the cell that was double-tapped, and with no other workaround had to move to the long press, which seemed to work. In the end I had to scrap that work for other reasons, so I never put it in production.
Hope you can find a solution but my experience was not good.

IOS UITableView Selection Highlight is sometimes very quick and did select is not being called

Have a strange issue where about 15% of the time, when selecting a cell with a UITableView the cell highlight flashes quickly and didSelectRowAtIndexPath is not called. The rest of the time it is working fine.
Tested how it was being selected (fast / slow finger nail, etc), but this does not seem to be the case. Looks semi-random.
Any thoughts one what might be causing this?
IOS 6.x
[Addition]
Thanks for the comments so far.
If while clicking the mouse (simulator) is moving, the problem can be duplicated. Even if the table is set to .scrollEnabled = false it is still happening. Also, the didHighlightRowAtIndexPath does fire and the didSelectRowAtIndexPath does not in the "quick" case.
Same thing happens on IOS 5.x also...
[Conclusion]
Well, it turns out that the scrolling was turned off for the table and it seems to be even more picky with the "moving tap" Turning the scrolling on actually made the "moving tap" less picky. There were a couple of other postings that I just found that pretty much said the same thing. This is a strange conclusion for a table view that has scrolling disabled and produces a "quick highlight" with no selection. Looks like this is why they added the didHighlight in IOS 6 to try and get around this "issue".
is it possible that a view from with in the cell is absorbing the touch rather than the cell ?
maybe you have a gesture recognizer in the cell, those take priorities over simple touch events
It seems that for some reason your cell is disabled. Try setting cell.enabled = TRUE; right before the cell is displayed and see if it fixes anything.
You're moving your finger up or down slightly, causing the table to scroll. Your item will not be selected, and the highlight will disappear. I've dealt with this before by tracking the row in tableView:didHighlightRowAtIndexPath, and then doing the action in tableView:didUnhighlightRowAtIndexPath: . You might also be able to solve your problem by making the tableView not scrollable if that's an option in your ui.

Resources