Ios PerformsgueWithIdentifier完全不起作用

Ios PerformsgueWithIdentifier完全不起作用,ios,xcode,uitableview,identifier,segue,Ios,Xcode,Uitableview,Identifier,Segue,嗨,我正在尝试根据用户选择的内容推送到不同的视图。我有一个带有4个其他视图控制器的表视图,通过故事板中的推送序列链接到它。所有分段都直接链接到TableView控制器。根据选定的单元,它将加载相应的视图。以下是我使用的代码: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ NSDictionary *dictionary = [_articles o

嗨,我正在尝试根据用户选择的内容推送到不同的视图。我有一个带有4个其他视图控制器的表视图,通过故事板中的推送序列链接到它。所有分段都直接链接到TableView控制器。根据选定的单元,它将加载相应的视图。以下是我使用的代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


    NSDictionary *dictionary = [_articles objectAtIndex:indexPath.row];
    NSArray *selectedKey = [dictionary objectForKey:@"Key"];


    if ([selectedKey isEqual:@"Driver"]){

        self.driverDetailView.wikiItem = dictionary;
        [self.driverDetailView performSegueWithIdentifier:@"pushDriver" sender:dictionary];
        NSLog(@"Push Driver");
    }

    if ([selectedKey isEqual:@"Team"]) {
        NSLog(@"Push Team");
    }
}


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    NSLog(@"Preparing For Segue");
    if ([[segue identifier] isEqual:@"pushDriver"]) {
        self.driverDetailView=segue.destinationViewController;
    }

}
出于某种原因

 [self.driverDetailView performSegueWithIdentifier:@"pushDriver" sender:dictionary];
 NSLog(@"Push Driver");
不允许我在开始时设置为Self,我会收到一个错误消息:

TableCell没有可见的@interface声明选择器 使用标识符进行性能测试

如果我使用self.driverDetailView,我不会得到错误,但是当我选择单元格时,什么也不会发生

这是水平视图

#import <UIKit/UIKit.h>
#import "HorizontalDetailView.h"
#import "HorizontalTableCell.h"
@interface HorizontalTableView : UITableViewController <UITableViewDelegate,   UITableViewDataSource> {

NSDictionary *_articleDictionary;
NSMutableArray *_reusableCells;

}

@property (nonatomic, retain) NSDictionary *articleDictionary;
@property (nonatomic, retain) NSMutableArray *reusableCells;


@end
HorizontalTableCell.h的代码为:

#import <UIKit/UIKit.h>
#import "HorizontalDetailView.h"
#import "DriverDetailView.h"
#import "HorizontalTableView.h"
@interface HorizontalTableCell : UITableViewCell <UITableViewDelegate, UITableViewDataSource> {

    UITableView *_horizontalTableView;
    NSMutableArray *_articles;
    HorizontalTableCell *horizontalTableCell;

}


@property (nonatomic, strong) UITableView *horizontalTableView;
@property (nonatomic, strong) NSMutableArray *articles;
@property (nonatomic, strong) HorizontalDetailView *horizontalDetailView;
@property (nonatomic, strong) DriverDetailView *driverDetailView;
@property (nonatomic, strong) HorizontalTableCell *horizontalTableCell;
@end

如果我没弄错的话,您已经将segues连接到了表视图单元格。如果这是正确的,我建议将它们从视图控制器本身连接到目标视图控制器,然后调用[self-PerformsgueWithIdentifier:@pushDriver];在didSelectRowAtIndexPath:方法中

感谢您的回复,我已经将所有4个segue连接到视图控制器,并且上面的代码已经在didSelectRowatIndexPath中实现,当我选择单元格时,不会发生任何事情。我无法将其设置为[self-PerformsgueWithIdentifier:@pushDriver],因为我收到一个错误。我必须将其设置为[self.driverdeailview performsguewithidentifier:@pushDriver]哦,我的错是没有更仔细地阅读您的代码。driverDetailView是实现这些方法的类的实例吗?从错误消息中可以看出,正在对UITableViewCell的子类调用performsgueWithIdentifier:方法。是的,它被调用是因为DidSelectRowatinex方法所在的位置。我尝试将DidSelectRowatinex方法放在UITableView的子类中,但它不起作用。该表是一个水平滚动表,在自定义单元格中有一个自定义单元格,只是为了让事情变得更复杂一点!表视图委托和数据源方法的正确位置是拥有表视图的视图控制器的实现。确保在添加的视图控制器的头文件中。然后,您的didSelectRowatineXpath方法将通知表视图的委托,即所属的视图控制器,它应使用Identifier:执行GUEGUE,UIViewController及其子类将识别该选择器。感谢您的快速回复。我检查了HorizontalTableView.h,我已经声明了。我仍然会收到错误消息No visible@interface for HorizontalTableCell声明选择器您还想看到其他代码吗?我会把它加到问题上。谢谢
#import <UIKit/UIKit.h>
#import "HorizontalDetailView.h"
#import "DriverDetailView.h"
#import "HorizontalTableView.h"
@interface HorizontalTableCell : UITableViewCell <UITableViewDelegate, UITableViewDataSource> {

    UITableView *_horizontalTableView;
    NSMutableArray *_articles;
    HorizontalTableCell *horizontalTableCell;

}


@property (nonatomic, strong) UITableView *horizontalTableView;
@property (nonatomic, strong) NSMutableArray *articles;
@property (nonatomic, strong) HorizontalDetailView *horizontalDetailView;
@property (nonatomic, strong) DriverDetailView *driverDetailView;
@property (nonatomic, strong) HorizontalTableCell *horizontalTableCell;
@end
#import "HorizontalTableCell.h"
#import "ControlVariables.h"
#import "ArticleCell.h"
#import "HorizontalDetailView.h"
@implementation HorizontalTableCell

@synthesize horizontalTableView = _horizontalTableView;
@synthesize articles = _articles;
@synthesize horizontalDetailView;
@synthesize driverDetailView;
@synthesize horizontalTableCell;

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.articles count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";

    ArticleCell *cell = (ArticleCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil){
        cell = [[ArticleCell alloc] initWithFrame:CGRectMake(0, 0, kCellWidth, kCellHeight)];
    }

    NSDictionary *currentArticle = [self.articles objectAtIndex:indexPath.row];

    cell.thumbnail.image = [UIImage imageNamed:[currentArticle objectForKey:@"Image"]];
    cell.titleLabel.text = [currentArticle objectForKey:@"Title"];

    return cell;
}

- (void)dealloc{
    self.horizontalTableView = nil;
    self.articles = nil;
}

- (NSString *) reuseIdentifier{
    return @"HorizontalCell";
}

- (id)initWithFrame:(CGRect)frame{
    if ((self = [super initWithFrame:frame])){
        self.horizontalTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kCellHeight, kTableLength)];
        self.horizontalTableView.showsVerticalScrollIndicator = NO;
        self.horizontalTableView.showsHorizontalScrollIndicator = NO;
        self.horizontalTableView.transform = CGAffineTransformMakeRotation(-M_PI * 0.5);
        [self.horizontalTableView setFrame:CGRectMake(kRowHorizontalPadding * 0.5, kRowVerticalPadding *
                                                      0.5, kTableLength - kRowHorizontalPadding, kCellHeight)];

        self.horizontalTableView.rowHeight = kCellWidth;
        self.horizontalTableView.backgroundColor = kHorizontalTableBackgroundColor;

        self.horizontalTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        self.horizontalTableView.separatorColor = [UIColor clearColor];

        self.horizontalTableView.dataSource = self;
        self.horizontalTableView.delegate = self;
        [self addSubview:self.horizontalTableView];
    }

    return self;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSDictionary *dictionary = [_articles objectAtIndex:indexPath.row];
    NSArray *selectedKey = [dictionary objectForKey:@"Key"];
    // NSLog(@"Selected Key = %@",selectedKey);

    if ([selectedKey isEqual:@"Driver"]){

        self.driverDetailView.wikiItem = dictionary;
        [self performSegueWithIdentifier:@"pushDriver" sender:self];
        NSLog(@"Push Driver");
    }

    if ([selectedKey isEqual:@"Team"]) {
        NSLog(@"Push Team");
    }

    if ([selectedKey isEqual:@"Tech"]) {
        NSLog(@"Push Tech");
    }

    if ([selectedKey isEqual:@"Track"]) {
        NSLog(@"Push Track");
    }

    //self.horizontalDetailView.wikiItem = dictionary;

    // NSLog(@"selected Array = %@",dictionary);

}


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    NSLog(@"Preparing For Segue");
    if ([[segue identifier] isEqual:@"pushDriver"]) {
        self.driverDetailView=segue.destinationViewController;
    }
}

@end