- (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で画像を表示することに成功した方法のいくつか..しかし、グーグルで検索した後、画像を回転させるための適切なガイダンスを見つけることができませんでした。 ?