Reputation: 865
I'm using custom URL scheme to open specific view and choose specific cell of a table view. However, the cell choosing code don't work. Went through stackoverflow still couldn't find a solution
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if ([url.host isEqual: @"help"]){
UITabBarController *tabController = (UITabBarController*)self.window.rootViewController;
tabController.selectedIndex = 4;
MoreController* more = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"more"];
[more.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:1] animated:true scrollPosition:UITableViewScrollPositionNone];
}
whenever i open the app using url myapp://help , it only stays at selected index , and doesn't choose the cell.
Upvotes: 0
Views: 94
Reputation: 3310
You need to Write this if your MoreController
is already loaded in UITabBarController
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if ([url.host isEqual: @"help"]){
UITabBarController *tabController = (UITabBarController*)self.window.rootViewController;
tabController.selectedIndex = 4;
MoreController* more = (MoreController *)[[tabController viewControllers] objectAtIndex:4];
[more.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:1] animated:true scrollPosition:UITableViewScrollPositionNone];
}
}
Upvotes: 1