0
- (void)configureView

{
  lblwelcome.text=@"Welcome To Gallery World";
    for (UIImageView *subview in self.view.subviews) {
        [subview removeFromSuperview];
    }

    UIBarButtonItem *addAcc = [[UIBarButtonItem alloc]
                               initWithTitle:@"Zoom"
                               style:UIBarButtonItemStylePlain
                               target:self
                               action:@selector(zoomEnabled)];

    UIBarButtonItem *delAcc = [[UIBarButtonItem alloc]
                               initWithTitle:@"Rotate"
                               style:UIBarButtonItemStylePlain
                               target:self
                               action:@selector(rotateEnabled)];

    NSArray *arrBtns = [[NSArray alloc]initWithObjects:addAcc,delAcc, nil];
    self.navigationItem.rightBarButtonItems = arrBtns;

    categoryScrollX=30;
    categoryScrollY=30;




    [scr.delegate self];
    scr.frame = self.view.frame;
    for (UIImageView *subview in scr.subviews) {
        [subview removeFromSuperview];
    }
    height = 200;
    width = 400;
    pos_y =0;
    pos_x =0;
    int idx=0;
    CGFloat x=0;
    switch (_itemNo) {
        case 0:
            for(int i=1;i<6;i++)
            {//imageView.frame = CGRectMake(categoryScrollX, categoryScrollY, (self.view.frame.size.width/4)-25, self.view.frame.size.width/4-5);
                UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(categoryScrollX, categoryScrollY, (self.view.frame.size.width/4)-25, self.view.frame.size.width/4-5)];
                [image setImage:[UIImage imageNamed:[NSString stringWithFormat:@"e1%d.png",i]]];
                [scr addSubview:image];
                x+=320;
                UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
                tapGesture.numberOfTapsRequired = 1;
                tapGesture.delegate = self;
                image.userInteractionEnabled = YES;
                [image addGestureRecognizer:tapGesture];
//                [image.layer setBorderColor: [[UIColor yellowColor] CGColor]];
//                [image.layer setBorderWidth: 0.9];
//                image.layer.MasksToBounds = false;
//                image.layer.ShadowColor = [[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.5].CGColor;
//                image.layer.ShadowOpacity = 1.0f;
//                image.layer.ShadowOffset = CGSizeMake(0, 2.5f);
//                image.clipsToBounds = NO;

                CALayer* layer = [image layer];
                [layer setBorderWidth:2.0f];
                [image setContentMode:UIViewContentModeScaleAspectFit];
                [layer setBorderColor:[UIColor whiteColor].CGColor];


                scr.minimumZoomScale = scr.frame.size.width / imgview.frame.size.width;
                scr.maximumZoomScale = 2.0;
                [scr setZoomScale:scr.minimumZoomScale];
                scrollPosition++;
                currentIndex++;
                if(scrollPosition>4)
                {
                    categoryScrollY = categoryScrollY+self.view.frame.size.width/4+12;
                    scrollPosition=0;
                    currentIndex = currentIndex+scrollPosition;
                    categoryScrollX=30;
                }
                else
                {
                    categoryScrollX= (categoryScrollX+self.view.frame.size.width/4)-6;
                }


            }

            scr.pagingEnabled=YES;
            scr.contentSize = CGSizeMake(320*5, 300);


             _detailDescriptionLabel.text=@"Accessories";
             self.title=@"Accessories";
            [self.view addSubview:scr];

            break;

.....按照上述方式使用不同图像的其他情况....

上面是我的配置视图,我只是在 UiScrollview 中添加了一些动态图像,并且我在每个图像上添加了点击手势......具有以下内容

-(void)handleSingleTap:(UITapGestureRecognizer *)rec{

    for (UIImageView *subview in scr.subviews) {
        [subview removeFromSuperview];
    }

    UIView *img = [rec view];
    img.frame = self.view.frame;
    [self.view addSubview:img];

}

现在我想要的是在点击后我想为该图像提供旋转效果.. 只是这个 Xcode 环境以及 iOS 开发的初学者。

一些我如何成功地在 uiscrollview 中显示图像..但是在谷歌搜索之后我找不到旋转图像的良好指导。所以任何人都可以帮助我在图像被点击后在 uiscrollview 中对 uiimageview 图像进行旋转?

4

2 回答 2

1

试试这样

-(IBAction)ButtonAction:(id)sender{
    CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
        fullRotation.fromValue = [NSNumber numberWithFloat:0];
        fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
        fullRotation.duration = 1;
        fullRotation.repeatCount = 1;
        [imageview.layer addAnimation:fullRotation forKey:@"360"];

}

取一个按钮并为该按钮执行操作(调用此方法)。

于 2013-03-25T10:00:53.230 回答
0

您可以使用以下代码旋转 imageView:

imageView.transform = CGAffineTransformMakeRotation(angle);

于 2013-03-25T09:59:25.747 回答