我的问题是当 FirstViewController 中的 SecondViewController 实例为变量 ID 赋值时,问题是我不能使用 Segue 和 NaviagtioController.. 也许解决方案使用静态变量?,怎么做,或者告诉我一个提示?
我这样做的代码:
// In the class FirstViewController.m
#import "SecondViewController"
NSString *identifier = [NSString stringWithFormat:@"%@", [self.cat objectAtIndex:indexPath.row]];
// Start the code causes an error
ViewControllerOne *instance = [[ViewControllerOne alloc]init];
instance.ID = [[NSString alloc] initWithFormat:@"%@",identifier];
// End code causes error
// In the SecondViewController.h
@property (nonatomic, retain) NSString *ID;
// In the SecondViewController.m
@synthesize ID;
调试错误:
2013-05-03 09:01:42.126 TheFreeApp [19880:c07] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“必须使用非零布局参数初始化 UICollectionView”*第一次抛出调用堆栈:(0x1cbc012 0x10f9e7e 0x1cbbdeb 0x53d748 0x558b1b 0x558646 0x11eff8 0x11f232 0x5588d5 0xbf5b 0x11ce1e 0xb74e 0xed285 0xed4ed 0xaf75b3 0x1c7b376 0x1c7ae06 0x1c62a82 0x1c61f44 0x1c61e1b 0x1c167e3 0x1c16668 0x3dffc 0x2bcd 0x2af5) libc++abi.dylib: terminate called throwing an exception (lldb)