[英]is it possible to open specific viewcontroller(containing app) after tap on extension(today extension)?
我在ios中使用Today擴展。
我有多個具有不同信息的視圖控制器。 並且我正在使用Today擴展在tableview中顯示一些信息。 當點擊行,然后我想打開相關的viewcontroller與信息。
我試過下面的代碼。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSURL *url = [NSURL URLWithString:@"ReadText://"];
[self.extensionContext openURL:url completionHandler:nil];
}
我已經在info.plist中設置了網址方案
但是使用此代碼,我只能打開root viewcontroller。
感謝您的幫助。
是的,您可以通過將自定義數據傳遞給urlSchemes來以編程方式打開customViewController。
NSURL *url = [NSURL URLWithString:@"ReadText://customViewController"];
實現委托方法並從url
獲取字符串,然后以customViewController
方式推送customViewController。
-(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
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.