How to improve performance while using UIWebView in cells of table view?

I am creating an application which uses a web service.And retrieves a list of users and there details like images, user id and there names.I displayed all the information related to users in table view, Thus each of the cell in the table view has an image with the for tables in it. I am using a Custom cell class to create the individual cells. selecting any row in table presents a detail view (using navigation) which show a larger image and all the details related to the particular user i selected.

in customcell and detail view class i am using web view to display image. But when i run the app the images gets a bit of delay to display and same happens with the detail view.

Is there any alternative so that i can improve the performance of the table view so that i can have smooth scrolling of table view with out any delay in image loading and detail view?? here is the code...

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

{
    static NSString *CustomCellIdentifier = @"CustomCellIdentifier ";

CustomCell *cell = (CustomCell *)[tableView 
                                  dequeueReusableCellWithIdentifier: CustomCellIdentifier];
if (cell == nil)  
{

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil ];
    //cell = [[CustomCell alloc] initwi ];
    for (id oneObject in nib)
        if ([oneObject isKindOfClass:[CustomCell class]])
           cell = (CustomCell *)oneObject;

}
NSUInteger row = [indexPath row];
NSString *imageName = [imgArray objectAtIndex:row];
NSString *completeImageUrl = [[NSString alloc] initWithFormat:@"http://122.160.153.166:201/%@", imageName];

NSURL *url = [NSURL URLWithString:completeImageUrl];
//NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
NSData *imageData = [[NSData alloc] initWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:imageData];     /// check to see if we are getting all the arrays such as image array and userId array and name array of same size..
if(image == nil)
{

}
cell.imgView.image = image;                             /// other wise an execption of out out array range will be shown

[image release];
[imageName release];

//[cell.webView initWithFrame:CGRectZero];
//[cell.webView loadRequest:requestObj];
//cell.webView.frame = CGRectMake(20, 0, 80.0, 64);
cell.userIdLabel.text = (NSString *)[userId objectAtIndex:row];
cell.nameLabel.text = (NSString *)[userName objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;

}`

i think problem can be in imgArray array as i am setting it from other class. Where i request the web service and fetched all the data about users .

Any help is greatly appreciated . Thanks in advance

Answers


I got the same problem. For that I used EGOImageCache and some thing. Find this Url for EGOImage

Download files those names starts with "EGO", and add those to your project.

and write the following code where ever you want to put the image:

EGOImageView *imgView = [[EGOImageView alloc] initWithFrame:CGRectMake(50,50,220,360)];
NSString *imageName = [imgArray objectAtIndex:row];
NSString *completeImageUrl = [[NSString alloc] initWithFormat:@"http://122.160.153.166:201/%@", imageName];

NSURL *url = [NSURL URLWithString:completeImageUrl];

imgView.imageUrl = url;

[self.view addSubView:imgView];

Thats it. Use the similar code, where ever you want the image. At the first time while loading it will take some time to download the image. But later it will cache the image and use it the next time.


Need Your Help

.htaccess · Use rewritecond to work with includes?

php .htaccess templates mod-rewrite

What I want to do is have multiple directories (created not physically) that granting them access to an file_template.php

How to turn off php-indent warning in Emacs

php html emacs elisp emacs23

When editing a PHP file with PHP code and HTML markup in Emacs, I continue to get the warning:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.