I am using ECSlidingViewController, and I have a UIWebView in my class WebViewController. Without reloading the entire view, I'd like to load the URL into the UIWebView when I click on a cell in the MenuViewController.m class.
This is what I have so far:
MenuViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];
}
NSString *pdfName = cell.textLabel.text;
WebViewController *webView = [[WebViewController alloc] init];
[webView setWebView:pdfName];
}
WebViewController.m
@interface WebViewController ()
@end
@implementation WebViewController
@synthesize WebView1;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.layer.shadowOpacity = 0.7f;
self.view.layer.shadowRadius = 10.0f;
self.view.layer.shadowColor = [UIColor blackColor].CGColor;
if(![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
}
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
CGRect frame = WebView1.frame;
frame.size.width = 280; // Your desired width here.
frame.size.height = 1; // Set the height to a small one.
WebView1.frame = frame;
NSString *fullURL = @"http://www.sluggy.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[WebView1 loadRequest:requestObj];
}
-(void)setWebView:(NSString *)pdfName{
NSString *homeDir = NSHomeDirectory();
NSString *filePath = [NSString stringWithFormat:@"%@/%@/%@", homeDir, @"Documents", pdfName];
NSString *fullURL = @"http://www.google.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[WebView1 loadRequest:requestObj];
[WebView1 reload];
}
So I know I'm missing something somewhere. Any suggestions?