开发者

Setting UISwitch state in UIPopoverController

开发者 https://www.devze.com 2023-03-22 12:25 出处:网络
I would like to reset the state of a UISwitch in a UIPopoverController from my MainViewController. I assume a simple

I would like to reset the state of a UISwitch in a UIPopoverController from my MainViewController. I assume a simple

popoverView.switchName.on = NO;

wont do the job (as it doesnt seem to 开发者_高级运维be working). Whats the best way to do this? Thank you.


The UIPopoverController is the container for the content view controller that is shown inside the frame. I assume at some point you are calling initWithContentViewController with a view controller that presents the content and that this view controller has the switchName property.

To access this view controller you can use the contentViewController property of the UIPopoverController. I imagine it will be something like:

// assuming popoverView is a UIPopoverController and that the type of 
// the view contorller you pass to initWithContentViewController is YourViewController
YourViewController * myController = (YourViewController*)popoverView.contentViewController;
myController.switchName.on = NO;
0

精彩评论

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