Swift – 自定义MKAnnotationView,设置标签标题

我正在尝试为我的mapView标注气泡自定义MKAnnotationView。 我可以在创build注解时设置注解标题,还可以自定义MKAnnotationView以添加标签或图像等(在viewForAnnotation委托中),但是如何更改在viewForAnnotation委托中创build的标签,以便标题每个引脚是不同的? 我遇到的另一个问题是,如果在viewDidLoad方法中创build标题或副标题时没有添加标题或副标题,但是我仍然尝试通过离开self.map.addAnnotation(annotation)创build一个标题或副标题,当我运行该应用程序,并点击引脚没有标注泡沫显示。 最后,我想完全定制标注泡泡,每个针脚都有单独的标签。 所以我真正需要知道的是如何在创build注解时访问viewForAnnotation委托来改变每个pin的属性。 override func viewDidLoad() { super.viewDidLoad() var countries: [String] = ["Germany","Germany","Poland","Denmark"] var practiceRoute: [CLLocationCoordinate2D] = [CLLocationCoordinate2DMake(50, 10),CLLocationCoordinate2DMake(52, 9),CLLocationCoordinate2DMake(53, 20),CLLocationCoordinate2DMake(56, 14)] for vari=0; i<practiceRoute.count; i++ { var annotation = MKPointAnnotation annotation.title = countries[i] annotation.coordinate = practiceRoute[i] self.map.addAnnotation(annotation) } } func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! { if annotation is MKUserLocation […]

didEnterRegion工作在前台,但不是后台或其他VC

如果应用程序正在运行,并且CLLocationManagerDelegate类是前景(即可见),则会触发didEnterRegions,并同时获得NSLog和AlertView。 但是,当应用程序处于后台时,我什么也得不到,实质上,如果屏幕显示除委托类以外的任何内容。 我已经在plist的“所需的背景模式”下设置了“位置更新的应用程序寄存器”,尽pipe我不确定这是甚至是必要的。 这是我认为是相关的代码,虽然我可能是错的(并很乐意添加更多)。 我应该注意,viewDidLoad中的所有内容都包含在一个if中,以检查区域监视是否可用和启用。 – (void)viewDidLoad { NSLog(@"MapViewController – viewDidLoad"); self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; self.locationManager.distanceFilter = kCLLocationAccuracyNearestTenMeters; self.locationManager.delegate = self; [self.locationManager startMonitoringSignificantLocationChanges]; } – (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"MapViewController – didEnterRegion"); NSLog(@"MVC – didEnterRegion – region.radius = %f", region.radius); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"entered region…" message:@"You have Entered the Location." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: […]

如何在iOS上创build一个文件的散列?

我试图通过在iOS中使用哈希值来重命名它们来创build唯一的文件名。 我怎样才能做到这一点?

iOS开发:我怎样才能得到一个Facebook的墙上post显示在朋友的新闻提要?

我正在整合Facebook到我的iPhone应用程序,我有代码工作后,他们login后发布到用户的墙上的post,但我注意到,该post不显示在用户的新闻朋友。 相反,它只显示在用户的墙上。 这是我的代码… – (void)publishStream { NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"Post a message on your wall", @"user_message_prompt", @"Hello, World!", @"message", nil]; [facebook dialog:@"feed" andParams:params andDelegate:self]; } 我怎么能把它显示在新闻Feed中呢? 我应该提到,我设置的唯一权限是“publish_stream”,据我所知,这是我需要的唯一权限。 非常感谢您的智慧!

确定核心audioAudioBuffer中的帧数

我正在尝试访问iPhone / iPad上的audio文件的原始数据。 我有下面的代码,这是我需要的path基本开始。 但是,我有一个AudioBuffer后,我很难做什么。 AVAssetReader *assetReader = [AVAssetReader assetReaderWithAsset:urlAsset error:nil]; AVAssetReaderTrackOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[[urlAsset tracks] objectAtIndex:0] outputSettings:nil]; [assetReader addOutput:assetReaderOutput]; [assetReader startReading]; CMSampleBufferRef ref; NSArray *outputs = assetReader.outputs; AVAssetReaderOutput *output = [outputs objectAtIndex:0]; int y = 0; while (ref = [output copyNextSampleBuffer]) { AudioBufferList audioBufferList; CMBlockBufferRef blockBuffer; CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(ref, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, […]

使UIView的特定angular落圆

我做了一些研究,我发现,没有简单的方法来制作UIView的右上angular和左上angular,对吧? PS。 这个代码使得所有的四个angular落都是平淡无奇的。 我不想要。 #import <QuartzCore/QuartzCore.h> self.layer.cornerRadius = 5; self.layer.masksToBounds = YES;

在Swift中解码JSON Web Tokens

试图在Swift中解码JWT的有效载荷,并且真的很困难 static func decodePayload(tokenstr: String) { //splitting JWT to extract payload let arr = split(tokenstr) {$0 == "."} //base64 encoded string i want to decode let base64String = arr[1] as String println(base64String) //eyJleHAiOjE0MjY4MjIxNjMsImlkIjoiNTUwYjA3NzM4ODk1NjAwZTk5MDAwMDAxIn0 //attempting to convert base64 string to nsdata let nsdata: NSData = NSData(base64EncodedString: base64String, options: NSDataBase64DecodingOptions(rawValue: 0)) //decoding fails because nsdata unwraps as […]

unit testing从一个类别的私人方法?

我有一个类包含一个私人帮手方法的NSString类。 如果我可以在我的unit testing中使用这个方法,这将是方便的。 不过,我很难揭露它。 当我在NSString上创build一个类扩展并在这里声明方法时,这个方法在unit testing中是不可见的。 如果我在一个单独的头文件中创build类扩展,或者作为unit testing.m文件的一部分,则无关紧要。 看起来我在这里错过了一些东西。 任何帮助家伙?

使用IOS中的Geocoder类获取基于zip的纬度和经度

我得到了当前位置基于经度和纬度值,然后我也得到了多个地方在谷歌地图上使用Annotation现在我想得到经度和纬度值的基础上邮编我不知道如何获取经度和纬度值基于Zip码

从Notification Center启动应用程序时出现奇怪的崩溃

我在我的智慧结束,我得到一个奇怪的崩溃,只发生在通知中心启动应用程序时。 在本地通知(在通知方)或者对extensionContext的调用:openURL:completionHandler(来自我的“今日”小部件)将使用customURLscheme启动应用程序。 当应用程序运行(热启动),没有问题,工作就像广告。 当我杀死应用程序(在任务切换器),然后尝试通过通知中心启动它(冷启动),我得到下面的崩溃报告。 我寻找任何东西的低和高,找不到它。 这只发生在iOS8设备上,iOS7设备没有问题(随着通知启动,显然没有今日小部件) 有没有人看过这个? 谢谢! Date/Time: 2014-10-14 18:16:39.924 -0400 Launch Time: 2014-10-14 18:16:38.667 -0400 OS Version: iOS 8.0.2 (12A405) Report Version: 105 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x000000016a4cbeb8 Triggered by Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libobjc.A.dylib 0x0000000195ebbbd0 objc_msgSend + 16 1 UIKit […]