开发者

Modalview information from another viewcontrol

I am trying to send label data from one viewcontrol to be presented in another view control.

The code sends the info from the button, what I need to understand is how to send the Label info.

Opens the modal:

-(IBAction) showModal:(id)sender {
    outputLabel.text=@"Nothing Chosen";
    [[(ContentViewController *)self.parentViewController outputLabel] 
     setText:[sender currentTitle]];

switch (transitionStyle.selectedSegmentIndex) {
        开发者_如何学编程modalContent.modalTransitionStyle=
        UIModalTransitionStyleCrossDissolve;
        break;
        }
[self presentModalViewController:modalContent animated:YES];
}

Received the modal back:

-(IBAction) hideModal:(id)sender {
      outputLabel2.text=@"12" ;
    [[(Corina3ViewController *)self.parentViewController outputLabel] 
     setText:[sender currentTitle]];
    [self dismissModalViewControllerAnimated:YES];   

}

I want to send the label info to the model. The label is "clearbLabel".


Create a label object in your modalView and set it at the - showModal: method

modalView:

// @interface
UILabel *clearLabel
// don't forget to @synthesize
-(IBAction) showModal:(id)sender {
    // your code;
    [modalView setClearLabel: clearLabel];
}

You can even nil it out after:

-(IBAction) hideModal:(id)sender {
    // your code;
    [modalView setClearLabel: nil];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜