
这是我的代码(减去所有解析xml部分):
(.H)
#import <UIKit/UIKit.h>#import <Foundation/Foundation.h>@interface MetamorphVIEwController : UItableVIEwController <UISearchbarDelegate,UISearchdisplayDelegate>{ IBOutlet UItableVIEw * newstable; UISearchbar *searchbar; UISearchdisplayController *searchdisplayController; UIActivityIndicatorVIEw * activityIndicator; CGSize cellSize; NSXMLParser * RSSParser; NSMutableArray * storIEs; NSArray * newStorIEs; NSMutableArray *filteredStorIEs; Nsstring *dataType; Nsstring *IDname; BOol *uploaded; BOol isFiltered; NSMutableDictionary * item; Nsstring * currentElement; NSMutableString * currentTitle,* currentDate,* currentSummary,* currentlink,* currentModule,*currentOwner,*currentOwnername;}- (voID)parseXMLfileAtURL:(Nsstring *)URL typeOfModule:(Nsstring *)typeOfData;@end (.M)
- (voID)vIEwDIDLoad { self.navigationItem.rightbarbuttonItem = self.editbuttonItem; searchbar = [[UISearchbar alloc] initWithFrame:CGRectMake(0,70,320,44)]; [searchbar setShowsScopebar:YES]; [searchbar setScopebuttonTitles:[[NSArray alloc] initWithObjects:@"OBJ",@"C",nil]]; searchdisplayController = [[UISearchdisplayController alloc] initWithSearchbar:searchbar contentsController:self]; searchdisplayController.delegate = self; searchdisplayController.searchResultsDataSource = self; [searchdisplayController setSearchResultsDelegate:self]; self.tableVIEw.tableheaderVIEw = searchbar; [self.tableVIEw reloadData]; self.tableVIEw.scrollEnabled = YES;}-(voID)searchbar:(UISearchbar *)searchbar textDIDChange:(Nsstring *)searchText{ NSLog(@"test"); //nspredicate *filterPredicate = [nspredicate predicateWithFormat:@"SELF beginswith[c] %@",searchbar]; //newStorIEs = [storIEs filteredArrayUsingPredicate:filterPredicate]; //NSLog(@"newStorIEs %@",newStorIEs);}解决方法 您尚未将searchset设置为searchbar对象.在那之后: [searchbar setShowsScopebar:YES];
加:
searchbar.delegate = self;
不要忘记添加< UISearchbarDelegate>协议.
总结以上是内存溢出为你收集整理的ios – UISeachBar和委托方法全部内容,希望文章能够帮你解决ios – UISeachBar和委托方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)