我正在使用ECSlidingViewController,我的WebViewController类中有一个UIWebView。在不重新加载整个视图的情况下,当我单击MenuViewController.m类中的单元格时,我想将URL加载到UIWebView中。
这是我到目前为止所做的:
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];
}
所以我知道我在某处遗漏了某些东西。有什么建议吗?
答案 0 :(得分:0)
所以,我不得不以迂回的方式进行搜索,并找到了与更新标签有关的NSNotificationCenter。我将链接到描述如何执行此操作的页面,它的工作非常出色: