2017-07-31 1 views

答えて

1

これを試してみてください:関数が実行されると

let alertView = UIAlertController(
     title: "Select item from list", 
     message: "\n\n\n\n\n\n\n\n\n", 
     preferredStyle: .alert) 

    let pickerView = UIPickerView(frame: 
     CGRect(x: 0, y: 50, width: 260, height: 162)) 
    pickerView.dataSource = self 
    pickerView.delegate = self 

    // comment this line to use white color 
    pickerView.backgroundColor = UIColor.lightGray.withAlphaComponent(0.2) 

    alertView.view.addSubview(pickerView) 

    let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil) 

    alertView.addAction(action) 
    present(alertView, animated: true, completion: { _ in 
     pickerView.frame.size.width = alertView.view.frame.size.width 
    }) 
+0

私はこのエラーを取得するUPDATE

は最後に、私はクールなカスタムアラートを作成するために、この素​​晴らしいライブラリを使用しました: "'TwitterCampaigns.ViewController'(0x1088ac638)型の値を 'UIPickerViewDataSource'にキャストできませんでした。"何か案が ? –

+0

データソースメソッドをviewControllerに追加しましたか? – Bali

+0

私はそれをして、UIPickerViewが表示されていますが、データがアラートボックスから出てきます。 –