Iphone uitableview中的Uiwebview

Iphone uitableview中的Uiwebview,iphone,uitableview,uiwebview,Iphone,Uitableview,Uiwebview,是否可以将uitableview分为3部分,其中一部分是uiwebview(这样我就可以显示html字符串)?其他两部分只是常规字符串,因此我可以只显示为文本。可以使用UITableViewCell的自定义子类(只需将每个单元格拆分为3个子单元格,并在其中插入UIWebview即可);然而,这可能与苹果公司的做法背道而驰 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPa

是否可以将uitableview分为3部分,其中一部分是uiwebview(这样我就可以显示html字符串)?其他两部分只是常规字符串,因此我可以只显示为文本。

可以使用UITableViewCell的自定义子类(只需将每个单元格拆分为3个子单元格,并在其中插入UIWebview即可);然而,这可能与苹果公司的做法背道而驰

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell...

[self addWebViewToTable:(UITableViewCell *)cell];


return cell;
}

-(void)addWebViewToTable:(UITableViewCell*)单元格{
NSString*htmlString=@“我的第一个标题我的第一段。

”; UIWebView*webView=[[UIWebView alloc]initWithFrame:CGRectMake(5.0f,1.0f,40.0f,40.0f)]; [webView加载htmlString:htmlString基URL:nil]; [[cell contentView]addSubview:webView]; [网络视图发布];

}

谢谢。有没有办法在html代码中自动调整图像的大小?目前它们太大,无法放在iphone屏幕内。@Dat NGuyen我不确定这样做是否正确:查看此帖子以调整图像大小,将图像存储到文档或临时文件中,然后使用本地文件作为图像源!!希望这有帮助
- (void)addWebViewToTable:(UITableViewCell *)cell{
NSString* htmlString = @"<html> <body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>";
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(5.0f,1.0f,40.0f,40.0f)];
[webView loadHTMLString:htmlString baseURL:nil];
[[cell contentView] addSubview:webView];
[webView release];