【发布时间】:2012-07-30 03:13:29
【问题描述】:
我有两个控制器 A 和 B 在 B 中有一个标签和一个字符串 在A中我写了下面的代码
B *ObjB =[[B alloc]initWithNibName:@"B" bundle:nil];
ObjB.Mylabel.text=[NSString stringWithString:@"Add New name"];
ObjB.MyString=[NSString stringWithString:@"new string name"];
[self.navigationController pushViewController:ObjB animated:YES];
[ObjB release];
我只得到 B 中的 ObjB.MyString 值,没有得到标签文本。谁能帮忙。提前谢谢。
【问题讨论】:
-
你试过在
[self.navigationController pushViewController:ObjB animated:YES];之后设置ObjB.Mylabel.text=[NSString stringWithString:@"Add New name"];吗? -
这取决于您的需要。您可以创建一个 Singleton 类以在类之间共享数据。可以看我之前的回答如何制作单例类here
标签: iphone objective-c ios