2012-07-20 3 views
0

사용자가 NSMutableArray에서 이미지를 터치 한 후 웹 뷰를 위로 이동하는 방법은 무엇입니까? 기본적으로 각 이미지에 터치 이벤트를 부여 할 수 있기를 원합니다. 사용자가 "ban3.png"이미지를 터치하면 이미 만든보기 (WebView)로 슬라이드됩니다. 미리 도움을 주셔서 감사합니다. 당신의 배열을사용자가 NSMutableArray의 이미지를 터치 한 후 뷰를 슬라이드하는 방법

코드

[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];  

답변

0

그냥 루프와 각 이미지에 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: 방법 단지 (이것은 아마도 프레임의 변경)보기를 밀어 넣습니다.

관련 문제