Add ViewControllers in a Scrollview - ios

I'm working on a project where I'd like to have a series of user interactive views (created in Interface builder, and have their own implementation and header files), displayed in a single scrollview with paging enabled. I have yet to come across an example which is easy to understand. Could someone provide code which does this?
Here is a schematic of how things should work.

You can use UIPageViewController with Scroll style if you are targeting ios 6 or later, which is much easier than UIScrollView. And if you search UIPageViewController scroll example in google, there are quite lots of samples. The following are two of them:
Using ScrollStyle with UIPageViewController
How to Use UIPageViewController to Build Tutorial Screens
Hope this is helpful for you.

Related

Xcode 9 Swift 4 Tabbed Page

I know how to use tabBarController.
But I dont Know How to Create A Tabbed Page Like The Attached Image.
Whats The Name Of This Type Of Tab?
This is not any type of Tab. You can use a collectionView or a stackView for "Tabs" and a UIPageViewController for changing viewControllers.
You can check CocoaControls for similar controls, download source code and check their construction. You can possible do it with SegmentedControls (Or Custom UIViews for single Tab and draw in ScrollView) and UIScrollView as Content View (with Pagination On) as well, but it depends how much customisation is needed.
Trust me, it's REALLY tricky to obtain what you want with the iOS components. There are a lot of details that you will miss.
When I tried myself to build the same thing, it was like "ok I think I am reinventing the wheel, is not straight forward as I though, it require a lot of work"
You know you have to consider a lot of stuff like an User that start to scroll as a crazy between the pages and then tap on one tab bar button, and so on. Trust me, it's easy to have a working implementation, but it's really really difficult to obtain a PERFECT implementation
I decided to go for a library
https://github.com/aokizen/SPSlideTabBarController
https://github.com/xmartlabs/XLPagerTabStrip
but there are others that are all good to achieve what you want
Anyway if you want to go for your personal implementation I suggest a Segmented Control in the upper side and a PageViewController (maybe inside a Container View)

Storyboard of a mockup

I am working on an e-commerce based app, and the designer has passed on the mockup to me. !
This is the mockup the designer has passed.
I am working on storyboard of this mockup and I have managed to get to this level as of now.
There are several views and features which cannot be included in this storyboard now because of the limited space. I know the designer has passed on me the rendered view, which can be seen on scrolling the app.
I wonder which could be the best approach to include all these views in a single storyboard or render them in a single view.
I have looked onto using xib files and calling them from my viewcontroller class, which could be a possible solution. But, I want to know, what could be the best solution?
Best solution is use Storyboard so that you have all screens at one place. But keep one thing in mind that start doing the whole project in XCODE 8 storyboard (Because XCODE 7 and 8 storyboards are not fully compatible with each other). So that you get compatibility with previous iOS versions also (< iOS 10)
Now as far as design is concerned, I would like to suggest you use autolayouts and proportional layout.
your View controller will always have self.view. Start on that view. First add navigation controller (with root view controller as your first prefered view controller on app start) or simply add one toolbar. Then add one UIScrollView to whole remaining space. Then start with your design inside UIScrollView. Don't forget to provide contentSize of UIScrollView.
For any help, feel free to ask.
The best solution would be using a tableView with multiple prototype cells for this kind of problem. Well, going through the concept as mentioned, I could easily scroll in the storyboard and maintain my design as per the mockup.

Horizontal scrolling in section of UICollectionView in iOS, Swift

I develop an app for online shop that should has some design features that I don't know how to implement. Lurking for it second day, but no profit. I suggest, that it should be the simple CV with some custom cells for different needs (banners, products).
Problem - design has scrollable horizontally content in each section and I see no simple way to implement it instead of writing custom flow layout.
I tried to make a tableView with collection view in its rows, but its not working correctly.
May be you know some examples of implementation of same thing in swift or a good way to make such feature without flow layout?
Refer mention link May be help you from this link:- https://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell-in-swift/

(Swift) How to implement a Page Control through paging single views?

I want to implement a page control in my project so that every view can be accessed through swiping left or right. Every example I have looked at is to do with images, not views. I've been studying this and its of course images again. My application is a single view application. I'm not really sure what code snippets to give you so far, I don't think I do because I haven't done anything on this yet. If you need specifics, please comment and ask me, i'll be here all day.
Please help me!
Thanks.
The same idea should apply in the tutorial you cited. They're adding UIImageView to a UIScrollView. So in your case, instead of UIImageView just use UIView. Also you can think of the pageImages array as a data source about your views. For example, instead of an array of UIImage you can just have an array of some model object that helps you configure your view. However, keep in mind that the implementation in the tutorial for your case won't scale if you plan to have a lot of UIViews. That's because you want to effectively reuse views that aren't showing. When it gets to that point, you're better off implementing a UITableView that scrolls horizontally.
You can use UIPageViewController for paging effect. Check out this tutorial. It is written in obj-c but who cares. It will give you idea about using UIPageViewController.

UITableViewController inside UIScrollView with Horizontal Paging

this is the situation:
I need horizontal scrolling, and table views inside every page. This is something like news app, it should display news from different categories, when scrolled in one horizontal direction, and inside one category it should display about 30 news, vertically scrollable, of course.
I have successfully done what i need, but...
I have following scenario:
UINavigationController
|__ UIViewController, which contains ScrollView and PageControl
|__ UITableViewController, which holds data in rows, and is displayed inside parent, which is actually ScollView
I know that this is not an ideal solution, but at least it works. As a base, i used Apple's code and tutorial for PageScroll found on this link. Instead of simple viewController to add to ScrollView, i used TableViewController, so basically i add tableController.tableView to the ScrollView.
I know, also, that adding tableViews inside scrollview is sort of adding a car inside a truck and driving that car, but i couldn't find more reasonable way of doing same thing.
So, i need your thoughts about how this can be accomplished using some other approach. I use storyboarding and iOS 5 for this, and everything seems (and looks) messy right now.
Thanks in advance, a lot.
I did something similar a few months ago, and it was like this:
UINavigationController
UIViewController with a UIScrollView
UIViewController with a UITableView inside (I use this because I simply hate UITablewViewController)
I followed the Apple's documentation about creating custom containers. There is a great video about that in the WWDC 2011 video's section if I am not mistaken. I can proudly say that the code is really clean and simple to understand.
Answer 1.0
The one thing is, did you managed to get proper orientation handling of the tableView, without any hack, or you don't use it?
No, in this case I didn't, but I am sure I would have been able to do it without any problem. You see, most of the problems come when you just [self.view addSubView:newViewController.view];. You just add the UIView, all the logic of the rotation is handled by the newViewController and not in the controller where the UIView will be.
The other thing is, if i'm gonna try to implement, say, GridView or something like that, for iPad, orientation handling and animations become very ugly.
I implemented this in another project and it was quite easy to implement once you understand what's going on:
I used a UIViewController with a UITableView so I could get all the goodies from the dequeueReusableCellWithIdentifier:, creation of section's titles, table's headers and footers, etc. I just figure that no matter what I would do with a UIScrollView a UITableView is always going to be more optimized. As the UITableViewCell's I just used an holder with 3 squares, each one being a picture. (my application was a showcase of pictures)
http://www.raywenderlich.com/4680/how-to-make-an-interface-with-horizontal-tables-like-the-pulse-news-app-part-1
Chk out above link

Resources