2016-08-01 68 views
2

我有這種結構在故事板:變化imageview的高度編程IOS

UIViewController > View > Scrollview > Scrollview > UIImageview 

默認ImageView的大小爲:320x230。檢查下面的圖片:

enter image description here

現在我需要以編程方式更改的ImageView的大小。

可以說,我需要設置框架:320x280

自動佈局是禁用的,參閱圖像:

enter image description here

這裏是我做了什麼:

override func viewDidLayoutSubviews(){ 
    super.viewDidLayoutSubviews() 
    imgThumbnail.frame = (frame: CGRectMake(0, 0, self.result.width, 280)) 
} 

但其根本不工作。它沒有改變imageview的大小。還有一件更重要的事情是當我向下滾動滾動視圖時滾動&。它採用了我在imageview中的上述代碼中設置的新框架。

如果有人指導我解決這個問題,那將會很棒。

在此先感謝。

+0

什麼是self.result.width? – NSNoob

+0

@NSNoob結果= UIScreen.mainScreen()。bounds.size – Mayur

回答