Note that there are some explanatory texts on larger screens.

plurals
  1. POLoaded the nib but didn't get a UITableView
    primarykey
    data
    text
    <p>I have been following this tutorial on YouTube (<a href="http://www.youtube.com/watch?v=P2yaZXn4MU0" rel="nofollow">part 1</a> and <a href="http://www.youtube.com/watch?v=VQRuY7FTo-o" rel="nofollow">part 2</a>).</p> <p>I have completed both videos and have hooked up the view controller with the parent view controller using this code:</p> <pre><code>- (IBAction)searchButtonClicked:(id)sender { NSLog(@"It works."); SearchViewController *searchViewControl = [self.storyboard instantiateViewControllerWithIdentifier:@"SearchControllerNav"]; [self presentViewController:searchViewControl animated:YES completion:nil]; } </code></pre> <p>This code indeed works since this is the same format that I use for my other modal view controllers, so i know that's not the problem.</p> <p>Anyway, when I tap on the search button in the view controller, it should pop up the <code>SearchViewController</code>. However, the app crashes instead and it gives me this error message:</p> <pre><code>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.' </code></pre> <p>I am using Storyboards for this app.</p> <p>Is there something that I'm missing? Thank you in advance.</p> <p>A side question: I'm also getting a warning, saying <code>Comparison between pointer and integer ('BOOL *' (aka 'signed char *') and 'int')</code> whenever <code>isFiltered == YES</code> is shown. Is there anyway to fix it?</p> <p>Here is the code for <code>SearchViewController</code>:</p> <p><strong>SearchController.h</strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface SearchViewController : UITableViewController &lt;UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate&gt; { } - (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 </code></pre> <p><strong>SearchViewController.m</strong></p> <pre><code>#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 </code></pre> <p>NOTE: There are a few edits that I made to fit my needs.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload