L'Échec d'Assertion dans UITableViewController
Je prends la iTunes U Stanford iOS Classe et je travaille sur une mission de construire un peu de Flickr app. J'obtiens une erreur que je n'arrive pas à être en mesure de débogage qui vient comme
* Échec d'Assertion dans -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2280.1/UITableView.m:5336 extrait de 2012-08-03
10:59:24.596 travail 4[4611:c07] (null) de la libc++abi.dylib: mettre fin à
appelé à la levée d'une exception
Mon code pour le tableviewcontroller en question:
#import "PlacesPhotosTableViewController.h"
@interface PlacesPhotosTableViewController ()
@property (nonatomic) NSDictionary *placeToDisplay;
@property (nonatomic) NSArray *photosInPlace;
@end
@implementation PlacesPhotosTableViewController
@synthesize placeToDisplay = _placeToDisplay;
@synthesize photosInPlace = _photosInPlace;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
//Custom initialization
}
return self;
}
- (id)init
{
self = [super init];
return self;
}
- (id)initWithPlace:(NSDictionary *)place
{
self = [self init];
if (self)
{
self.placeToDisplay = place;
}
return self;
}
- (NSArray *)photosInPlace
{
if (_photosInPlace == nil)
{
_photosInPlace = [FlickrFetcher photosInPlace:self.placeToDisplay maxResults:50];
}
return _photosInPlace;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog([self.placeToDisplay valueForKeyPath:@"description._content"]);
//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.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
//Return the number of rows in the section.
return [self.photosInPlace count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Photos";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSString *string = [[self.photosInPlace objectAtIndex:indexPath.row] valueForKeyPath:@"description._content"];
cell.textLabel.text = string;
return cell;
}
- Voir également enregistrer votre identificateur de cellule. stackoverflow.com/questions/15813498/...
Vous devez vous connecter pour publier un commentaire.
CellIdentifier
Je parie que votrecellForRowAtIndexPath
est de retournil
.C'est probablement pourquoi
[UITableView _configureCellForDisplay:forIndexPath:]
est un échec... parce quecellForRowAtIndexPath
retourne une valeur null et puisconfigureCellForDisplay
s'attend à uneUITableViewCell
.Cette ligne ici
Ne ce match de la cellule identifiant dans votre scénario? J'ai trouvé ce qui ne correspond pas a la cause du problème pour moi!
J'ai connu le même problème et de le résoudre cause j'ai oublié d'ajouter
maintenant sa résolu.
Vous n'êtes pas la Création de Cellules dans la méthode
Vous seulement la réutilisation de la cellule à partir de cette méthode qui renvoie la
nil
initialement.Vous avez à créer des cellules par cette donnée ci-dessous de code dans votre méthode.