如何使用URL方案将我的应用程序打开到特定视图?

时间:2017-09-25 16:35:31

标签: ios swift3 viewcontroller url-scheme

我想让另一个应用程序使用URL方案打开我的特定视图。 我实际上不知道如何处理这个问题。

有没有人有想法? 像protected function execute(InputInterface $input, OutputInterface $output) { // Remove SQL logger to avoid out of memory errors $em = $this->getEntityManager(); // method defined in base class $em->getConnection()->getConfiguration()->setSQLLogger(null); $firstResult = 0; // Get latest ID $maxId = $this->getMaxIdInTable('AppBundle:MyEntity'); // method defined in base class $this->getLogger()->info('Working for max media id: ' . $maxId); do { // Get data $dbItemsQuery = $em->createQueryBuilder() ->select('m') ->from('AppBundle:MyEntity', 'm') ->where('m.id <= :maxId') ->setParameter('maxId', $maxId) ->setFirstResult($firstResult) ->setMaxResults(self::PAGE_SIZE) ; $paginator = new Paginator($dbItemsQuery); $dbItems = $paginator->getIterator()->getArrayCopy(); $totalCount = count($paginator); $currentPageCount = count($dbItems); // Clear Doctrine objects from memory $em->clear(); // Update first result $firstResult += $currentPageCount; $output->writeln($firstResult); } while ($currentPageCount == self::PAGE_SIZE); // Finish message $output->writeln("\n\n<info>Done running <comment>" . $this->getName() . "</comment></info>\n"); } 这样的东西可以直接使用,还是我必须做其他事情?

1 个答案:

答案 0 :(得分:0)

从一个应用程序中,您可以使用canOpenUrl功能打开您的应用程序:

if let url = NSURL(string: “yourApp://?\test=test”) ,
 UIApplication.shared.canOpenURL(url as URL) {
             UIApplication.shared.open(url as URL, options: [:], completionHandler: { (success) in
                 print("\n App opended")
             })
         }
         else{
             print("\n Can't open app")
         }

在您的应用程序中,您将在此功能AppDelegate中执行处理:

- (BOOL)application:(UIApplication *)app 
            openURL:(NSURL *)url 
            options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options;