简体   繁体   中英

is it possible to open specific viewcontroller(containing app) after tap on extension(today extension)?

I am using Today extension in ios.

I have multiple view controller with different info. and I am displaying some info in tableview using Today extension. when click on row then I want to open related viewcontroller with info.

I have tried following code.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
   {
      NSURL *url = [NSURL URLWithString:@"ReadText://"];
      [self.extensionContext openURL:url completionHandler:nil];

   }

I have set url schemes in info.plist

but using this code I can only open root viewcontroller.

appreciate for help.

Yes you can open the customViewController progrmattically by passing custom data to urlSchemes.

NSURL *url = [NSURL URLWithString:@"ReadText://customViewController"];

Implement the delegate method and get the string from url and than push the customViewController progrmattically.

 -(BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
       NSString *viewController =  [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
       if([viewController isEqualToString:@"customViewController"]) {
          //push customViewController on rootViewController
       }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM