Stevia icon indicating copy to clipboard operation
Stevia copied to clipboard

different with same constrain

Open sameer4 opened this issue 5 years ago • 2 comments

hi i have a view https://imgur.com/dWNRAgE

i created a viewcontroller and i'm adding it as view in scrollview

with

trendingPhotoViewController!.view.heightAnchor.constraint(equalTo: scrollViewForPhotos.heightAnchor).isActive = true

it's fine as in above image but with

trendingPhotoViewController.view.Height == scrollViewForPhotos.Height

results in

https://imgur.com/I37nm4y

i'm adding the code if you need to look at it.

`var trendingPhotoViewController: UITrendingPhotoViewController! var previousTrendingPhotoViewController: UITrendingPhotoViewController!

    for i in 0..<data.count
    {
        previousTrendingPhotoViewController = trendingPhotoViewController
        trendingPhotoViewController = UITrendingPhotoViewController()
        scrollViewForPhotos.addSubview(trendingPhotoViewController.view)
        arrayTrendingPhotoControllers.append(trendingPhotoViewController)
        
        trendingPhotoViewController.config(data: data[i], rank: i + 1)
        
        trendingPhotoViewController.view.translatesAutoresizingMaskIntoConstraints = false
        
        trendingPhotoViewController.view.Top == scrollViewForPhotos.Top
        trendingPhotoViewController.view.Bottom == scrollViewForPhotos.Bottom
        trendingPhotoViewController.view.Height == scrollViewForPhotos.Height
        
        if i == 0
        {
            trendingPhotoViewController.view.Leading == lblTrendingPhotos.Trailing + 20
        }
        else
        {
            trendingPhotoViewController.view.Leading == previousTrendingPhotoViewController.view.Trailing
        }
        
        if i + 1 == data.count
        {
            trendingPhotoViewController.view.Trailing == scrollViewForPhotos.Trailing
        }
    }`

sameer4 avatar Oct 30 '18 13:10 sameer4

@sameer4 This is quite weird indeed. I need to debug this to find out where the issue lies. This surely looks like a bug :/ Have you been able to find a workaround in the meantime?

s4cha avatar Jan 07 '19 14:01 s4cha

yes just using

trendingPhotoViewController!.view.heightAnchor.constraint(equalTo: scrollViewForPhotos.heightAnchor).isActive = true

instead of

trendingPhotoViewController.view.Height == scrollViewForPhotos.Height

for now :D

sameer4 avatar Jan 16 '19 09:01 sameer4