Yalantis / Segmentio

Animated top/bottom segmented control written in Swift.
https://yalantis.com/
MIT License
2.53k stars 324 forks source link

scroll screen size problem #136

Open keyvan1361 opened 5 years ago

keyvan1361 commented 5 years ago

Report

i have replaced the contenview in the example with my own viewCotrollers it works fine when the app loads and i change the tabs but when i click on the menu items the screen width is wrong and it does not scroll to the end! it works fine on iphone xs but in larger screen sizes like iphone xs

Screen Shot 2019-08-28 at 22 28 26

plus or ipad the size is wrong when the menu is clicked

when i change self?.scrollView.frame.width to UIScreen.main.bounds.width it makes the tab size better but with a padding on the sides

segmentioView.valueDidChange = { [weak self] _, segmentIndex in let contentOffsetX = UIScreen.main.bounds.width * CGFloat(segmentIndex) changed:",self!.segmentioView.selectedSegmentioIndex) self?.scrollView.setContentOffset( CGPoint(x: contentOffsetX, y: 0), animated: true ) segmentioView.valueDidChange = { [weak self] _, segmentIndex in let contentOffsetX = UIScreen.main.bounds.width * CGFloat(segmentIndex) self?.scrollView.setContentOffset( CGPoint(x: contentOffsetX, y: 0), animated: true )

AlexanderYem commented 5 years ago

Hi,

may be you did this in viewDidLoad(), try viewDidAppear()

keyvan1361 commented 5 years ago

Hi,

may be you did this in viewDidLoad(), try viewDidAppear()

hi i moved the code from viewwillappear to viewDidAppear but still the same problem in containerVc(exampleViewController) maybe it's a constraint problem there is a problem with contentOffsetX!