【问题标题】:Modalview information from another viewcontrol来自另一个视图控件的模态视图信息
【发布时间】:2011-05-26 22:32:14
【问题描述】:

我要疯了。

我正在尝试从一个视图控件发送标签数据以显示在另一个视图控件中。

下面从按钮发送信息,我正在寻找的是如何发送标签信息,

打开 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];
}

收到 MODAL BACK

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

}

我想将标签信息发送给模型,,标签是“clearbLabel”

杰森

【问题讨论】:

  • 这里的控制器流程很难理解。根据您将父视图控制器投射到的内容,这两种方法似乎不在同一个控制器中。你能再描述一下你的问题吗?

标签: ios properties uiviewcontroller


【解决方案1】:

在您的 modalView 中创建一个标签对象并将其设置在 - showModal: 方法中

模态视图:

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

您甚至可以在之后将其取消:

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

【讨论】:

  • 您没有添加@property 行
猜你喜欢
  • 1970-01-01
  • 2020-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多