我有这个代码用于我的iOS应用程序:
NSString *location = [[NSString alloc] initWithFormat:@"%@, %@", [self.campus campusStreetAddress], [self.campus campusCityStateZip]];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:location
completionHandler:^(NSArray* placemarks, NSError* error){
if (placemarks && placemarks.count > 0) {
CLPlacemark *topResult = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult];
MKCoordinateRegion region = self.campusMap.region;
region.center = placemark.region.center; //DEPRECATED iOS 7
region.span.longitudeDelta /= 1500;
region.span.latitudeDelta /= 1500;
[self.campusMap setRegion:region animated:NO];
[self.campusMap addAnnotation:placemark];
}
}
];
Run Code Online (Sandbox Code Playgroud)
但是,当我将我的应用程序升级到iOS 7时,不推荐使用placemark.region.center.我应该使用替代品吗?这甚至是在视图中创建地图的正确方法吗?
谢谢!!
按照推送通知的Parse.com教程,我把这个Swift代码放到我的应用程序didFinishLaunchingWithOptions方法中:
// Register for Push Notitications
if application.applicationState != UIApplicationState.Background {
// Track an app open here if we launch with a push, unless
// "content_available" was used to trigger a background push (introduced in iOS 7).
// In that case, we skip tracking here to avoid double counting the app-open.
let preBackgroundPush = !application.respondsToSelector("backgroundRefreshStatus")
let oldPushHandlerOnly = !self.respondsToSelector("application:didReceiveRemoteNotification:fetchCompletionHandler:")
var pushPayload = false
if let options = launchOptions {
pushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil
}
if (preBackgroundPush || oldPushHandlerOnly || …Run Code Online (Sandbox Code Playgroud) 我的应用程序中有视频.一些使用MPMoviePlayerController,其他人使用YouTube的UIWebView.我希望我的应用程序完全是肖像.但是,我想让用户选择在有视频时翻转到横向(不是强制,而是可选).
我一直在网上搜索答案,但我还没有找到任何答案.
谢谢你的帮助!