[英]How to slide up a view after user touches an image in NSMutableArray
用戶觸摸NSMutableArray中的圖像后,如何滑動Web視圖基本上,我希望能夠為每個圖像提供一個觸摸事件,因此,如果用戶觸摸圖像“ ban3.png”,它將向上滑動視圖我已經創建了(WebView),感謝您的幫助。
碼
[imagesQueue = [[NSMutableArray alloc] init];
[imagesQueue addObject:[UIImage imageNamed:@"ban3.png"]];
[imagesQueue addObject:[UIImage imageNamed:@"ban1.png"]];
[imagesQueue addObject:[UIImage imageNamed:@"ban2.png"]];
//Put the last image on imageBack (UIImageView)
imageBack.image = [imagesQueue objectAtIndex:[imagesQueue count] - 1];
//Insert the last image item from array to the first position
[imagesQueue insertObject: imageBack.image atIndex:0];
//Remove the last image item from array
[imagesQueue removeLastObject];
//Change UIImageView alpha
//The desired opacity of the image, specified as a value between 0.0 and 1.0.
//A value of 0.0 renders the image totally transparent while 1.0 renders it fully opaque.
//Values larger than 1.0 are interpreted as 1.0.
imageFront.alpha = 1.0;
imageBack.alpha = 0.0;
//Call nextImageAnimation add the next picture and produce the infinite loop
[self nextImageAnimation];
只需遍歷數組並向每個圖像添加UITapGestureRecognizer:
for(UIView *image in self.myImages)
{
UITapGestureRecognizer* recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
recognizer.numberOfTapsRequired = 1;
recognizer.numberOfTouchesRequired = 1;
[image addGestureRecognizer: recognizer];
}
然后在您的handleTap:
方法中向上滑動視圖(也許更改其框架)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.