IOS7 在 segue 之前在不同 View 中更改标签值(同一 Controller )

标签 ios objective-c

我的 Storyboard 中有 2 个简单 View ,它们都使用相同的 ViewController。我有以下代码来切换第二个 View ...

self.labelStatus.text = @"CHECKING";
[self performSegueWithIdentifier:@"LoginSuccess" sender:sender];

*labelStatus 在第二个 View 上。

出于某种原因,标签文本没有改变。谁能告诉我这是为什么?

最佳答案

[self performSegueWithIdentifier:@"LoginSuccess" sender:sender];

//在prepareForSegue:方法中更改标签值

- (void)prepareForSegue:(UIStoryboardSegue *)segue {
    if ([segue.identifier isEqualToString:@"LoginSuccess"]) {
        UIViewController *loginVC = segue.destinationViewController;

       //declare the string in .h file and assign it in viewDidLoad in loginVC

        loginVC.labelString = @"CHECKING";
    }
}

loginViewController.h文件中

@property(nonatomic, strong) NSString *labelString;

loginViewController.m文件中

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.labelStatus.text = labelString
}

关于IOS7 在 segue 之前在不同 View 中更改标签值(同一 Controller ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21205988/

相关文章:

ios - 在 x 秒后快速删除标签

ios - 如何在 iOS 应用程序中减小谷歌地图的屏幕尺寸

iphone - 获取带有动态绘制引脚的 MKAnnotationView 子类

ios - Objective-C - 具有特定子字符串的 NSRegularExpression

ios - 将所有捆绑资源复制到 Documents 目录内的单独文件夹中

objective-c - Cocoa 在没有托管对象上下文的情况下无法执行操作

ios - 将数据传递给 Swift 中的容器 View ?

objective-c - 在dealloc中应该将什么样的属性设置为nil?

ios - swift : How can I make UITextView in UITableViewCell firstresponder

ios - 滚动 UIImageView 图像