gpt4 book ai didi

ios - UIScrollView 将按钮保持在固定位置

转载 作者:可可西里 更新时间:2023-11-01 00:15:33 25 4
gpt4 key购买 nike

我正在使用 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 也在移动。相反,我想让屏幕右下角的按钮保持静态。

谁能帮帮我。

最佳答案

您可以将 subview 从 UIScrollView 移动到 ScrollView 的 super View ,例如:

将您的按钮放置/设置在 ScrollView 上(而不是在 ScrollView 内),如此快照所示。并针对 ScrollView 的 super View 设置按钮约束(位置)。

enter image description here

这是引用。每个 View 彼此之间的位置层次结构快照。

enter image description here

关于ios - UIScrollView 将按钮保持在固定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31557131/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com