【问题标题】:How can I pass a value NSLabel from one representation to another. With storyboard如何将值 NSLabel 从一种表示形式传递到另一种表示形式。带故事板
【发布时间】:2012-07-12 10:55:48
【问题描述】:

如何将值从一个控制器传递到另一个控制器?我使用故事板。

-(void) prepareForSegue:(UIStoryboardPopoverSegue *)segue sender:(id)sender
{
    if ([segue.identifier hasPrefix:@"FinishController"]) {
        FinishController *asker = (FinishController *) segue.destinationViewController;
        asker.FinishDesc = @"What do you want your label to say?";
        asker.FinishTitle = @"Label text";
        asker.FinishPoint = @"asdas";
    }
}

我想出现在第一个视图的突出显示的文本视图上。

调用下一个视图的代码,我觉得应该是这样的: UIStoryboard *finish = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

     UIViewController *viewController = [finish instantiateViewControllerWithIdentifier:@"FinishController"];

     viewController.modalPresentationStyle = UIModalPresentationPageSheet;
     [self presentModalViewController:viewController animated:YES];

完成控制器:

- (void)viewDidLoad
{
    self.lblFinishTitle.text=self.FinishTitle;
    self.lblFinishDesc.text = self.FinishDesc;
    self.lblFinishPoint.text=self.FinishPoint;
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

【问题讨论】:

    标签: iphone objective-c xcode cocoa-touch storyboard


    【解决方案1】:

    可以使用全局变量吗?如果是这样,请看一下名为“extern”的东西。希望这能给你一个方向=]

    【讨论】:

    • 比如说,在 Example1.h 中,在 header 区域放置“extern UILabel *testLabel”。然后在 Example1.m 的标题区域中,放下“UILabel *testLabel”。然后在您要使用该值的 Example2.m 中,包括 Example1.h。
    • 你的决定很糟糕 = \
    猜你喜欢
    • 1970-01-01
    • 2015-06-23
    • 2015-06-06
    • 2012-03-11
    • 2011-10-08
    相关资源
    最近更新 更多