Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 制作位置指示器';地图';在滚动视图中的位置_Ios_Uiscrollview_Position - Fatal编程技术网

Ios 制作位置指示器';地图';在滚动视图中的位置

Ios 制作位置指示器';地图';在滚动视图中的位置,ios,uiscrollview,position,Ios,Uiscrollview,Position,我有一个包含大图像大小的scrollview的视图,我想为您在scrollview中的位置添加一个位置指示器,就像游戏中的地图一样 我在scrollview顶部创建了一个较小的视图,该视图具有较小的图像版本,我想知道如何在较小的视图中添加一个相对于scrollview缩放比例大小和位置的矩形,以在较小的图像上指示您当前正在查看的较大图像的哪个部分?我的目标是使用ARC的iOS 5+ 到目前为止,我得到的是-它似乎正确地设置了原点,但当我缩放它时,它会变小,而它应该变大,反之亦然: int scr

我有一个包含大图像大小的scrollview的视图,我想为您在scrollview中的位置添加一个位置指示器,就像游戏中的地图一样

我在scrollview顶部创建了一个较小的视图,该视图具有较小的图像版本,我想知道如何在较小的视图中添加一个相对于scrollview缩放比例大小和位置的矩形,以在较小的图像上指示您当前正在查看的较大图像的哪个部分?我的目标是使用ARC的iOS 5+

到目前为止,我得到的是-它似乎正确地设置了原点,但当我缩放它时,它会变小,而它应该变大,反之亦然:

int scrollxint = self.scrollView.bounds.origin.x;
int scrollyint = self.scrollView.bounds.origin.y;
int scrollxlength = self.scrollView.contentSize.width;
int scrollylength = self.scrollView.contentSize.height;

int reducedscrollxint = (scrollxint*0.05);
int reducedscrollyint = (scrollyint*0.05);
int reducedscrollxlength = (scrollxlength*0.05);
int reducedscrollylength = (scrollylength*0.05);

areaFrame.frame = CGRectMake(reducedscrollxint, reducedscrollyint, reducedscrollxlength, reducedscrollylength);
[self.mapView addSubview:areaFrame];

任何帮助都将不胜感激。

我必须使用相对于区域指示器原始大小的缩放比例来实现此功能,但此代码适用于我:

int scrollxint = self.scrollView.bounds.origin.x;
int scrollyint = self.scrollView.bounds.origin.y;

float scale = self.scrollView.zoomScale;

int reducedscrollxint = (scrollxint*0.05);
int reducedscrollyint = (scrollyint*0.05);


areaFrame.frame = CGRectMake(reducedscrollxint, reducedscrollyint, (10/scale), (6.5/scale));
[self.mapView addSubview:areaFrame];