我已经完成了两个视频,并使用以下代码将视图控制器与父视图控制器连接起来:
- (IBAction)searchbuttonClicked:(ID)sender { NSLog(@"It works."); SearchVIEwController *searchVIEwControl = [self.storyboard instantiateVIEwControllerWithIDentifIEr:@"SearchControllerNav"]; [self presentVIEwController:searchVIEwControl animated:YES completion:nil];}
这段代码确实有效,因为这与我用于其他模态视图控制器的格式相同,所以我知道这不是问题.
无论如何,当我点击视图控制器中的搜索按钮时,它应该d出SearchVIEwController.但是,应用程序崩溃了,它给了我这个错误信息:
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.'
我正在为这个应用程序使用Storyboard.
有什么东西我不见了吗?先感谢您.
一个附带问题:我也收到一个警告,说当指示isFiltered == YES时,指针和整数之间的比较(‘BOol *'(又名’signed char *’)和’int’).无论如何要解决它吗?
这是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
注意:我做了一些编辑以满足我的需求.
解决方法 您是否尝试将@interface SearchVIEwController:UItableVIEwController更改为@interface SearchVIEwController:UIVIEwController我强烈怀疑你没有将你的UItablevIEw作为VIEw附加在XIB中,或者你的类应该派生UIVIEwController而不是UItablevIEwController类.
总结以上是内存溢出为你收集整理的ios – 加载笔尖但没有得到UITableView全部内容,希望文章能够帮你解决ios – 加载笔尖但没有得到UITableView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)