2016-06-16 10 views

答えて

0

まず、ボタンのアクションを作成する必要があります。通常はCtrl + dragです。そのアクション実装では、宛先ViewControllerを割り当てる必要があります。

- (IBAction)buttonTapped { 
    MyViewController *modalViewController = [MyViewController new]; 
    [self presentViewController:modalViewController animated:YES completion:nil]; 
} 

、あなたのファイルがコードで提示されるように、私はあなたがそれとのViewControllerの両方ViewControllersとストーリーボード上にないことを仮定しているペン先であることを言ったので:コードは次のようなものになるだろうベース。そうでない場合は、あなたの質問を詳述してください。

要求されたよう:ストーリーボード

- (IBAction)buttonTapped { 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:nil]; 
    RSSViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"RSSVC"]; 
    // OR If is initial 
    // RSSViewController *viewController = [storyboard instantiateInitialViewController]; 

    viewController.feedURL = @"..."; 
    [self presentViewController:viewController animated:YES completion:nil]; 
} 

からVCをロードあなたが必要な場合は、のViewController識別子はストーリーボードでのアイデンティティインスペクタで設定する必要があります。

Storyboard Identity Inspector

+0

はい、xibビューコントローラは同じストーリーボードにありません。特定のビューコントローラを表示するためにボタンを接続するにはどうすればよいですか? – jmwhite132

+0

また、このボタンは、次のView ControllerがRSSフィードにロードする必要があるリストのURLと言うデータを渡すことができますか? – jmwhite132

+0

@ jmwhite132私は自分の答えを改善しました。それが役に立てば幸い。 –

0

下のスクリーンショットに

まず参照してください:​​

第二ボタンを制御する+ドラッグ:あなたは、マウスを離したら、それはenter image description here

第三に、あなたにボックスを示しています。クリックしてください接続のドロップダウンボックス.Itは3つのオプションを示しますenter image description here

第4:ドロップダウンからアクションを選択または選択します。

5:最後に、あなたがしたい、私が理解できるように、アクションメソッドがViewContoller.m

#import "SecondViewController.h" 

- (IBAction)actionGoNextPage:(id)sender 
{ 
    SecondViewController *secondVC = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil]; 
    [self presentViewController:secondVC animated:YES completion:nil]; 
} 
1

に続いて

- (IBAction)actionGoNextPage:(id)sender; 

あるViewContoller.hになりましたアクション名にenter image description here

を与えますボタンクリック時に新しいviewControllerをプッシュします。試してみてください

- (IBAction)buttonClicked { 
    MyViewController *myViewController = [[MyViewController alloc]init]; 
    [self presentViewController: myViewController animated:YES completion:nil]; 
} 
関連する問題