0

ユーザーが NSMutableArray の画像に触れた後、webview をスライドアップするにはどうすればよいですか?私はすでに( 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];    
4

1 に答える 1

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:メソッドでビューを上にスライドします(おそらくフレームを変更します)。

于 2012-07-20T16:01:04.440 に答える