0

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

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 新手,所以只有有用的批评才会有用。

问候

4

1 回答 1

1

如果您通过情节提要使用 segues,UITableView那么您不需要didSelectRowAtIndexPath:. 我相信您会因此而两次推动。

于 2013-03-27T14:17:15.580 回答