Calling Webview from anther View Controller class

Discussion in 'iPad Development' started by ray10, Feb 24, 2011.

  1. ray10

    ray10 iPF Noob

    Joined:
    Feb 24, 2011
    Messages:
    1
    Thanks Received:
    0
    Trophy Points:
    0
    Ratings:
    +0 / 0
    Hi everyone, I'm new to this as I come from C++ and Perl background. Trying to learn from books but they are missing some core concepts of Objective-C. I need some help on this code to pull a webpage:

    RootViewController.m
    Code:
    - (void)fetchWebsite:(NSString*)website{
        NSLog(@"address: %@", website);
        
        NSString *urlAddress = website;
        NSURL *url = [NSURL URLWithString:urlAddress];
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
        [webImageDisplay loadRequest:requestObj];
        [webImageDisplay release];
    }
    
    - (void)viewDidLoad {
        [self fetchWebsite:@"website here"];
        [super viewDidLoad];
    }
    
    
    This code works just fine but what I'm having trouble is calling this method from another class, like the code below:

    AnotherViewController.m
    Code:
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
        NSString *itemRequested = [conusItems objectAtIndex:indexPath.row];
        NSLog(@"logging: %@", itemRequested);
    
        RootViewController *parent = [[RootViewController alloc] init];
        [parent fetchWebsite:@"another website here"];
        
        [itemRequested release];
    
    }
    
    I click on the button on the table view and I see the code is being called in the RootViewController with the NSLog but it doesn't seem to display the new page. Any ideas? Thanks
     

Share This Page

Search tags for this page

change webview from didselectrowatindexpath

,

didselectrowatindexpath call uiwebview