I’d like to start by apologising as I’m sure this question has been answered, in various forms on this site and others, but I just can’t seem to implement any similar threads
It’s just I have been trying to push a array of search engines into my webView,
I have populated the table with a .plist or NSMutableArray and I have an array of both kinds with Url’s in I have manages to load a subview but I an really struggling to get my web view loading.
I think I’m ok until didSelectRowAtIndexPath and the webView load request. Ok thinking about it I have only populated the table and put IBOUTLET (nonatomic, retain) UIWebView *webView and synthesised it in my WebViewController.
And as Background my TableViewController is embedded in a NavigationController and a WebView in a UIViewController
If anyone is willing to help me out I’m more than willing to donate as this has caused way too many sleepless nights.
Here is a link to my project if it would help anyone http://dl.dropbox.com/u/28335617/TableViewArrays.zip
Thank you very much for any help offered
Here is my TableViewController.h
@class WebViewController;
#import <UIKit/UIKit.h>
@interface TableViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate> {
WebViewController *viewController;
IBOutlet UITableView *mytableView;
}
@property (strong, nonatomic) IBOutlet UITableView *mytableView;
@property (nonatomic, retain) WebViewController *viewController;
@property (nonatomic, retain) NSMutableArray *searchData, *tableData, *tableUrl;
@end
Here is my TableViewController.m
#import "TableViewController.h"
#import "TableAppDelegate.h"
#import "WebViewController.h"
@interface TableViewController ()
@end
@implementation TableViewController
@synthesize mytableView;
@synthesize viewController;
@synthesize searchData, tableData, tableUrl;
NSMutableArray *searchData, *tableData, *tableUrl;
- (void)viewDidLoad
{
[super viewDidLoad];
tableUrl = [[NSMutableArray alloc] init];
[tableUrl addObject: @"http://www.google.com"];
[tableUrl addObject: @"http://www.bing.com"];
[tableUrl addObject: @"http://www.dogpile.com"];
[tableUrl addObject: @"http://www.wikipedia.com"];
[tableUrl addObject: @"http://www.ask.com"];
[tableUrl addObject: @"http://www.yahoo.com"];
[tableUrl addObject: @"http://www.aol.com"];
[tableUrl addObject: @"http://www.altavista.com"];
[tableUrl addObject: @"http://www.gigablast.com"];
[tableUrl addObject: @"http://www.msn.com"];
[tableUrl addObject: @"http://www.mamma.com"];
self.title = @"Search Engines";
//ARRAY FOR PLIST
// Find out the path of recipes.plist
NSString *path = [[NSBundle mainBundle] pathForResource:@"searchData" ofType:@"plist"];
searchData = [[NSMutableArray alloc] initWithContentsOfFile:path];
// Load the file content and read the data into arrays
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
tableData = [dict objectForKey:@"SearchEngines"];
// tableUrl = [dict objectForKey:@"SearchAddress"];
// NSString *path = [[NSBundle mainBundle] pathForResource:@"sEArray" ofType:@"plist"];
// sEArray = [[NSMutableArray alloc] initWithContentsOfFile:path];
// NSString *urlArray = [[NSBundle mainBundle] pathForResource:@"urlsArray" ofType:@"plist"];
//urlsArray = [[NSMutableArray alloc] initWithContentsOfFile:urlArray];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#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 [self.tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
}
// Configure the cell...
NSInteger row = [indexPath row];
cell.textLabel.text = [tableData objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
#pragma mark - Table view delegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
@end
And here is my WebViewController.h
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController {
NSMutableArray *tableURL;
}
@property (nonatomic, retain) IBOutlet UIWebView *webView;
@property (nonatomic, retain) NSMutableArray *tableUrl;
@end
And WebViewController.m
#import "TableAppDelegate.h"
#import "TableViewController.h"
#import "WebViewController.h"
@interface WebViewController ()
@end
@implementation WebViewController
@synthesize tableUrl;
@synthesize webView;
Not tested. Add SequgeIdentifier “WebView” in IB
in tableviewcontroller add:
in webviewcontroller