滑动图像单击iphone中的右键和左键

时间:2014-01-14 13:54:46

标签: iphone

我是IOS编程的新手,目前我在uiview上有一个带有滑动图像的图像应用程序。我有疑问。

我想在点击右侧button时向右滑动图片,并在iphone中点击左侧button时将图片向左滑动。  我正在使用此代码: -

.h文件

#import<UIKit/UIKit.h>

@interface flashViewcontroller : UIViewController<UIScrollViewDelegate>

@property (nonatomic, strong) IBOutlet UIScrollView *scrollView;

@property (nonatomic, strong) IBOutlet UIPageControl *pageControl;

@property (nonatomic, strong) NSArray *pageImages;

@property (nonatomic, strong) NSMutableArray *pageViews;

@property(nonatomic,strong) IBOutlet UIButton *next;

@property(nonatomic,strong) IBOutlet UIButton *previous;

-(void)loadVisiblePages;

-(void)loadPage:(NSInteger)page;

-(void)purgePage:(NSInteger)page;

-(IBAction)next:(id)sender;

-(IBAction)previos:(id)sender;

-(IBAction)skipes:(id)sender;
@end

1 个答案:

答案 0 :(得分:0)

//左键单击

-(IBAction)click_LeftBtn:(id)sender{
        [imgView setFrame:CGRectMake(imgView.frame.orign.x, imgView.frame.orign.y, imgView.frame.size.width, imgView.frame.size.height)];
       [UIView beginAnimations:nil context:NULL];
       [UIView setAnimationDuration:.5];  //// Set Animationt time Duration
       [imgView setFrame:CGRectMake(0, imgView.frame.orign.y, imgView.frame.size.width, imgView.frame.size.height)];
       [UIView commitAnimations];
}

//右键单击

-(IBAction)click_RightBtn:(id)sender
{
        [imgView setFrame:CGRectMake(imgView.frame.orign.x, imgView.frame.orign.y, imgView.frame.size.width, imgView.frame.size.height)];
       [UIView beginAnimations:nil context:NULL];
       [UIView setAnimationDuration:.5];  //// Set Animationt time Duration
       [imgView setFrame:CGRectMake(320-imgView.frame.size.width, imgView.frame.orign.y, imgView.frame.size.width, imgView.frame.size.height)];
       [UIView commitAnimations];
}