鉴于以下UITableViewController
情况,为什么我UISearchBarDelegate
不能调用任何方法?我省略了UITableViewDelegate
andUITableViewDataSource
方法。
#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
我已确认我的 Storyboard 场景已配置为使用OpportunitySearchViewContoller
该类,并且我已确认UISearchBar
现场已将 First Responder 设置为它的委托。虽然这可能是错误的,但我在情节提要界面中找不到文件所有者。
帮助将不胜感激。