So Apple is saying that UIWebView and UITableView objects shouldn't be embedded in UIScrollView objects. https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/index.html
You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
Does that mean we should never have web or table views inside scroll views? I'm implementing an app that have several web views and table views that scroll with the rest of the content of the view, so scrolling in the web and table views is disabled.
To never place web or table views inside scroll views would mean big design changes. Is Apple saying that we should never keep web and table views inside scroll views, meaning we can never have them scroll with the rest of the view's content?
Or will it work OK as long as scrolling is disabled for the web and table view embedded in the scroll view? If not - are there any better alternatives other than redesigning the app?
I have used a UITableView inside a UIScrollView in a production app.
Example:
List of POI's in a UITableView and MKMapView next to each other inside a UIScrollView with paging enabled.
The problem was indeed that the scrolling of the UIScrollView did not actually work. Especially on the MKMapView, as this scrolls in all directions. The workaround was to create a custom UIView with two UIButton's which act as a custom UISegmentedControl. These will actually scroll the UIScrollView to the selected page.
Some of the things Apple puts in their documentation is probably there to be able to comment on bug reports, or to say: See, we told you so.
UIWebView ans UITableView inherit from a UIScrollView, so they will scroll if the content exceed the screen size.
If you use it in a UIScrollView its a UIScrollView in an other. That's why it can cause problems.
And if you want to use scrolling view in another, you should change the design of your app.
Related
In my app we have taken a scrollview with paging enabled inside that i have added multiple custom views which can have multiple individual elements which are all accessible. Now the issue is when accessibility is on and i try to traverse all the elements via right swipe gesture.
Observation: when it comes to last element of first custom view and i perform right swipe gesture it does not jumps the focus to next custom view elements. Any idea how i can make it happen?
I followed voice over can only see a page of a uicollectionview but here there are using collection view and individual elements inside UICollectionViewCell are not accessible
Using paging with a scrollview, the UIPageControl handles movement between the subviews. You really should just leave this control as the accessibility component for navigation as users are familiar with how it works.
https://developer.apple.com/documentation/uikit/uipagecontrol
I'm trying to implement something similar to iTunes Store UI.
As you can see from the picture, there are two directions of scrolling possible. But I would like to prioritise scrolling of UICollectionView which is to the left or right because currently scroll down and scroll left/right are conflicting and causing weird behaviour.
Way to duplicate:
Scroll Down UITableView and then quickly try to swipe right or left on UICollectionView. UITableView will continue to scroll.
How can I do so? Do I need to use GestureRecognizer?
I always avoid collection view as it provides less flexibility to work with auto layout compared to a table view, however not against collection view every time. You should try the adding collection view inside a table view
There is a number of tutorials available for the same. eg (ios 8 Swift - TableView with embedded CollectionView)
I need to have iOS app with screen like this:
screen
The idea is when user start to scroll down the first UIView to move up until the second UIView reach the top where it will stick and only UICollectionView will continue to move up.
Currently I'm using this structure
UIScrollView (main scroll)
UIView (some banners)
UIView (UISegmentedControl)
UICollectionView (grid with items, scroll is disabled, main scroll is used)
I manage to do it, but I needed to set UICollectionView height constraint manually in the code (calculated based on all items in grid) in order to appear in UIScrollView (everything else is handled by AutoLayout in Storyboard). The problem with this is that UICollectionView think all cells are visible and load them, so the whole recycling & reusing thing does not work. It's even worst because I use willDisplayCell method on UICollectionView to load more data when last cell is displayed, but now it load all pages at once.
My question (actually they are 2)
How can I fix the issue above?
What is the right way to achieve this functionality? Maybe my whole approach is conceptually wrong?
Collection view is a scroll view itself. So maybe you could have same functionality only with Collection view with sections or even custom layout?
I have the following layout
So it's basically a scroll view that occupies whole screen. Content size is set to triple-width and same height. Inside the scroll view - there is container view and three table views - one per page. Only middle table view is visible initially.
This allows me to use scroll view horizontal scrolling to navigate between the tables and vertical scrolling inside the middle table.
I know that Apple doesn't really recommend putting UITableView inside UIScrollView, but in this particular case I don't know how to implement it differently, and until iOS8 everything was working fine.
UIScrollView would not recognize any vertical scrolling (since content height was equal to scroll view height) and these gestures were passed directly to UITableView.
But starting in iOS8 - this getting broken. UIScrollView would allow some vertical scrolling and basically intercept scrolling gestures sent to UITableView.
I created a simple project that works fine in iOS7 but is broken in iOS8. Anybody has any idea how to fix this problem?
Link to the project: https://dl.dropboxusercontent.com/u/6402890/TablePaging.zip
I haven't been able to solve this and as I mentioned in comments had to re-write logic using built-in UIPageViewController class.
If I change the Class of your ScrollView in Interface Builder to UIScrollView, it fixes part of the problem. Now just the UITableView goes up and down, and I go left-and-right, but haven't gotten rid of the space at the top.
In shorts, my desired screen layout is basically a user profile (iOS 7 + Xcode 5). I used UIScrollView as the top level view. The reason is that I want all its subviews to scroll (user info view - the view with a profile image and some buttons you see on the screen, and the photos collection view - the one with black background) when it is scrolled.
The region with black background will show user photos. I'm wondering if I could use a UICollectionView here, or there's a better way to implement it. The UICollectionView in this case shouldn't be able to scroll itself, it just shows all cells, while the scrolling work is handled by the outermost UIScrollView.
I read following posts:
UICollectionView inside of UIScrollView
UICollectionView in UIScrollView -> Scroll Order
iOS 7 Collection View inside Scroll View
Some said it's not possible (or at least, weird) implemeting UICollectionView inside UIScrollView because UIScrollView is UICollectionView's superclass which leads to unexpected behaviour. Some said it should be implemented in another way (but I didn't see a clear suggestion).
Yes, you can put a UICollectionView inside a UIScrollView. iOS has fully supported nested scroll views since iOS 3.0, and UICollectionView is a subclass of UIScrollView. For example, check out the App Store app on your iOS device. The screen scrolls vertically - it's either a UIScrollView or a UITableView (which is itself a subclass of UIScrollView). And each row of icons scrolls horizontally - each row is a UICollectionView.
However, it's not clear why you need to put a collection view inside a scroll view. It sounds like you only want the photos view to scroll, so just make the photos view be a collection view. Why do you need to put the collection view inside a scroll view?
UPDATE
Just use a collection view. Set the header of section 0 to the profile info view. You don't need a scroll view.
If you put all the photos in one section, you can set up the header in your storyboard with no code. If you use multiple sections, you'll need to implement collectionView:layout:referenceSizeForHeaderInSection: in your delegate and collectionView:viewForSupplementaryElementOfKind:atIndexPath: in your data source.