iPhone:如何实现android AlertDialog之类的功能?

时间:2012-04-28 11:40:47

标签: ios objective-c android-alertdialog

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

在Android中,我们可以通过AlertDialog执行此操作但在IN Iphone中我用Google搜索但是没有找到实现此内容的建议。

以下是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();

2 个答案:

答案 0 :(得分:2)

我不知道它如何在android中显示你寻求的警报对话。 但我想您正在搜索类似Image1 Image2的内容。

UITableView with Section-Header inside UIAlertView enter image description here

答案 1 :(得分:0)

Swift:查看我的代码:

你需要一个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]
    }
}