1 / 8

Chapter 5 Favorite Twitter Searches App

Chapter 5 Favorite Twitter Searches App. Interaction with buttons Load a web page. Access the web by code. Some apps access the web We can do that through code, i.e. programmatically Click on a button  open up a web site. Buttons and Web Views. Create a Single View app

kaipo
Download Presentation

Chapter 5 Favorite Twitter Searches App

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 5 Favorite Twitter Searches App • Interaction with buttons • Load a web page

  2. Access the web by code • Some apps access the web • We can do that through code, i.e. programmatically • Click on a button  open up a web site

  3. Buttons and Web Views • Create a Single View app • In the view, place a button at the top and a web view occupying the rest of the window

  4. Buttons and Web Views • Find button in Interface Builder • The corresponding class is UIButton • Find web view in Interface Builder • The corresponding class is UIWebView

  5. Buttons and Web Views • In Controller.h, set up 2 instance variables to match the button and the web view IBOutlet UIButton *go; IBOutlet UIWebView *webView; • Connect the instance variable to the gui components in the window • Add a method goToYahoo -(IBAction) goToYahoo: (id) sender;

  6. Buttons and Web Views • Code the method header of goToYahoo in Controller.m • Set up the event: when the user clicks on the button, goToYahoo will execute • Check that this is happening using a printf statement

  7. Accessing and loading an URL • The NSURL class encapsulates a url; the method URLWithString enables us to build one from a string NSURL *url = [NSURL URLWithString:@”http://www.yahoo.com”]; • Now the UIWebView instance variable of the Controller class can load the web page

  8. Accessing and loading an URL • NSURLRequest encapsulates a request to a server • The loadRequest method of UIWebView can load a web page based on a NSURLRequest [webView loadRequest : [NSURLRequest requestWithURL: url] ]; • The web page should load inside webView

More Related