Objective-C 및 Xcode를 처음 사용하며보기를 변경하는 데 어려움이 있습니다. UIScrollView
을 사용하여 이미지보기간에 스 와이프 할 수 있다고 생각하지만 오른쪽으로 스 와이프하여보기를 변경하고 왼쪽으로 스 와이프하여 돌아갑니다. 나는 변경되지 않은 AppDelegate.h
과 AppDelegate.m
을 가지고 있습니다.스 와이프 제스추어보기 컨트롤러 Xcode 5.1.1
ViewController.h : ViewController.h
및 ViewController.m
아래에서 언급
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
ViewController.m :
#import "ViewController.h"
#import "ViewController2.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
//sets up gesture recognizer
UISwipeGestureRecognizer *swipeRightGesture=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)];
[self.view addGestureRecognizer:swipeRightGesture];
swipeRightGesture.direction=UISwipeGestureRecognizerDirectionRight;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)sender
{
NSUInteger touches = sender.numberOfTouches;
if (touches == 2)
{
if (sender.state == UIGestureRecognizerStateEnded)
{
ViewController2 *vc2 = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil];
[self.navigationController pushViewController:vc2 animated:YES];
}
}
}
@end
I는 I을 따라서 스토리 보드 번째 관점에 연결 한 ViewController2.h
및 ViewController2.m
을 위의 handleSwipeGesture
메서드에 연결된 제스처를 사용하십시오.
는 u는 두 손가락을 사용하여 슬쩍 싶어? 또는 손가락 하나만 사용하면됩니까? – iOSDeveloper