我想从一个表视图的细节视图切换。 当我点击细胞崩溃。 我用休息,试图找到其中的代码崩溃,但我不能找到一个特定的线。 当从表视图到详细视图进行SEGUE崩溃。 我想一些变量传递到详细信息视图,但我首先需要把它切换到详细信息视图。 我使用的故事板仅供参考。 任何帮助,将不胜感激。
UPDATE:崩溃日志如下
arg c = (int) 1
arg v = (char **) 0x2fd63cdc
这是该行的崩溃是
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
更新2
代码的最后一节之前,当我逐句通过代码是SEGUE功能准备崩溃。 的代码在那里的最后一行后,它崩溃,转到上述行。
更新3
我意识到控制台被隐藏,所以这是在控制台显示了错误。 无论我在赛格瑞准备nslogs的被称为。
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<DetailViewController 0x1e098bd0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.'
*** First throw call stack:
(0x3a1e63e7 0x39072963 0x3a1e60d5 0x3a418fe9 0x3a414d53 0x3a16c8a5 0x39665d7d 0x396655ff 0x3955e039 0x394e8421 0x3953d1b7 0x3953d0fd 0x3953cfe1 0x3953cf0d 0x3953c659 0x3953c541 0x3952ab33 0x3952a7d3 0x3958b2ad 0x3960dca1 0x3a4b9e67 0x3a1bb857 0x3a1bb503 0x3a1ba177 0x3a12d23d 0x3a12d0c9 0x3746633b 0x3951d291 0x69a9 0x3a91eb20)
libc++abi.dylib: terminate called throwing an exception
RootViewController.m
#import "RootViewController.h"
#import "DetailViewController.h"
@implementation RootViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];
//Add items
[listOfItems addObject:@"Jane"];
[listOfItems addObject:@"Johnny"];
[listOfItems addObject:@"Deanne"];
[listOfItems addObject:@"John"];
[listOfItems addObject:@"Susan"];
//Set the title
self.navigationItem.title = @"Countries";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [listOfItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Set up the cell...
NSString *cellValue = [listOfItems objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
DetailViewController *DVC = [[DetailViewController alloc]init];
DVC = [segue destinationViewController];
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
NSString *name = [listOfItems objectAtIndex:path.row];
DVC.name1.text = name;
}
RootViewController.h
#import <UIKit/UIKit.h>
@interface RootViewController : UITableViewController <UITableViewDataSource,UITableViewDelegate> {
NSMutableArray *listOfItems;
IBOutlet NSMutableArray *detailListOfItems;
}
@end
DetailViewController.m
#import "DetailViewController.h"
@implementation DetailViewController
@synthesize selectedCountry;
@synthesize name1;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//Set the title of the navigation bar
//self.navigationItem.title = name1.text;
}
DetailViewController.h
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController
@property (nonatomic,strong) IBOutlet UILabel *name1;
@property (nonatomic, retain) NSString *selectedCountry;
@end