开发者

Uiwebview within uitableview

Is it possible to divide uitableview into 3 parts, one of which is uiwebview (so i can display htm开发者_如何学Pythonl string)? The other 2 parts are just regular strings so I can just display as text.


It is possible using custom subclasses of UITableViewCell (just split each cell into 3 subcells and insert a UIWebview into one.); however, it probably goes against the Apple HIG.


- (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 *)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];      

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜