大佬教程收集整理的这篇文章主要介绍了objective-c – Xcode:如何使用滑动手势更改UIPageControl值?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
#import <UIKit/UIKit.h> @interface PageViewController : UIViewController @property (strong,nonatomiC) IBOutlet UIImageView *dssview; - (IBACtion)changephoto:(UIPageControl *)sender; @end
#import "PageViewController.h" @interface PageViewController () @end @implementation PageViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundLeorNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundLeorNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBACtion)changephoto:(UIPageControl *)sender { _dssview.image = [UIImage imagenamed: [NSString StringWithFormat:@"%d.jpg",sender.currentPage+1]]; } @end
任何帮助将不胜感激.
谢谢@H_874_3@
您可以参考以下代码.
将滑动手势添加到视图控制器@H_874_3@
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@SELEctor(swipe:)]; swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft; [self.view addGestureRecognizer:swipeLeft]; UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@SELEctor(swipe:)]; swipeRight.direction = UISwipeGestureRecognizerDirectionRight; [self.view addGestureRecognizer:swipeRight];
滑动手势选择器@H_874_3@
- (void)swipe:(UISwipeGestureRecognizer *)swipeRecogniser { if ([swipeRecogniser direction] == UISwipeGestureRecognizerDirectionLeft) { self.pageControl.currentPage -=1; } else if ([swipeRecogniser direction] == UISwipeGestureRecognizerDirectionRight) { self.pageControl.currentPage +=1; } _dssview.image = [UIImage imagenamed: [NSString StringWithFormat:@"%d.jpg",self.pageControl.currentPage]]; }
@interface PageViewController : UIViewController @property (strong,nonatomiC) IBOutlet UIImageView *dssview; @property (strong,nonatomiC) IBOutlet UIPageControl *pageControl; - (IBACtion)changephoto:(UIPageControl *)sender; @end
以上是大佬教程为你收集整理的objective-c – Xcode:如何使用滑动手势更改UIPageControl值?全部内容,希望文章能够帮你解决objective-c – Xcode:如何使用滑动手势更改UIPageControl值?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。