【发布时间】:2014-10-03 22:50:32
【问题描述】:
我正在使用 xcode 中的情节提要,并且在 prepareForSegue 方法期间它崩溃了。我想要做的是在我单击一个单元格后从一个表格视图进入另一个详细的表格视图。这是代码。
GamesInfoViewController.m
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"ShowDetails"]) {
DetailViewController2 *detailViewController = [segue destinationViewController];
NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];
NSUInteger row = [myIndexPath row];
GameInfo *gameInfoObject;
gameInfoObject =[GamesInfoArray objectAtIndex:row];
detailViewController.DetailArray = @[gameInfoObject.HomeTeam, gameInfoObject.AwayTeam]; // IT CRASHES HERE!!!
}
}
这里是 DetailViewController2.m
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
GamesInfoTableViewCell *cell = (GamesInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MainCell"];
cell.mainLabel.text = _DetailArray[0];
cell.awayTeamLabel.text = _DetailArray[1];
// Configure the cell...
return cell;
}
DetailViewController2.h
#import <UIKit/UIKit.h>
@interface DetailViewController2 : UITableViewController
@property (strong, nonatomic) NSArray *DetailArray;
@end
是的,我已选择 DetailViewController2 作为故事板中的自定义类!!!
错误消息:'NSInvalidArgumentException',原因:'-[UINavigationController setDetailArray:]: unrecognized selector sent to instance 0x7fa65a537f00'
【问题讨论】:
-
请发布无法识别的选择器。
-
请发布您收到的错误消息。
-
添加到问题底部!
-
DetailViewController2 是 UINavigationController 的子类还是嵌入在 UINavigationController 中?
-
它是一个子类,有关系吗?
标签: ios objective-c uitableview selector uistoryboardsegue