0

次の場合、呼び出されるメソッドをUITableViewController取得できないのはなぜですか?とメソッドUISearchBarDelegateを省略しています。UITableViewDelegateUITableViewDataSource

#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、シーンのオンにファーストレスポンダーがデリゲートとして設定されていることを確認しました。それは間違っているかもしれませんが、ストーリーボードインターフェイスでファイルの所有者を見つけることができませんでした。

助けていただければ幸いです。

4

1 に答える 1

0

ファーストレスポンダーをデリゲートとしてクラスに接続しないでください。検索バーからコントローラーオブジェクト自体にドラッグし、への接続を確立しますdelegate

于 2012-07-24T05:27:13.523 に答える