2015-11-26 172 views
0

我只在圖像上實現自定義選取器視圖。問題是,圖像重疊在對方喜歡的是: enter image description hereUIPickerView無法正確顯示圖像

這是代碼在選擇器視圖配置圖片:

func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView!) -> UIView { 
    let chosenImage: UIImageView = UIImageView(image: UIImage(named: iconArray[row])) 
    NSLog("choosen image \(iconArray[row])") 
    let workaroundImageView: UIImageView = UIImageView(frame: chosenImage.frame) 
    workaroundImageView.backgroundColor = UIColor(patternImage: chosenImage.image!) 
    return workaroundImageView 
} 

我缺少什麼?有什麼建議麼?

回答

1

在UIPickerView的委託中使用rowHeightForComponent。

pickerView:rowHeightForComponent: 

爲組件給出所需的行高度。

func pickerView(pickerView: UIPickerView!, rowHeightForComponent component: Int) -> CGFloat 
+0

謝謝!完全忘了這種方法!隊友的歡呼聲! –

+1

沒問題!很高興能有幫助! –