yerpy
yerpy

Reputation: 1446

Scroll View does not display components

I've started to creating UI programmatically and I'm stuck. I've added blur effect to the view and then to the blur scroll which have just one button but it does not display it. From debuging i can see that there is a button inside. What might be wrong ?

(lldb) po blurEffectViewFilters.contentView.subviews
▿ 1 element
  - 0 : <UIScrollView: 0x7fd5958a5e00; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600000253020>; layer = <CALayer: 0x6000002369c0>; contentOffset: {0, 0}; contentSize: {320, 568}>


(lldb) po blurEffectViewFilters.contentView.subviews[0].subviews
▿ 1 element
  - 0 : <UIButton: 0x7fd593f3bde0; frame = (0 0; 100 50); opaque = NO; layer = <CALayer: 0x600000236a40>>


   func initFiltersView() {
        blurEffectFilters = UIBlurEffect(style: UIBlurEffectStyle.dark)
        blurEffectViewFilters = UIVisualEffectView(effect: blurEffectFilters)
        blurEffectViewFilters.frame = view.bounds
        blurEffectViewFilters.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        blurEffectViewFilters.isHidden = true

        scrollView = UIScrollView()
        scrollView.delegate = self
        scrollView.contentSize = blurEffectViewFilters.bounds.size

        doneButton = UIButton(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
        doneButton.backgroundColor = .white
        doneButton.setTitle("Done", for: .normal)

        scrollView.addSubview(doneButton)

        blurEffectViewFilters.contentView.addSubview(scrollView)

        view.addSubview(blurEffectViewFilters)
    }

Thanks in advance!

Upvotes: 0

Views: 42

Answers (1)

DonMag
DonMag

Reputation: 77433

It looks like you never set the frame of your scroll view:

- 0 : <UIScrollView: 0x7fd5958a5e00; frame = (0 0; 0 0); clipsToBounds ...

In the initFiltersView() code, you're setting the contentSize, but not the frame.

Upvotes: 1

Related Questions