2011-07-28 8 views
1

したがって、ナビゲーションコントローラーをタブバーコントローラーに埋め込むアプリケーションがあります。私はデータを取得するNSMutableArrayを持っています。配列のインデックスが表示されないナビゲーションバーのコントローラーのコントローラ

問題は、テーブルビューが表示され、1つをクリックすると詳細ビューが表示されますが、実際にはうんざりしたパターンになります。セル2を初めてクリックすると、セル2の詳細ビューが表示されます。 「Back」をクリックして「Cell 2」をもう一度クリックすると、詳細ビ​​ューは表示されず、「Cell 3」をクリックすると「Cell 2 Detail View」が表示され、「Back」をクリックするたびに注文が変更されます。私は何が間違っていますか?

#pragma mark - View lifecycle methods 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    searchResultsArray = [[NSMutableArray alloc] initWithObjects:@"Producer 1", @"Producer 2",@"Producer 3", nil]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
             reuseIdentifier:CellIdentifier] autorelease]; 



    cell.textLabel.text = [searchResultsArray objectAtIndex:indexPath.row]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

    return cell; 
} 

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    NearMeDetailViewController *nmdvController = [[NearMeDetailViewController alloc] initWithNibName:@"NearMeDetailViewController" bundle:nil]; 

    NSLog(@"%i", indexPath.row); 

    nmdvController.producerName = [searchResultsArray objectAtIndex:indexPath.row]; 

    NSLog(@"%@", [searchResultsArray objectAtIndex:indexPath.row]); 

    [self.navigationController pushViewController:nmdvController animated:YES]; 
    [nmdvController release]; 
} 

答えて

3

あなたが追加され、選択解除しながら、ナビゲーションコントローラにプッシュ:ここではいくつかのコードを支援することです。

選択を解除するのはいつですか?他のものを選択している間。

例:

あなたが最初cell1.ok

その後、

選択セル2を選択しています。

ですから、cell1は最初に選択を解除してからcell2を選択します。

あなたのコードを選択解除していました。したがって、次のセルまたは他のセルの選択時に毎回押し込まれます。

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

} 

not 

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{ 

} 
+0

私は結果 –

+0

よ、これはそれを知らせてください。私が間違っているのは、私たちが間違っていることがわかっているのです。 – yretuta

関連する問題