0

I have a UISegmentedControl in one of my ViewControllers.This VC has a 'close' button,so the user makes a selection using the segmentedcontrol and then closes the window by clicking on the 'close' button.I want to use the value selected by the user in another VC.But the selection of the segmentedcontrol is not persisted. If I close the window and open it,the segmented control switches back to its original state. I have not set the segmented control to be 'Momentary'. Any idea why the state isn't persisted? And how do I access the selected index in another view controller?

4

1 回答 1

1

状态不是持久的,因为当您关闭窗口时,视图控制器可能已被释放,并且当您再次打开它时会创建一个新实例(尽管这只是一个猜测,因为您没有发布任何代码)。

您如何获得该值取决于您的应用程序是如何设置的。您可以使用通知或委托方法。如果您需要更多细节,那么您需要提供有关您的应用程序结构的更多信息。

于 2012-11-09T05:13:33.923 回答