我从网络获取JSON MutableArray包含 YouTube URL 字符串..
目的是在每个单元格中执行UIWebView
。
我的代码: 代码如何实现? 谢谢。
@property (nonatomic, strong) NSMutableArray* arrMovies;
@synthesize arrMovies;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
}
cell.textLabel.text = [[self.arrMovies objectAtIndex:indexPath.row] valueForKey:@"title"];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ views | Duration: %i",
[[self.arrMovies objectAtIndex:indexPath.row] valueForKey:@"viewCount"],intMinutes];
return cell;
}
最佳答案
我认为您误解了 UIWebView 是什么。 UIWebView 允许您将 Web 内容嵌入到您的应用程序中。这与执行 Web 请求、获取 JSONString、解析它并将其显示在 View 中不同。我认为这才是您真正要问的问题。请编辑您的问题/确认这一点。
您上面的代码具体有什么问题?您面临什么问题?我认为你的问题是你的实现文件中需要一个 @property (nonatomic, Strong) NSMutableArray* arrMovies;
和 @synthesize artMoves = _artMovies;
。
确保也覆盖 artMovies 属性的 getter。
关于ios - 在 UITableView Cell 中实现 UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14383980/