2017-12-04 6 views
0

Xcodeの1つのViewControllerに複数のSegmentedControlsをロードしようとしています。以下はボタンです。 Buttons複数のSegmentedControlをViewControllerにロードする方法

ボタンの1つをクリックすると、SegmentedControlをロードします。 SegmentedControl

これらのSegmentedControlsはViewControllerにロードされます。それを実現させる方法はありますか?

私の現在のコードは以下のようになります。

@IBAction func action(_ sender: Any) { 

    //let url = URL(string: sender.accessibilityIdentifier!)! 

    let alertController = UIAlertController(title: (sender as AnyObject).accessibilityLabel, message: (sender as AnyObject).accessibilityHint, preferredStyle: .actionSheet) 

    let HSAction = UIAlertAction(title: "Upper Building", style: .default) { action in 

     DispatchQueue.main.async { 
      self.performSegue(withIdentifier: "one", sender: nil) 
     } 


     //UIApplication.shared.open(url, options: [:], completionHandler: nil) 
    } 
    alertController.addAction(HSAction) 
    } 

答えて

0

他のビューコントローラに移動した後、あなたは以下のように、複数のボタンとsegmentedcontrolを作成することができます。

segmentedControl = UISegmentedControl (items: ["First","Second","Third"]) 
    segmentedControl.frame = CGRectMake(60, 250,200, 30) 
    segmentedControl.selectedSegmentIndex = 0 
    segmentedControl.addTarget(self, action: "segmentedControlAction:", forControlEvents: .ValueChanged) 
    self.view.addSubview(segmentedControl) 
関連する問題