在我的应用程序中有一个联系我们视图,该视图将有一个打开公司地址的按钮。所以我的代码在 iOS6 中运行良好,我知道 iOS 5 应该有所不同,但找不到正确的方法。这是我的代码:
// Check for iOS 6
BOOL iOS6 = NO;
Class mapItemClass = [MKMapItem class];
if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
iOS6 = YES;
switch (buttonIndex) {
case 0:
if (iOS6)
{
// Create an MKMapItem to pass to the Maps app
CLLocationCoordinate2D coordinate =
CLLocationCoordinate2DMake(26.375561, 50.170305);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:@"Industrial Projects Technologies"];
// Pass the map item to the Maps app
[mapItem openInMapsWithLaunchOptions:nil];
}
else
{
// Use the iOS 5 method
}
break;