的視圖控制器,它有兩個views.in第一ViewController
有一個tableview
。當第一個單元格從tableview
選擇,它加載另一種觀點與其它tableview
與搜索選項。然後從tableview
的搜索結果中,選擇一個單元格後,當前視圖應該消除。爲什麼不能排除在我的應用程序在didSelectRowAtIndexPath方法方法
- 我的第一個問題是我無法從搜索結果中選擇一個單元格direclty。我必須點擊兩次。
- 我的第二個問題是不能dimiss的
viewcontroller
這是我的代碼
- (void)updateSearchResultsForSearchController:(UISearchController *)searchController
{
NSString *enteredString = searchController.searchBar.text;
if ([enteredString length] >= 3) {
[self getAirportCodesFromWebService:enteredString];
}
[self.airportTable reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [airportArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
GetAirportTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse" forIndexPath:indexPath];
GetAirport *getAirports = [airportArray objectAtIndex:indexPath.row];
cell.AirportName.text = getAirports.AirportName;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
GetAirport *getAirports = [airportArray objectAtIndex:indexPath.row];
NSString *selectedAirport = getAirports.AirportName;
[[NSUserDefaults standardUserDefaults] setObject:selectedAirport forKey:@"selectedairport"];
[[NSUserDefaults standardUserDefaults] synchronize];
[self dismissViewControllerAnimated:YES completion:nil];
}
我用UISearchController
編程爲searh.inside它,我根據用戶inputs.help我呼籲web服務這個
你是怎麼來到這第二個視圖控制器的 –
把fisrt'cell'拖到新的控制檯上並選擇'show'作爲'Storyboard segue' –
你可以試試模態..? –