0

我正在尝试在 iphone 中实现功能以在 AlertView 中显示表格,并在单击表格时填充父视图的一些控件。

在 Android 中,我们可以通过 AlertDialog 做到这一点,但在 Iphone 中,我用谷歌搜索但没有找到一些建议来实现这个东西。

下面是Android代码,但是如何通过IOS做到这一点

   new AlertDialog.Builder(MakeReservation.this).setTitle("Previous Locations").setItems(locArray, new DialogInterface.OnClickListener() {

     @Override
     public void onClick(DialogInterface dialog, int which) {
      String str = locArray[which];
      if (str.contains(",")) {
       String[] Address = str.split(",");
       // String[] PickAddress = "Snoufer School, Gaithersburg, MD 45123".split(",");
       if (Address.length > 0)
        pickUpStreet.setText(Address[0]);

         for (int i = 0; i < getResources().getStringArray(R.array.state_symbols).length; i++)
          if (getResources().getStringArray(R.array.state_symbols)[i].equals(getStateCity[0])) {
           pos = i;
           break;
          }

         pickUpState.setSelection(pos);
        }
        if (getStateCity.length > 1)
         pickUpZip.setText(getStateCity[1]);
       }

      }
     }
    }).create().show();
4

2 回答 2

2

我不知道它如何在 android 中显示你寻求的警报对话框。但我猜你正在寻找类似Image1 Image2的东西。

在 UIAlertView 中带有 Section-Header 的 UITableView 在此处输入图像描述

于 2012-04-28T12:08:43.647 回答
0

斯威夫特:看看我的代码:

你需要一个uipickerview。

class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
    @IBOutlet weak var gradeTextField: UITextField!

    var gradePicker: UIPickerView!
    let gradePickerValues = ["5. Klasse", "6. Klasse", "7. Klasse"]

    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int{
        return 1
    }
    func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int{
        return gradePickerValues.count
    }
    func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
        return gradePickerValues[row]
    }
    func pickerView(pickerView: UIPickerView!, didSelectRow row: Int, inComponent component: Int){
        gradeTextField.text = gradePickerValues[row]
        self.view.endEditing(true)
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        gradePicker = UIPickerView()
        gradePicker.dataSource = self
        gradePicker.delegate = self
        gradeTextField.inputView = gradePicker
        gradeTextField.text = gradePickerValues[0]
    }
}
于 2016-02-11T08:23:45.253 回答