ios - Is there any code like "If the storyboard ID is XXX, then..." in Swift? -
I am now creating an app that has two UIView controllers code> UIWebView . However, they should be in the same class. So is there a way that I just "load" the URLE, load the URL 2 "if the Storyboard ID is XXX?"
This is my code:
day_range = = NSURL (string: "http://www.url1.com/") go day_url_request = NSURLRequest (url: day_url ) day_webView.loadRequest (day_url_request) to week_url = NSURL (string: "http: //www.url2. com /") to week_url_request = NSURLRequest (URL: week_url) week_webView.loadRequest (week_url_request) Thanks
PS: Sorry for my bad english. : (
Each of your UIViewController s has a unique ID and a custom class. The first UIViewController < / Code> should look something like this:
class StoryboardID1: UIViewController {override func viewDidLoad () {super.viewDidLoad ()) day_url = NSURL (string: "http: // www. url1.com/ ") to day_url_request = NSURLRequest (URL: day_url) day_webView.loadRequest (day_url_request)} override function didReceiveMemoryWarning () {super.didReceiveMemoryWarning ()}} and the second
class StoryboardID2: UIViewController {viewDidLoad () {super.viewDidLoad (override function) to week_url = NSURL (string: "http: // Www.url2 .com / ") let_url_request = Give NSUR LRequest (URL: week_url) week_webView.loadRequest (week_url_request)} override function didReceiveMemoryWarning () {super.didReceiveMemoryWarning ()}} other way
first, announced their UIViewController :
to myViewControllerID = self.storyboard .instantiateViewControllerWithIdentifier ( "PutIDHere" ) As the UIViewController then check that myViewControllerID is actually a user Navigating on Yntrk:
if segue.identifier == "myViewControllerID" {...}
Comments
Post a Comment