I have this UIWebView
inside a custom UITableViewCell
that I've created.
The problem is, when I implement the UIWebView
in "MyMain"
, it's working but when I scroll the text is readded again and again on over the cells.
When I implement the UIWebView
in the custom cell class itself it's not showing it at all.
UITableViewCustomCell.h
@property (nonatomic, weak) IBOutlet UIWebView *wvMainText;
@property (nonatomic, strong) NSString *wvTitle;
@property (nonatomic, strong) NSString *wvPrice;
UITableViewCustomCell.m
@synthesize wvMainText = _wvMainText;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
// THIS IS WHERE I IMPLEMENT THE WEBVIEW?
}
return self;
}
MyMain
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"myListCell";
UITableViewCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"UITableViewCustomCell" owner:nil options:nil];
for (UIView *view in views) {
if([view isKindOfClass:[UITableViewCell class]])
{
cell = (UITableViewCustomCell *)view;
}
}
}
cell.wvTitle = [[self.arrList objectAtIndex:indexPath.row] valueForKey:@"title"];
cell.wvPrice = [[self.arrList objectAtIndex:indexPath.row] valueForKey:@"price"];
wv.scrollView.scrollEnabled = NO;
NSString *htmlString = [NSString stringWithFormat:
@"<html><body>%@,%@</body></html>", self.wvTitle, self.wvPrice];
[wv loadHTMLString:htmlString baseURL:nil];
[wv setBackgroundColor:[UIColor clearColor]];
[wv setOpaque:NO];
return cell;
}