iphone - UITableView pushViewController On Selecting a Row -


I am creating an iPhone app with UITableView, when I select a row, let me load a specific URL to a UIWebView To be pushed in

- (zero) table view: (UITableView *) was the TableView SelectionRowAtIndexPath: (NSIndexPath *) indexPath {NSDictionary * story = [Stories { : [Index path line]]; NSString * storyLink = [NSString stringWithFormat: [story objectForKey: @ "link"]]; [[Self-Navigation Controller] PushviewController: [[FirstviewConverterAloc] Init Whitneynames: @ "Firstview" Bundle: [NSBindle Main Bundle]] Animated: Yes]; }

How can I get a new view that slides up to include a UIWebView and later loads the story link through it:

< P>

As other people have said, the general idea is to first place a property on the ViUI controller, which is the URL Loads the need to load, and then loads that URL into the UIWebView when the view appears.

This example is how it might look, starts with the header:

first interface controller: UIViewController {UIWebView * webView; NSURL * storyURL; } @ Property (Nonomatic, Replacement) IBotlet UIWebView * webView; // This is set in your nib @ property (non-creative, retaining) NSRRL * storyURL; @end

for implementation now:

  @implementation FirstViewController @synthesize webView; @ Synthesis storyURL; - (zero) DLok; {[Wordline release]; // Do not forget to leave this [super delok]; } - (zero) viewDid you: (BOOL) animated; {// When the view appears, create the URL request from the story URL and load it in the web view. NSURLRequest * Request = [NSURLRequest request with url: self.storyURL]; [Self. Webw load request: request]; } - (zero) viewviewYou: (BOOL) animated; {// There is no point in continuing with any request load // If anyone left this screen before the screen expires [self. VV Weaver Stoplogging]; } @end  

So now that you need to do in the controller for the previous view, it will receive the story URL, first give it to the View Controller and press it.

  - (zero) table view: (UITableView *) table was viewed SelectionRowAtIndexPath: (NSIndexPath *) indexPath {NSDictionary * story = [Stories ObjectOut Index: [Index Path line]]; NSURL * storyURL = [NSURL URLWithString: [story objectwork: @ "link"]]; First ViewController * First visual controller = [[[FirstviewConverter alloc] initWithNibName: @ "Firstview" bundle: [NSBindal main bundle]]; // I am absolutely sure that you do not have to go to the main bundle in the first bundle first, ViewController.storyURL = storyURL; [Self. Navigation controller Push ViewController: Animated first viewer: Yes]; [First weekant release]; // do not remember memory}  

And there are some other points about it:

  • I think the "link" The value is already a string - If this case was unnecessary to build a brand new string in your original example. As you can see in my example, we can use this string to create a NSURL example directly.

  • In your original code, when you turn alloc / your FirstViewController, you can pass it directly to pushViewController . This creates a memory leak because once the UINavigationController is done with it (later the navigation stack stops), it retains 1. At least you have to autorelease but the most effective thing to do here is that it is aloc / int, it stores it in a temporary variable, then it is directly to release After it is pressed, call it ensures that once the navigation stack closes, it will be deallocated.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -