scrollsToTop and multiple scrollViews on-screen - ios

I'm currently working on an iPad app that should feature two UITableViews side-by-side (unfortunately, they can't be combined into a single one for some specific reasons).
As far as I know, scrollsToTop won't work properly for both of them, since only one scrollView should have this property enabled at a time. The thing, the app could really use this feature for both tableViews, but I haven't figured out how to do it.
Is there any workaround that would allow me to have scrollsToTop enabled and working for both of them? Or maybe disabling it on both and then listening for touches on the status bar so the app can determine above which tableView they happen and scroll as appropriately? Or any other clever solutions?
Edit: tableViews shouldn't scroll up together. Each should scroll only if the tap on the status bar is right above them (just like if we had two iPhones side by side, for the lack of a better example).

If you have many scrollviews this category is really useful.
-[UIScrollView makeOnlyThisScrollViewScrollToTopOnStatusBarTap];
https://gist.github.com/hfossli/6776203
It basically sets scrollsToTop to NO on all other scrollViews than the one you are specifying + taking care of the default value.

There's a scroll view delegate method scrollViewShouldScrollToTop:. Implement the method on one table view and in the method body tell the other one to also scroll to the top (probably with setContentOffset:animated:).

Related

iOS Multiple Scrolling Sections - Right way

i have question regarding one screen which i should implement in app, as iOS giving us various possibilities i don't know which one is the best practice for this current task.
Sections as visible on the screen should scroll and while we select one of them, should show unique data.
Scrolling Data Is Static.
My ideas:
1) Create multiple tableView's to support scrolling and get button actions.
2) Using the scrollView - programmatically add buttons on scrollview with multiple IBActions.
3) Modify UIPickerController to support such template.
As i mention there are lot of options and maybe i have missed more, but question is: In which way you would finish this tasks and how do you think is right way to handle such a design because on iPhone 5s we know that this UIView will be resized and will be smaller so UIView should be inserted in ScrollView itself.

How to pin an image/view inside a UIScrollView when scrolling

I've been searching for a way to pin views/images to the top of a UIScrollView when scrolling. However the posts/articles I came across are not in swift 3. I'm not sure if I'm typing my question in the web correctly. So my question is how can we achieve the same behavior as a UITableView or UICollectionView. When you scroll, a section will stick to the top until another section pushes it up. I'm wondering would we be able to use views/image and pin them at the top of the UIScrollView. Down below is a screenshot of a UIScrollView that has 4 views.
So when scrolling I would like to pin the first view/image to the top until another view/image pushes it. Also would it be possible to determine which view sticks to the top. So lets say I only want the red views to stick until another red view pushes it. Been looking for a way to achieve this type of behavior for a while now.
Please help, would really appreciate any help provided at this point. Thanks.
A few ways to do this, but you can use the scrollView delegate’s scrollViewDidScroll to capture the contentOffset and use a combination of the target view’s origin/center/transform properties to keep the view where you want it.
There’s a neat video explaining how to do this that Apple released during WWDC 2010, called something like “Advanced Scroll View Behavior”, if I remember correctly. It’s definitely worth a watch.

iCarousel rotary mode scroll views one by one / pagination

I'm using iCarousel in rotary mode. I'd like to have my views scrolled one by one in a paginated way. I've tried many settings but couldn't manage to do that.
The settings i'm looking for is a bit like "pagingEnabled" in UIScrollView, but with the addition that a swipe motion should never scroll more than one view.
I tried to perform "[stop animation]" in the "carouselCurrentItemIndexDidChange" method without luck.
I first thought that stopAtItemBoundary property would let me do that, but it doesn't. I just means the carousel will stop at an item, but i lets the user swipe more than one at a time.
Anyone ?
set decelerationRate to a lower value like 0.5.
You may need to tweak this value to suit your view sizes, but it will have the effect of reducing the distance the carousel moves when flicked.
Set 'isPagingEnabled = true'. This would help
This is available in latest version of iCarousel. But it won't help in auto scroll though.

Simple Picture based App

I'm developing a iPad app which is just a series of pictures, and I'm stuck. I've managed to link up a Tab Bar Contoller to the 6 View Controllers and all seems to work well. But I'd like to be able swipe to the next View Controller once the user has selected the button. How do I do this? The swipe gestures don't work for me. Here's a snapshot:
I think you are looking for UIPageController. This is the control that is used in the iPhone Weather app to allow you to swipe from city to city. Go here to see the full documentation on the control.
That's not usually how Tab Bars work in iOS, but…
What it sounds like you're after is either a UIScrollView with paging enabled (keep in mind you'll have to set the scroll view's ContentSize) or a UIPageViewController (if you don't want to deal with sizing explicitly and you're OK making a new UIViewController to house each image). I'd recommend the first option. The process would go something like:
Add the UIScrollView as a subview of your main view (remember, ensure to set pagingEnabled to YES
Add each image to the scroll view
Set the scroll view's content size to the total width of all images
Thanks for the clarification!

Nesting UIScrollViews and getting info, when the scrolling happened

I tried reading the other questions about similar cases, but no luck, so here’s a question.
I have a setup of nested UIScrollView’s and while the scrolling all happens fine, I don’t seem to any of the delegate events.
Outer UIScrollView is paginated and scrolls vertically. Inside I have multiple "rows" of horizontally scrolling paginated UIScrollViews. Now, what I want, is to force the inner scrollers to a specific location when vertical scroll happened.
I made the ViewController a delegate and am calling the scrollViewDidScroll, but it only fires when I initially set up the scrollers and never if I actually touch the device and scroll the grid.
I’m listening both inner and outer scrollers and they both ignore firing any events when I scroll on the device.
I’m quite new to Obj-C and Cocoa dev, so I might be completely missing something obvious, but any help is appreciated.
I created a small test project and it all seemed to work fine. Make sure to call [scrollView setDelegate: self] on all of the scrollViews (assuming the controller itself is the delegate. Apart from that, always make sure the scrollViews have a bigger contentSize than their frames, if not then scrollDidScroll: shouldn't fire at all.
My small project basically had one pointer to the outer scrollView and an NSArray of all the inner scrollViews, every time the outer one scrolled (just had a small check in the scrollViewDidScroll: delegate method) I simply recursively changed all the inner scrollViews' contentOffsets to CGPointMake(0.0, 0.0).
This isn't the most optimised approach as actually only the previously visible scrollViews would need to be reset (all the other ones should already be at that offset anyway). Also, as a side note, depending on the number of inner scrollViews this approach of adding them all to the outer scrollView may severely damage performance (the app needs to have all the subviews in memory), so you may want to think about reusing scrollViews that are not currently visible (Apple sample project PhotoScroller has some neat tricks on reusing subviews in a UIScrollView, which basically mimics how UITableView works).
If you have any other issues, let me know I'll post the sample project.

Resources