【发布时间】:2014-11-24 06:27:29
【问题描述】:
我是 iOS 开发的新手。我想在我的应用程序中制作一个应用程序,我制作了一个 UIScrollview,并在这个 UIScrollView 中添加了一个 UIImageview。当 viewDidAppear 我将 imageview 图像设置为
-(void)viewDidAppear:(BOOL)animated
{
NSDictionary *dict=[self.imagesa objectAtIndex:0];
NSString *imagelink=[dict valueForKey:@"link"];
NSLog(@"imageLink %@",imagelink);
[self.bigImage sd_setImageWithURL:[NSURL URLWithString:imagelink] placeholderImage:[UIImage imageNamed:@"1.png"]];
}
以及为我的 Imageview 和 Scrollvie 添加手势的代码,例如
UISwipeGestureRecognizer *swipeGestureLeftdirection=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(slideToLeftWithGestureRecognizer:)];
swipeGestureLeftdirection.delegate=self;
swipeGestureLeftdirection.direction=UISwipeGestureRecognizerDirectionLeft;
[self.bigImage addGestureRecognizer:swipeGestureLeftdirection];
[self.bigScrollview addGestureRecognizer:swipeGestureLeftdirection];
UISwipeGestureRecognizer *swipeGestureRightdirection=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(slideToRighttWithGestureRecognizer:)];
swipeGestureRightdirection.delegate=self;
swipeGestureRightdirection.direction=UISwipeGestureRecognizerDirectionRight;
[self.bigImage addGestureRecognizer:swipeGestureRightdirection];
[self.bigScrollview addGestureRecognizer:swipeGestureRightdirection];
这里 Self.bigimage 是我的 UIImageview,self.bigScrollview 是我的 UIScrollView。 现在我想要当用户向左滑动时我想要 UIImageview 图像作为 self.imagesa 下一个索引,当向右滑动时我想要 UIImageVIew 图像返回索引图像。请给我解决方案。
【问题讨论】:
-
显示您的 UISwipeGestureRecognizer 操作
-
@Sport UISwipeGestureRecognizer action -(void)slideToLeftWithGestureRecognizer:(UISwipeGestureRecognizer *)gestureRecognizer { for(index=0;index
标签: ios uiscrollview uiimageview uiswipegesturerecognizer