我使用的UIScrollView用于捏缩放图像我使用的代码是这样的的UIScrollView保持按钮固定位置
CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame]; //Full Screen
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:fullScreenRect];
scroll.backgroundColor = [UIColor clearColor];
scroll.delegate = self;
scroll.contentSize = _imageView.frame.size;
[scroll addSubview:_imageView];
scroll.minimumZoomScale = 1.0;
scroll.maximumZoomScale = 5.0;
[scroll setZoomScale:scroll.minimumZoomScale];
self.view = scroll;
[scroll addSubview:_screenShotButton];
[scroll addSubview:_resolutionButton];
-(void)aligementTheControlBasedOnOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
bool ipad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
if (ipad) {
if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
{
_imageView.frame = CGRectMake(142, 114, 740, 555);
if ([self.resoultion isEqualToString:@"Default"]) {
_imageView.frame = CGRectMake(142, 114, 740, 555);
}
else if([self.resoultion isEqualToString:@"4:3"])
_imageView.frame = CGRectMake(142, 114, 740, 555);
else if([self.resoultion isEqualToString:@"16:9"])
_imageView.frame = CGRectMake(142, 114, 740, 416);
self.screenShotButton.frame = CGRectMake(794, 667, 55, 55);
self.resolutionButton.frame = CGRectMake(857, 667, 55, 55);
}
else
{
_imageView.frame = CGRectMake(64, 238, 640, 480);
if ([self.resoultion isEqualToString:@"Default"]) {
_imageView.frame = CGRectMake(64, 238, 640, 480);
}
else if([self.resoultion isEqualToString:@"4:3"])
_imageView.frame = CGRectMake(64, 238, 640, 480);
else if([self.resoultion isEqualToString:@"16:9"])
_imageView.frame = CGRectMake(64, 238, 640, 360);
self.screenShotButton.frame = CGRectMake(578, 749, 55, 55);
self.resolutionButton.frame = CGRectMake(649, 749, 55, 55);
}
}
}
基于分辨率用户
已选择我定位的按钮。
一切工作正常。我正面临的问题是_screenShotButton和_resolutionButton在我缩放图像时也在移动。相反,我想保持静态按钮在屏幕的右下角。
任何人都可以帮助我。
我也注意到您更换了'你'scroll' self.view'。考虑*将'self.view'作为'self.view'的子视图添加*滚动,以便您可以使用超级视图添加按钮。 – SwiftArchitect