Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 主详细信息-不同的单元格对应不同的UITableViewController_Iphone_Ios_Uitableview_Master Detail - Fatal编程技术网

Iphone 主详细信息-不同的单元格对应不同的UITableViewController

Iphone 主详细信息-不同的单元格对应不同的UITableViewController,iphone,ios,uitableview,master-detail,Iphone,Ios,Uitableview,Master Detail,我在将不同的TableViewCell连接到不同的UITableViewController时遇到问题。第一个cellrow连接到正确的TableViewController,但之后就不能再连接了,因为我真的不知道如何在这里设置else if语句 提前谢谢 请参阅.mmaster: #import "GuideTableViewController.h" #import "GuideDetailTableViewController.h" #import "GuideDetailTableVie

我在将不同的TableViewCell连接到不同的UITableViewController时遇到问题。第一个cellrow连接到正确的TableViewController,但之后就不能再连接了,因为我真的不知道如何在这里设置else if语句

提前谢谢

请参阅.mmaster:

#import "GuideTableViewController.h"
#import "GuideDetailTableViewController.h"
#import "GuideDetailTableViewController2.h"
#import "GuideDetailTableViewController3.h"
#import <QuartzCore/QuartzCore.h>

@interface GuideTableViewController (){
    NSArray *guide;
    NSMutableData *weatherResponseData;

}
@property (weak, nonatomic) IBOutlet UITableView *tableView;


@property (weak, nonatomic) IBOutlet UIImageView *imgHeader;


@property (weak, nonatomic) IBOutlet UIImageView *ImgTitle;


@property (weak, nonatomic) IBOutlet UIImageView *ImgWeather;


@property (weak, nonatomic) IBOutlet UIButton *btnMap;

@property (weak, nonatomic) IBOutlet UILabel *LabelWeather;

@end

@implementation GuideTableViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}



//JSON method
- (void) loadJSON{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //code
        NSData *data = [NSData dataWithContentsOfURL:[NSURL   URLWithString:@"https://dl.dropbox.com/u/100670549/test.json"]];

        NSError *error;

        if (data)
        {

            guide = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];

            for (NSDictionary *dictionary in guide){
                //NSLog([dictionary description]);
            }


        }else
        {
            NSLog(@"Could not load data");
        }




            dispatch_sync(dispatch_get_main_queue(), ^{
                // code
                [self.tableView reloadData];
            });


    });


    }




- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    //Call json

    [self loadJSON];

    [self loadWeather];







    //set background
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage    imageNamed:@"background.jpg"]];

    //rounded corners

    [self.tableView.layer setCornerRadius:9.0];

    [self.ImgWeather.layer setCornerRadius:9.0];






}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


//TableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];


    NSDictionary *dict = [guide objectAtIndex:indexPath.row];
    cell.textLabel.text = [dict valueForKey:@"title"];

    return cell;
}


//To detailView

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

    if ([segue.identifier isEqualToString:@"showStay"]){
        GuideDetailTableViewController *tvc = [segue destinationViewController];
        NSIndexPath *index = sender;
        NSDictionary *dict = [guide objectAtIndex:index.row];

        tvc.stay = dict;


    }
    else if([segue.identifier isEqualToString:@"showEat"]){
        GuideDetailTableViewController2 *tvc = [segue destinationViewController];
        NSIndexPath *index = sender;
        NSDictionary *dict = [guide objectAtIndex:index.row];

        tvc.eat = dict;
    }
    else if([segue.identifier isEqualToString:@"showDo"]){
        GuideDetailTableViewController3 *tvc = [segue destinationViewController];
        NSIndexPath *index = sender;
        NSDictionary *dict = [guide objectAtIndex:index.row];

        tvc.todo = dict;
    }


}

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

    [self performSegueWithIdentifier:@"showStay" sender:indexPath];


}


- (void) viewWillAppear:(BOOL)animated{
    UITableViewCell *cell = [self.tableView     cellForRowAtIndexPath:self.tableView.indexPathForSelectedRow];

    //ta bort markeringen när man går tillbaka till master från detailView.
    [cell setSelected:NO];


    //Hide navbar
    [self.navigationController setNavigationBarHidden:YES];
}


//Show navbar in detailView
-(void)viewWillDisappear:(BOOL)animated{
    [self.navigationController setNavigationBarHidden:NO];   
}






@end

你的代码现在做什么?你想让它做什么?你试过什么吗?另外,如果答案能帮助你解决问题,请接受。阅读Stackoverflow常见问题解答。嗨,当我单击MasterTableView中的第一个单元格时,我会进入右侧的DetailTableView。问题是我在主机中的其他单元。我想将它们连接到不同的DetailTableView。那么,您是否试图在一个表中包含三行,当单击它们时,所有这些行都链接到不同的UIViewController?你在使用故事板吗?丹尼尔,改进你的问题,而不仅仅是在评论中添加内容。