2017-08-15 6 views
0

をロードすることはありません、他のビューコントローラからプッシュされ、私はストーリーボードで作成しUITableViewでビューコントローラを持っています。テーブル内の画像の1つをスワイプすると、現在のView Controller(SecondViewController)がxibファイル(SpeciesViewController.xib)をロードして「アプリケーションを利用する」ようにして新しいビューにしたいと思います。今のところ、didSelectRowAtIndexPathがスワイプで呼び出されますが、xibファイルは決してロードされません。ビューコントローラが私のタブベースのアプリケーションで

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    SpeciesViewController* speciesController = [[[SpeciesViewController alloc]initWithNibName:@"SpeciesViewController" bundle:nil] autorelease]; 

    // SpeciesViewController* speciesController = [[SpeciesViewController alloc] init]; 
    Species *theSpecies = [fetchedResultsController objectAtIndexPath:indexPath]; 
    speciesController.theSpecies = theSpecies; 

    switch (sortBySegmentedControl.selectedSegmentIndex) { 
     case kSortByCommonNameFirst: 
      speciesController.title = [theSpecies commonNameFirstLast]; 
      break; 
     case kSortByCommonNameLast: 
      speciesController.title = [theSpecies commonNameLastFirst]; 
      break; 
     case kSortByScientificName: 
      speciesController.title = [[NSString alloc] initWithFormat:@"%@%@", 
             [theSpecies.scientificName substringToIndex:1], 
             [[theSpecies.scientificName substringFromIndex:1] lowercaseString]]; 
      break; 
     default: 
      break; 
    } 

    speciesController.hidesBottomBarWhenPushed = YES; 
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil]; 

    //// Store current index path for viewDidAppear animation. //// 
    self->currentSelectedIndexPath = indexPath; 

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

} 

SpeciesViewControllerペン先は、属性インスペクタでそのカスタムクラスとしてSpeciesViewControllerを持っています。この理由から、pushViewController:speciesControllerのときに、ViewDidLoad、またはその他の方法がSpeciesViewController.mから呼び出されると思います。

ペン先の取り付けに関する問題の多くは、initWithNibNameinitWithCoderの間違いと関連しています。しかし、私は正しくビューコントローラからそうしているので、initWithNibNameを正しく使用していると思います。

ご協力いただきありがとうございます。どうもありがとうございます!

答えて

0

私はペン先名が正しい

SpeciesViewController* speciesController = [[SpeciesViewController alloc]initWithNibName:@"SpeciesViewController" bundle:nil] ; 

であり、また、私はあなたが私は自己を推測し、それを行っていない場合は、NavigationControllerの内側にあなたのtableviewcontrollerを最初に埋め込む必要があると思うなら、あなたはこれが動作するはずです、自動解放を使用してはならないと思います.navigationControllerlerは現在nilです。

あなたはこの

[self presentViewController:speciesController animated:YES completion:nil]; 

のようなビューコントローラを提示することができますが、それは私が実際にナビゲーションコントローラを必要としないSecondViewController` `からペン先をロードするための方法はあり

+0

を役に立てば幸い? – Matt

+0

@Mattはいあなたが表示コントローラを提示することができます、私の更新された答えを確認してください、顔の問題があれば、 – 3stud1ant3

+0

presentViewControllerが働いてください - ありがとう! – Matt

関連する問題