【发布时间】:2016-01-26 09:31:53
【问题描述】:
在下面的代码中,webTableViewCell 是 UITableViewCell 的子类(我创建它是为了避免使用this),其中我在viewController 中从 tableView 的原型单元格绑定了 webview 的 IBOutlet到这个webTableViewCell 班级。
URLs 正在加载,而 tableViewCell 中的 webViews 没有。我认为问题出在tableView:cellForRowAtIndexPath: 方法中。有人可以帮帮我吗?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
webTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"My Cell"];
if(!cell)
cell = [[webTableViewCell alloc]initWithFrame:CGRectZero];
NSString *urlString = [NSString stringWithFormat:@"http://www.facebook.com/%@",[myArrayOfLinks objectAtIndex:indexPath.row]];
NSURL *url = [NSURL URLWithString:urlString];
NSLog(@"%@", url);
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[cell.webView loadRequest:urlRequest];
return cell;
}
【问题讨论】:
-
正在加载 URL 是什么意思?能否提供截图。
-
我的意思是正在生成的网址,我已经通过
NSLog(@"%@", url);验证了您想要哪些屏幕截图? -
发布您的自定义单元格类的代码,并添加 iOS 模拟器的屏幕截图,我们可以了解显示的内容和不显示的内容
-
除了在 .h 文件的接口部分绑定 webview 的出口外,我在自定义单元类中什么也没做!
标签: ios uitableview uiwebview