Note that there are some explanatory texts on larger screens.

plurals
  1. POUISearchBar and UITableView
    primarykey
    data
    text
    <p>I am getting the following error when i run my app,</p> <p>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "2-view-3" nib but didn't get a UITableView.'</p> <p>The following are the code i am using,</p> <p>ViewController.h</p> <pre><code>@interface ViewController : UITableViewController &lt;UISearchDisplayDelegate,UITableViewDataSource,UITableViewDelegate&gt; @property (nonatomic,strong) NSArray *arForTable; @property (nonatomic,strong) NSArray *arForSearch; </code></pre> <p>ViewController.m</p> <pre><code>@implementation ViewController @synthesize arForTable = _arForTable; @synthesize arForSearch = _arForSearch; -(void)awakeFromNib { [super awakeFromNib]; } - (void)viewDidLoad { [super viewDidLoad]; self.arForTable = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys:@"Pending",@"name",@"2",@"value",nil], [NSDictionary dictionaryWithObjectsAndKeys:@"Pent",@"name",@"22",@"value",nil], [NSDictionary dictionaryWithObjectsAndKeys:@"Pen",@"name",@"5",@"value",nil], [NSDictionary dictionaryWithObjectsAndKeys:@"Neon",@"name",@"7",@"value",nil], [NSDictionary dictionaryWithObjectsAndKeys:@"Spark",@"name",@"99",@"value",nil], nil]; self.arForSearch = nil; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return (tableView == self.tableView)?self.arForTable.count:self.arForSearch.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil) { cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier]; } NSDictionary *dToAccess = (self.tableView==tableView)?[self.arForTable objectAtIndex:indexPath.row] : [self.arForSearch objectAtIndex:indexPath.row]; [(UILabel*)[cell viewWithTag:1] setText:[dToAccess valueForKey:@"name"]]; [(UILabel*)[cell viewWithTag:2] setText:[dToAccess valueForKey:@"value"]]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (void)filterContentForSearchText:(NSString*)str{ // for inCaseSensitive search str = [str uppercaseString]; NSMutableArray *ar=[NSMutableArray array]; for (NSDictionary *d in self.arForTable) { NSString *strOriginal = [d valueForKey:@"name"]; // for inCaseSensitive search strOriginal = [strOriginal uppercaseString]; if([strOriginal hasPrefix:str]) { [ar addObject:d]; } } self.arForSearch=[NSArray arrayWithArray:ar]; } - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString { [self filterContentForSearchText:searchString]; // Return YES to cause the search result table view to be reloaded. return YES; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } </code></pre> <p>Thanks In Advance</p>
    singulars
    1. This table or related slice is empty.
    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