我有一个问题,当我的代码执行时,然后单击表上的项目,它将带我到详细视图。一切正常显示,但在控制台中显示以下消息:


  2013-03-27 13:09:30.616 LinkTest [3605:c07]通话不平衡
  开始/结束外观转换
  。


我知道这是经常在这里报告的,并通过答案进行了检查,但似乎没有任何效果。也许我出了点问题。这是tableviewcontroller的代码:

#import "EventListingTableViewController.h"
#import "EventListingDetailViewController.h"

@interface EventListingTableViewController ()

@end

@implementation EventListingTableViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}


-(void)fetchEventDetails
{
    NSData *jsonData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://xsysdevelopment.com/ios/read.php"]];
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];
    self.eventsTitles = [[NSMutableArray alloc] init];
    self.eventsCity = [[NSMutableArray alloc] init];

    for(id object in dict){
        [self.eventsTitles addObject:object[@"title"]];
        [self.eventsCity addObject:object[@"city"]];
    }

}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self fetchEventDetails];
    // 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;


}


- (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 the number of rows in the section.
    return self.eventsTitles.count;
}

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

     int row = [indexPath row];

    cell.textLabel.text = self.eventsTitles[row];
    cell.detailTextLabel.text = self.eventsCity[row];

    return cell;
}




#pragma mark - Table view delegate

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

    // Navigation logic may go here. Create and push another view controller.

     EventListingDetailViewController *detailViewController = [[EventListingDetailViewController alloc] initWithNibName:@"EventListingDetailViewController" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];

}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
     if ([[segue identifier] isEqualToString:@"eventDetailSeague"])
     {

         NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
         EventListingDetailViewController *detailViewController = [segue destinationViewController];

         int row = [indexPath row];

         detailViewController.eventDetails = @[self.eventsTitles[row], self.eventsCity[row]];



     }
}


如果有人告诉我我要去哪里错了,我将非常感激。我是iOS新手,因此只有有用的批评才有用。

问候

最佳答案

如果您正在通过UITableView的情节提要板使用segues,则不需要didSelectRowAtIndexPath:中的代码。相信您会因此而两次开枪。

10-06 13:26