貌似愚蠢的問題,但...:裏面的UISearchBar UINavigationController的
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.bar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 20.0, self.navigationController.view.bounds.size.width, HEADER_HEIGHT)];
mySearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:bar contentsController:self];
mySearchDisplayController.delegate = self;
mySearchDisplayController.searchResultsDataSource = self;
mySearchDisplayController.searchResultsDelegate = self;
[self.navigationController.view addSubview:self.bar];
所有的行爲都工作正常,而我不要按取消或牆根的tableview。 之後,搜索欄關閉,我看到一個清晰的導航欄,沒有搜索欄。 我已更改爲viewDidload,但沒有任何更改。
開始打印前:
後:
能不能介紹一下你所看到的行爲解釋一下? 'viewWillAppear'並不是真正的這種代碼的地方。 'viewDidLoad'更合適。 – 2011-04-15 01:08:27