Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Storyboards? #50

Closed
andres-cianio opened this issue May 4, 2017 · 5 comments
Closed

Using Storyboards? #50

andres-cianio opened this issue May 4, 2017 · 5 comments

Comments

@andres-cianio
Copy link

While I love this component and how simple it is, I'm having quite a weird situation...
I've got everything working as per the demo example, but there is a thing that keeps me bothering, and it's creating the buttons in runtime with fixed frames. Since I hate working with constraints in code I decided to build a simple XIB and setup the buttons there.
The problem is that the previewView hides the buttons! From what I understand, the previewView is added later on, so it covers everything that's there; so adding the buttons after view did load manages to put the buttons above.
For now I'm gonna try moving the buttons to front, but is there any other way?

@Awalz
Copy link
Owner

Awalz commented May 4, 2017

Indeed, the PreviewLayer is created in ViewDidLoad. It will conflict with with views in XIB's and Storyboards as they are added prior to ViewDidLoad being called. Calling bringSubview(toFront:) for your views in ViewDidLoad would work just fine for now.

I am working on a new build where the PreviewLayer is self.view, rather than added after the fact, which should resolve this issue for IB users

@andres-cianio
Copy link
Author

Awesome! I had something like that in mind, but for now I'll stick to bringSubview(toFront:).
Thanks!

@eric-krikey
Copy link

Can you elaborate on this concept (calling bringSubview(toFront:))? When I have tried to do this, it hasn't actually worked. I am using a simple storyboard. I put a UINavigationBar and a button on, intending to be overlaid on the camera stream. Here is my code in viewDidLoad():
navBar.superview?.bringSubview(toFront: navBar) recordButton.superview?.bringSubview(toFront: recordButton)

@andres-cianio
Copy link
Author

I was doing just that... for each of my custom buttons, calling its superview bringSubview(toFront:). Don't know about the navbar though.
I have a ViewController that inherits from SwiftyCamViewController, and in this VC viewDidLoad I do:
closeButton.superview?.bringSubview(toFront: closeButton) mainButton.superview?.bringSubview(toFront: mainButton) misteryToggleButton.superview?.bringSubview(toFront: misteryToggleButton)
where closeButton, mainButton, misteryToggleButton are IBOutlets of buttons defined in the Storyboard.

@eric-krikey
Copy link

Hmm. Yeah, no matter what I seem to do, I can't get my UIButton or SwiftyButton to appear. I even tried to use the Debug View Hierarchy tool, and I can't see anything from my xib on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants