2011-01-14 7 views
1

uitableviewを3つの部分に分けることは可能ですか?そのうちの1つはuiwebviewです(したがって、html文字列を表示できます)?他の2つの部分は普通の文字列ですので、テキストとして表示できます。uitableview内のUiwebview

答えて

2

UITableViewCellのカスタムサブクラスを使用することができます(各セルを3つのサブセルに分割し、UIWebviewを1つに挿入するだけです)。しかし、それはおそらくApple HIGに反対します。

1
- (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

おかげ。自動的にHTMLコード内の画像のサイズを変更する方法はありますか?現在のところ、iPhoneの画面に収まるには大きすぎます。 –

+0

@Dat NGuyenこれが正しいかどうかわからない:このhttp://stackoverflow.com/questions/603907/uiimage-resize-then-crop投稿を見て、画像のサイズを変更したり、画像を文書や一時保存したりするイメージソースとしてローカルファイルを使用してください!お役に立てれば – 0x8badf00d

関連する問題