开发者

Pass UISegmentControl selectedSegmentIndex to Popover

Sorry for the noob question. I have a view that has a UISegmentControl in the UIToolBar. I also present a popover from a button. How do I get the value of the UISegmentControl to the开发者_C百科 popover? Should I have the Popover have an NSInteger ivar to hold this value so when I present the popover, I set that value to whatever the selectedSegmentIndex is? I didn't know if that was the cleanest way since I'm new at this and keep reading stuff about not coupling your classes. Thanks!


In my opinion , You can use UIControlEventValueChanged Event of UISegmentControl to directly set the TAG Propertly of popover to the selectedSegmentIndex of UISegmentControl .

{
[segmentedControl addTarget:self
                     action:@selector(setvalueofselected:)
           forControlEvents:UIControlEventValueChanged];
}

-(IBAction)setvalueofselected:(id)sender
{
  popover.tag = segmentedControl.selectedSegmentIndex;

OR

   self.intSelected = segmentedControl.selectedSegmentIndex;
}

And from with in your popover click event code try to check the property of TAG . You can also use Some Global Integar for this purpose instead of tag property.

In this way your POPOver can know which segment was selected when they clicked popover.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜