Siddharth Shah
Siddharth Shah

Reputation: 382

UIscrollview not working ios swift

enter image description here

I tried to implement thorugh this method:

override func viewDidLoad() 
{
        super.viewDidLoad()
mainScrollView.contentSize = CGSizeMake(self.view.frame.size.width, 530);
          // Do any additional setup after loading the view.
}

but then also scrollbar not working properly.

Upvotes: 1

Views: 1131

Answers (3)

Vivek Lathiya
Vivek Lathiya

Reputation: 76

In this case your mistake is you should not give content size. And for automatic scrolling you can do auto-layout constraint.

Upvotes: 1

GökhanT
GökhanT

Reputation: 139

self.scrollView.contentSize = self.scrollView.superview!.bounds.size

Upvotes: 2

SASI KUMAR
SASI KUMAR

Reputation: 19

  1. First, you have set scrollview(0,0,600,600)

  2. Setting the autolayout for scrollview leading,trailing,top,bottom.

  3. Second, you have set contentview inside your scrollview(0,0,600,600)

  4. Setting the autolayout for contentview like leading,trailing,top,bottom.

  5. Third, Setting contentview width is Equal to superview width.

  6. Fourth, Setting contentview height.

  7. It's working perfectly.

Upvotes: 1

Related Questions