Quantcast
Channel: Active questions tagged flexbox - Stack Overflow
Viewing all articles
Browse latest Browse all 1318

Swift Sync Buttons on Viewcontroller to ScrollView on Custom View

$
0
0

So what I have are a bunch of buttons in a custom view arranged in a checkerboard layout using Flexbox withthe FlexLayout plugin. On this custom view the rootFlexContainer is a subview of scrollView which in turn is a subview of that custom view.

SocialView

scrollView.addSubview(rootFlexContainer)        addSubview(scrollView)

ViewController buttons on CustomView

I originally had the idea of just pressing the checkered background (since they are all buttons) and having that push a view ViewController through the Navigation controller. But neither love, money, nor StackOverflow would achieve this for me. (Even though it's a relatively simple thing to do on Android.)

So the next best thing was to make custom buttons on the ViewController and just place them on top of the checkered custom view and use THOSE buttons to push the ViewControllers through the navigation controller.

SocialViewController

override func loadView() {        view = SocialView()        view.addSubview(customButton1)        view.addSubview(customButton2)        view.addSubview(customButton3)        view.addSubview(customButton4)        view.addSubview(customButton5)        view.addSubview(customButton6)        view.addSubview(customButton7)        view.addSubview(customButton8)        view.addSubview(customButton9)       }

This works just fine... until you scroll...

Scrolled custom view

The buttons don't scroll WITH the custom view. They remain stationary.

My first thought was to go back and try and figure out how to get the buttons on the custom view to just push the viewcontrollers... but that was such a horrible nightmare that I figured it MUST be easier to just sync the buttons that I have in the ViewController (which work just fine) with the scrollview.

So how do I go about doing that?


Viewing all articles
Browse latest Browse all 1318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>