我正在制作一个在TableviewCell中使用webview的应用程序,我想知道是否有办法让webview变得更小,因此它不会填满整个单元格。我已经尝试了所有明显的事情,例如更改CGRectMake维度并更改了故事板中的大小,但它不断占用整个单元格。我也想知道是否有办法在网站的某个地方加载网页。
这是我到目前为止的代码......
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSDictionary *myModel = feeds[indexPath.row];
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.customName.text = [myModel objectForKey: @"author"];
cell.customDate.text = [myModel objectForKey: @"pubDate"];
UIWebView* CellWebview = [[UIWebView alloc] initWithFrame:
CGRectMake(5, 5, cell.bounds.size.width - 5, cell.bounds.size.height - 5)];
[CellWebview setOpaque:NO];
[CellWebview setBackgroundColor:[UIColor clearColor]];
[[CellWebview scrollView] setScrollEnabled:YES];
self.url = [myModel objectForKey:@"link"];
[CellWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: self.url]]];
[cell addSubview:CellWebview];
CellWebview.delegate = self;
return cell;
}
- (void)webViewDidFinishLoad:(UIWebView *)CellWebview{
CGSize contentSize = CellWebview.scrollView.contentSize;
CGSize viewSize = self.view.bounds.size;
float rw = viewSize.width / contentSize.width;
CellWebview.scrollView.minimumZoomScale = rw;
CellWebview.scrollView.maximumZoomScale = rw;
CellWebview.scrollView.zoomScale = rw;
CellWebview.hidden = NO;
}