我是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
答案 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];
}