开发者

How to transfer value between tow xib in Utility Application template?

开发者 https://www.devze.com 2023-02-22 11:35 出处:网络
In Utility Application Template, how to transfer the state of UISwitch of FlipsideViewController.m to MainViewController.m ?

In Utility Application Template, how to transfer the state of UISwitch of FlipsideViewController.m to MainViewController.m ?

This is the method of button of MainViewController.m

- (IBAction)doSomething:(id)sender{
<sound method>
<button action>

}

According the selected of UISwitch of FlipsideViewController.m , judge use 'sound method' or not. 开发者_Go百科could you help me overcome this issue please?


Make a bool as property in your main view and when your switch changes its state then in its IBAction assign proper value to the main view property. for example

in main view .h -

BOOL switchState;

@property (nonatomic) BOOL switchState;

in main view .m

@synthesize switchState;

in flip view .h

IBOutlet UISwitch *switch;

-(IBAction) switchValueChanged:(id) sender;

in flip view . m

-(IBAction) switchValueChanged:(id) sender
{   
    //create/get instance of your main view
    //for example it is mainView then

    if (switch.on) 
    {
        mainView.switchState = TRUE
    }
    else 
    {
        mainView.switchState = TRUE
    }

}
0

精彩评论

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