Posts

Showing posts from April, 2015

[iOS] How to get top most view controller?

+ (UIViewController *)topViewController { return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController]; } + (UIViewController *)topViewController:(UIViewController *)rootViewController { if (rootViewController.presentedViewController == nil) { return rootViewController; } if ([rootViewController.presentedViewController isKindOfClass:[UINavigationController class]]) { UINavigationController *navigationController = (UINavigationController *)rootViewController.presentedViewController; UIViewController *lastViewController = [[navigationController viewControllers] lastObject]; return [self topViewController:lastViewController]; } UIViewController *presentedViewController = (UIViewController *)rootViewController.presentedViewController; return [self topViewController:presentedViewController]; } + (UINavigationController *)navigationController { UIViewController *topViewController = [self topVi...

[iOS] How to open a native app or Appstore from Safari or UIWebView

Image
1. Promoting App Banner: https://developer.apple.com/ library/ios/documentation/ AppleApplications/Reference/ SafariWebContent/ PromotingAppswithAppBanners/ PromotingAppswithAppBanners. html http://stackoverflow.com/ questions/6964515/launching- app-or-app-store-from-safari 2. Take user to Appstore from Safari link: http://applinks.org/ documentation/ https://www. brandbuilderwebsites.com/blog/ 2014/05/01/mobile-app-linking/ https://developers.facebook. com/products/app-links