Get UISegmentedController value from flipside

↘锁芯ラ 提交于 2020-01-17 05:21:17

问题


If you just have a utility template provided by SDK with a segmented controller on the flipsideview with several segments of a decimal value, and you want to grab the current value for the mainview, what is the best way to do this? Thank you for taking the time to answer!

MainViewController.m

-(void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
    [self dismissModalViewControllerAnimated:YES];

    //This does get the value, but only by going to the flipside first then back to the mainview.
    SegValueLabel.text = [controller.RiseSegmentedControl titleForSegmentAtIndex:controller.RiseSegmentedControl.selectedSegmentIndex];
}

-(IBAction)CalculateButton:(id)sender{
    //Need to get the value of segmented control from FlipSideView and assign it a variable.
}

回答1:


Make sure that the segmented controller is mapped to an IBOutlet property in the flipside view. If you are using the Apple utility app template, you'll see that FlipsideViewControllerDelegate is implemented by MainViewController. If you aren't using it, make a project using it as an example. Implement the flipsideViewControllerDidFinish: method in MainView and use it to grab the property something like this:

flipsideController.segmentedControlProperty.selectedIndex;

or if you want the title:

[flipsideController.segmentedControlProperty titleForSegmentAtIndex:flipsideController.segmentedControlProperty.selectedIndex];


来源:https://stackoverflow.com/questions/5466195/get-uisegmentedcontroller-value-from-flipside

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!