2011-07-14 4 views
0

splitviewcontrollerに問題があります。 私は以下のコードを持っています。アプリケーションを実行して、テーブルであるrootviewcontrollerを押すと、次のビューがdetailviewではなくrootviewcontrollerの部分に表示されました。 コードのどの部分が間違っているのか分かりますか?SplitViewControllerの問題

多くのおかげ

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    // Set up the cell 
    Travel_Packer_HDAppDelegate *appDelegate = (Travel_Packer_HDAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    Animal *animal = (Animal *)[appDelegate.animals objectAtIndex:indexPath.row]; 

    [cell setText:animal.name]; 
    return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    // Navigation logic -- create and push a new view controller 
    Travel_Packer_HDAppDelegate *appDelegate = (Travel_Packer_HDAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    Animal *animal = (Animal *)[appDelegate.animals objectAtIndex:indexPath.row]; 

    if(self.animalView == nil) { 
     DetailViewController *viewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil]; 
     self.animalView = viewController; 
     [viewController release]; 
    } 

    // Setup the animation 
    [self.navigationController pushViewController:self.animalView animated:YES]; 
    // Set the title of the view to the animal's name 
    self.animalView.title = [animal name]; 
    // Set the description field to the animals description 
    [self.animalView.animalDesciption setText:[animal description]]; 
    // Load the animals image into a NSData boject and then assign it to the UIImageView 
    NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[animal imageURL]]]; 
    UIImage *animalImage = [[UIImage alloc] initWithData:imageData cache:YES]; 
    self.animalView.animalImage.image = animalImage; 

} 

答えて

1

私はあなたの分割ビューコントローラの各ペインのナビゲーションコントローラを持って理解できるように? そして、おそらく次の行の問題:あなただけの左側のナビゲーションコントローラにanimalViewをプッシュしたけど、あなたが右(詳細ペイン)1を必要とする原因に

[self.navigationController pushViewController:self.animalView animated:YES]; 

関連する問題