Reputation: 171
i am very new to Xcode and don't know much about it , sorry for my silly question.
i want to create app with 20 buttons on home page , and i want to attach them all in one ViewController
Like if button1 clicked
do this
elseif button2 clicked
do diffrent
i have added 2 buttons with google and yahoo.com but when i click it down it opens in same ViewController i Want To open it in Feed (ViewController2)
This is screenshot of my app Lovebook
LoveBook attached to ViewController1 and feed attached to viewcontroller2
and this is my code in ViewController1
@IBAction func button1(_ sender: Any) {
let url = URL(string:"http://google.com")
let request = URLRequest (url: url!)
webView.frame = self.view.frame;
webView.loadRequest(request)
}
@IBAction func button2(_ sender: Any) {
let url = URL(string:"http://yahoo.com")
let request = URLRequest (url: url!)
webView.frame = self.view.frame;
webView.loadRequest(request)
}
please help me or send me the project demo. please thanks
Upvotes: 1
Views: 1112
Reputation: 131398
The code you wrote asks an external app to handle the URL.
If you want to open a web view then you'll need to create a new view controller that contains a web view, pass the URL to that view controller, and have the view controller send the link to the web view in it's viewWillAppear
method.
(No, I don't have sample code I can share.)
Upvotes: 1