我有以下问题:
我有一个"绘制的地图"(图像),我作为叠加添加到MapView.有没有问题..但我需要的MapView限制在覆盖的区域,因此用户不能滚动/缩放这个区域之外..但它应该可以滚动/变焦的"边界内"覆盖 - 意味着我不能只为MapView禁用缩放/滚动.
关于这个主题有什么想法/解决方案吗?使用MapView/-Kit的原因是我需要将各种POI添加到自定义地图.仅使用ImageView + ScrollView呈现自定义地图时,这可能会变得更加复杂.
我已经研究了很多这个主题,但我没有找到一个很好的解决方案.
任何帮助表示赞赏!
最诚挚的问候,基督徒
编辑:这是我们的解决方案: 您提供了一个topleft和一个底部坐标来限制地图.(最小)缩放级别也是有限的.我已经停用减速功能,你可以从地图中弹出一点(为了更好的性能/ ux).我在叠加层上添加了一个〜1km的灰色边框,因此用户无法看到谷歌的原始世界地图.
LimitedMapView.h:
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface LimitedMapView : MKMapView <UIScrollViewDelegate>{
}
@property (nonatomic, assign) CLLocationCoordinate2D topLeftCoordinate;
@property (nonatomic, assign) CLLocationCoordinate2D bottomRightCoordinate;
@end
Run Code Online (Sandbox Code Playgroud)
LimitedMapView.m:
#import "LimitedMapView.h"
@implementation LimitedMapView
@synthesize topLeftCoordinate, bottomRightCoordinate;
- (void)scrollViewDidZoom:(UIScrollView *)scrollView{
if([super respondsToSelector:@selector(scrollViewDidZoom:)]) [super scrollViewDidZoom:scrollView];
if ([self region].span.latitudeDelta > 0.002401f || [self region].span.longitudeDelta > 0.003433f) {
CLLocationCoordinate2D center = self.centerCoordinate;
MKCoordinateSpan span = MKCoordinateSpanMake(0.002401f, 0.003433f);
self.region = MKCoordinateRegionMake(center, span);
}
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
if([super …Run Code Online (Sandbox Code Playgroud) 从我,Custom Keyboard我想知道用户是否在他们的文本(及其范围)中选择了一些东西.根据文档,我认为我可以利用UITextInputDelegate协议提供的回调:
但是,selectionWill/DidChange从不调用回调.如果我在文本中更改选择,则会触发其他回调(textWill/DidChange).由于这已经很奇怪,我遇到的问题是textInput参数总是为零.但我需要它,因为我想访问selectedTextRange以解决我的问题.
有关如何在自定义键盘实现中检索当前所选文本和/或其范围的任何想法?
我目前正在开发一个类似"Dropbox"的应用程序,它有一个集成了文件/图像的查看器.
问题:当用户在服务器上存储了一个非常高分辨率的图像并想要在设备上查看它时,应用程序将崩溃.
示例:12000x4000像素的全景照片.有没有办法缩小这个图像(在客户端 - iOS - 侧)?
目前我正在使用这些课程:http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
但我需要找到一种不使用> 300mb内存的方法......