Chargé de la plume, mais n'a pas obtenu une UITableView

J'ai suivi ce tutoriel sur YouTube (partie 1 et partie 2).

J'ai terminé les deux vidéos et ont accroché le point de vue du contrôleur avec le parent-vue-contrôleur à l'aide de ce code:

- (IBAction)searchButtonClicked:(id)sender {
    NSLog(@"It works.");

    SearchViewController *searchViewControl = [self.storyboard instantiateViewControllerWithIdentifier:@"SearchControllerNav"];

    [self presentViewController:searchViewControl animated:YES completion:nil];

}

Ce code fonctionne vraiment puisque c'est le même format que j'utilise pour mon autre mode de vue des contrôleurs, donc je sais que ce n'est pas le problème.

De toute façon, quand j'appuie sur le bouton de recherche dans la vue du contrôleur, il devrait sortir le SearchViewController. Toutefois, l'application se bloque à la place, et il me donne ce message d'erreur:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "jp7-vt-IdA-view-Jer-xW-qlD" nib but didn't get a UITableView.'

J'utilise les Storyboards de cette application.

Il y a une chose que je suis absent? Je vous remercie à l'avance.

Un côté de la question: je suis également un avertissement, disant Comparison between pointer and integer ('BOOL *' (aka 'signed char *') and 'int') chaque fois que isFiltered == YES est indiqué. Est-il de toute façon à résoudre ce problème?

Voici le code pour SearchViewController:

SearchController.h

#import <UIKit/UIKit.h>

@interface SearchViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate> {

}
- (IBAction)cancelButtonTapped:(id)sender;

@property (weak, nonatomic) IBOutlet UISearchBar *mySearchBar;
@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@property (nonatomic, strong) NSMutableArray *itemsInCloudApp;
@property (nonatomic, strong) NSMutableArray *filteredList;
@property BOOL *isFiltered;


@end

SearchViewController.m

#import "SearchViewController.h"
@interface SearchViewController ()
@end
@implementation SearchViewController
@synthesize mySearchBar, myTableView, itemsInCloudApp, filteredList, isFiltered;
- (void)viewDidLoad
{
[super viewDidLoad];
//Set title.
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
titleLabel.text = @"Search";
titleLabel.adjustsFontSizeToFitWidth = YES;
titleLabel.clipsToBounds = YES;
titleLabel.numberOfLines = 1;
titleLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:18];
titleLabel.textColor = [UIColor blackColor];
titleLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight;
titleLabel.textAlignment = NSTextAlignmentCenter;
[titleLabel sizeToFit];
self.navigationItem.titleView = titleLabel;
//Alloc and init list.
itemsInCloudApp = [[NSMutableArray alloc]initWithObjects:@"http://www.apple.com/", @"http://www.trijstudios.com/", @"http://www.google.com/", @"http://www.squarespace.com/", @"http://www.youtube.com/", nil];
}
- (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.
if (isFiltered == YES) {
return [filteredList count];
} else {
return [itemsInCloudApp count];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//Configure the cell...
if (isFiltered == YES) {
cell.textLabel.text = [filteredList objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [filteredList objectAtIndex:indexPath.row];;
} else {
cell.textLabel.text = [itemsInCloudApp objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [itemsInCloudApp objectAtIndex:indexPath.row];
}
return cell;
}
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
if (searchText.length == 0) {
//Set bollean flag
isFiltered = NO;
} else {
//Set boolean flag
isFiltered = YES;
//Alloc and init our fliteredData
filteredList = [[NSMutableArray alloc] init];
//Fast enumeration
for (NSString *name in itemsInCloudApp) {
NSRange nameRange = [name rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound) {
[filteredList addObject:name];
}
}
}
//Reload tableView
[myTableView reloadData];
}
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[mySearchBar resignFirstResponder];
}
- (IBAction)cancelButtonTapped:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
@end

REMARQUE: Il y a quelques modifications que j'ai fait pour l'adapter à mes besoins.

Cochez cette.. stackoverflow.com/questions/11221802/...
C'était en fait le premier que je suis allé à l'avant de poser cette question, mais il n'a pas aidé.
J'ai posté une réponse ici stackoverflow.com/questions/11221802/... j'espère que cela vous aide, vous et merci de voter si elle n'. Merci!

OriginalL'auteur chrisjr | 2013-11-27