鉴于以下UITableViewController
,为什么我不能得到任何UISearchBarDelegate
方法被调用?我省略了UITableViewDelegate
和UITableViewDataSource
方法。UITableViewController <UISearchBarDelegate>不调用UISearchBarDelegate方法
#import <UIKit/UIKit.h>
@interface OpportunitySearchViewController : UITableViewController <UISearchBarDelegate>
@end
#import "OpportunitySearchViewController.h"
@interface OpportunitySearchViewController()
@end
@implementation OpportunitySearchViewController
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
NSLog(@"initWithCoder:");
};
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"self=%@ self.view=%@ ", self, [self view]);
}
- (void)viewDidUnload {
[super viewDidUnload];
NSLog(@"viewDidUnload");
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSLog(@"shouldAutorotateToInterfaceOrientation:");
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - UISearchBarDelegate
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
NSLog(@"searchBar:textDidChange:");
}
@end
我已经证实了我的故事板场景配置为使用OpportunitySearchViewContoller
类,我已经证实,在现场UISearchBar
有急救员设置为它的委托。虽然这可能是错误的,但我无法在故事板界面中找到文件所有者。
帮助,将不胜感激。
是否在您的手机搜索栏? PLZ在“tableView:cellForRowAtIndexPath:”方法中显示我们的代码。 – 2012-07-24 05:14:17
尝试为您的搜索栏创建一个插座,并将其连接到故事板中的搜索栏并将该代理程序设置在程序中。 – 2012-07-24 05:16:00