I’ve been working on this project for iPhone/iPad devices, and after finishing the iPhone portion of my project I was struck my inspiration to change up the style of the iPad project.
My Scenario:
I have a View that has UIButtons in it that link to websites. Originally I planned that these buttons use a Push sequence to open separate View that already had a UIWebView in it to open the web page. But then I thought maybe I could use the UIButtons to open the desired webpages within the parent View.
My Question:
Is it possible to load a webpage using a UIButton, but in a UIWebView that is in the same View as the UIButton used to load the webpage?
Thanks in advance everybody, I think this should be possible but nothing is coming to mind at the moment.
Of course is possible (really… why not?). You just have a
UIViewthat has aUIWebViewand severalUIButtonsubviews. Then you could do something like this:Now if you don’t use InterfaceBuilder you could just construct your webView and buttons in code and just add them to your mainView.
Finally if you plan to have a lot of buttons you could optimize the code by breaking the loading part into a separate method and just pass the url from your IBActions. Something like this: