スワイプするとビューを変更しようとしています。背景色を変更してこれをテストしたので、スワイプ作業が見つかりました。
それ以来、新しい view.nib を追加し、クラスを現在のビューと同じに設定しました。このclasses .hファイル内でこれを行いました
@interface MasterViewController : UIViewController <UIGestureRecognizerDelegate>{
UIView *myView;
UIView *secondView;
}
@property (strong, nonatomic) IBOutlet UIView *myView; // attached to Viewcontroller nib
@property (strong, nonatomic) IBOutlet UIView *secondView; // attached to the secondView
- (void)swipedScreen;
MyView は最初に表示されるメイン ビューです。secondView は、このビューに関連するようにクラスを作成および変更した nib のビューです。
そこから、.mファイルでこれを行いました
- (void) setupSwipeGestureRecognizer {
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedScreen)];
swipeGesture.direction = (UISwipeGestureRecognizerDirectionRight|UISwipeGestureRecognizerDirectionLeft);
[myView addGestureRecognizer:swipeGesture];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"Prototype";
[self setupSwipeGestureRecognizer];
}
- (void)swipedScreen
{
// Not sure what to do here.
[[NSBundle mainBundle] loadNibNamed:@"SecondView" owner:self options:nil];
}
secondView を表示するために swipedScreen メソッドで何をすべきかわかりません..このビューをアニメーション化して右からスライドインしたいと思います..ここで何が間違っているのかわかりませんが、明らかに非常に基本的なことです。
どんな助けでも大歓迎です。