tags:

views:

72

answers:

0

Objective-C::

   1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {  
   2.   static NSString *CellIdentifier = @"Cell";  
   3.   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];  
   4.   if (cell == nil) {  
   5.     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];  
   6.     cell.selectionStyle = UITableViewCellSelectionStyleNone;  
   7.   }  
   8.   
   9.   // Set up the cell...  
  10.   NSString  *string = @"Go to <a href="http://cs193p.stanford.edu/" target="_blank" class="liexternal">CS193p website</a>";  
  11.   
  12.   CGRect frame = cell.contentView.bounds;  
  13.   frame = CGRectInset(frame, 10, 1);  
  14.   UIWebView *webView = [[UIWebView alloc] initWithFrame:frame];  
  15.   [webView loadHTMLString:string baseURL:nil];  
  16.   webView.delegate = self;  
  17.   [cell.contentView addSubview:webView];      
  18.   
  19.   return cell;  
  20. }  
  21.   
  22. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {  
  23.   if (navigationType == UIWebViewNavigationTypeLinkClicked)  
  24.   {  
  25.       WebViewController *webController = [[WebViewController alloc] init];  
  26.       webController.url = request.URL;  
  27.       [self.navigationController pushViewController:webController animated:YES];  
  28.       [webController release];  
  29.   
  30.     return NO;  
  31.   }  
  32.   return YES;  
  33. }

When the length of string is long, it is not settled well in the cell.

How should I do to adjust the height of webview and cell according to the length of string?