Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView with UIWebVIew Not Loading UIWebView. Does It Require an IBAction?
    primarykey
    data
    text
    <p>This is the code I've got so far, basically what's supposed to happen is that once you make a selection in the UITableView, you should then get a transition that will take you onto the UIWebView although all that's happening is once you make a selection it just highlights blue.</p> <p><em><strong>First view controller .h</em></strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface YoMaFifthViewController : UITableViewController { NSArray *data, *sites; } @end </code></pre> <p><em><strong>First view controller .m</em></strong></p> <pre><code>#import "YoMaFifthViewController.h" #import "YoMaWebsiteViewController.h" @interface YoMaFifthViewController () @end @implementation YoMaFifthViewController - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - view lifecycle - (void)viewDidLoad { [super viewDidLoad]; data = [NSArray arrayWithObjects:@"Website", @"Developer", nil]; sites = [NSArray arrayWithObjects: @"https://www.google.co.uk/", @"https://www.google.co.uk/", nil]; // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [data count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } // Configure the cell... cell.textLabel.text = [data objectAtIndex:indexPath.row]; cell.detailTextLabel.text = [sites objectAtIndex:indexPath.row]; cell.imageView.image = [UIImage imageNamed:[data objectAtIndex:indexPath.row]]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } /* // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; } */ /* // Override to support editing the table view. - (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view } } */ /* // Override to support rearranging the table view. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { } */ /* // Override to support conditional rearranging of the table view. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the item to be re-orderable. return YES; } */ #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { YoMaWebsiteViewController *wvc = [[YoMaWebsiteViewController alloc] initWithNibName:@"YoMaWebsiteViewController" bundle:nil]; wvc.site = [sites objectAtIndex:indexPath.row]; [self.navigationController pushViewController:wvc animated:YES]; } @end </code></pre> <p><em><strong>Website view controller .h</em></strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface YoMaWebsiteViewController : UIViewController { IBOutlet UIWebView *webview; } @property (retain) NSString *site; @end </code></pre> <p><em><strong>Website view controller .m</em></strong></p> <pre><code>#import "YoMaWebsiteViewController.h" @interface YoMaWebsiteViewController () @end @implementation YoMaWebsiteViewController @synthesize site; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; NSURL *url = [NSURL URLWithString:self.site]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webview loadRequest:request]; // Do any additional setup after loading the view from its nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload