2017-08-11 2 views
-1

M目的コンテナビューを使用して目的を指定します。セグメント化されたコントローラを使用して2つのコンテナビューで作業する

ここでは、セグメント化されたコントローラを使用して1つずつ2つのコンテナを表示しようとします。 2つのコンテナ使用コンテナ名はcontainerViewA、containerViewBです。 私はコンテナViewBだけが負荷であるアプリケーションを実行しています。

コード:

@interface ViewController() 
@property (weak, nonatomic) IBOutlet UIView *containerViewA; 
@property (weak, nonatomic) IBOutlet UIView *containerViewB; 
@end 

- (IBAction)ShowComponent:(UISegmentedControl *)sender { 
    if (sender.selectedSegmentIndex == 0) { 
     [UIView animateWithDuration:(0.5) animations:^{ 
      self.containerViewA.alpha = 1; 
      self.containerViewB.alpha = 0; 
     }]; 
    } else { 
     [UIView animateWithDuration:(0.5) animations:^{ 
      self.containerViewA.alpha = 0; 
      self.containerViewB.alpha = 1; 
     }]; 
    } 
} 

更新:

enter image description here

アップデート1:

ストーリーボードサイドパネル。

enter image description here

+0

問題点は何ですか? – Akhilrajtr

+0

最初のコンテナは表示されません。@ Akhilrajtr –

+0

sender.selectedSegmentIndexの値をifの前に印刷して、それを伝えてみてください。 – 3stud1ant3

答えて

1

@property (weak, nonatomic) IBOutlet UIView *containerViewA;@property (weak, nonatomic) IBOutlet UIView *containerViewB;が正しく接続されていることを確認してください。

+1

'@property(weak、nonatomic)IBOutlet UIView * containerViewA;および '@property(weak、nonatomic)IBOutlet UIView * containerViewB;が接続されています。他のすべては正しいようです。 – Akhilrajtr

+0

は、両方のコンテナがコンテナであると言うことを意味しますか? –

+1

@GanganiRoshanいいえ私は彼がストーリーボードのビューへの接続とこれらのアウトレットを確立すべきことを彼が意味すると思います – 3stud1ant3

関連する問題