我的老板让我在Objective-C应用程序中启用深层链接,但我不懂那种语言。首先,我在info.plist
中启用了URL方案:
然后在我的AppDelegate.m
我有:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[NSThread sleepForTimeInterval:2]; //add 2 seconds longer.
// Do your time consuming setup
[splashView removeFromSuperview];
_pushDict= nil;
[self APNSRegistration];
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
//[UIApplication sharedApplication].applicationIconBadgeNumber =0;
// Assign tab bar item with titles
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
UITabBarItem *tabBarItem4 = [tabBar.items objectAtIndex:3];
UITabBarItem *tabBarItem5 = [tabBar.items objectAtIndex:4];
tabBarItem1.title = @"";
tabBarItem2.title = @"";
tabBarItem3.title = @"";
tabBarItem4.title = @"";
tabBarItem5.title = @"";
NSString *badgeValue = [NSString stringWithFormat:@"%ld", (long)[UIApplication sharedApplication].applicationIconBadgeNumber];
if([badgeValue isEqual: @"0"]) badgeValue = nil;
tabBarItem3.badgeValue = badgeValue;
//unselected
[tabBarItem1 setImage:[[UIImage imageNamed:@"0003-home3.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem1 setSelectedImage:[[UIImage imageNamed:@"0003-home3_selected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//unselected
[tabBarItem2 setImage:[[UIImage imageNamed:@"tazza.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem2 setSelectedImage:[[UIImage imageNamed:@"0163-mug_selected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//unselected
[tabBarItem3 setImage:[[UIImage imageNamed:@"0084-calendar.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem3 setSelectedImage:[[UIImage imageNamed:@"0084-calendar_selected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//unselected
[tabBarItem4 setImage:[[UIImage imageNamed:@"0016-camera.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem4 setSelectedImage:[[UIImage imageNamed:@"0016-camera_selected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//unselected
[tabBarItem5 setImage:[[UIImage imageNamed:@"0072-location.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem5 setSelectedImage:[[UIImage imageNamed:@"0072-location_selected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
NSDictionary *pushDict = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
_pushDict= pushDict;
return YES;
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
printf("openURL called");
return YES;
}
如果从iOS Safari启动网址superbar://
,则表示Safari无法打开该页面。
我确信我遗失了didFinishLaunchingWithOptions
中的内容,但是什么?
答案 0 :(得分:1)
只需在safari地址栏中输入superbar://
即可。
应用应该启动。
请检查您的信息标签 - &gt;网址类型