如何在表格视图的单元格中使用UIWebView时提高性能? [英] How to improve performance while using UIWebView in cells of table view?

查看:54
本文介绍了如何在表格视图的单元格中使用UIWebView时提高性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个使用Web服务的应用程序,并检索用户列表以及图像,用户ID和名称等详细信息.我在表格视图中显示了与用户相关的所有信息,因此每个单元格表格视图中有一个图像,其中包含for表格.我正在使用自定义单元格类来创建单个单元格.选择表中的任何行都会显示一个详细信息视图(使用导航),该视图显示较大的图像以及与所选特定用户有关的所有详细信息.

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.

在customcell和局部视图类中,我正在使用Web视图显示图像. 但是,当我运行该应用程序时,图像显示会有些延迟,并且详细视图也会发生同样的情况.

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;

}`

我认为问题可能出在imgArray数组中,因为我是从其他类设置它的.我在哪里请求Web服务并获取有关用户的所有数据.

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

推荐答案

好吧,最后我从应用程序中删除了uiweb视图,并使用了Imaged视图并成功. 我使用了tweetie开发人员提供的链接.这是链接文本

okay finally i removed the uiweb view from my app and used Imaged view and succeed. i used the link that was given by the developer of the tweetie . here it is link text

我使用ABTableViewCell类,并使用代码创建了整个单元格. 当我执行该应用程序时,滚动非常生涩.经过将近4个小时的应用,并在延迟加载的帮助下,我能够流畅地运行我的应用.我将从url中检索到的数据存储到一个数组中,然后在tableView:cellForRowAtIndexPath中应用了该概念: 方法.

i used the ABTableViewCell class and created the whole cell using the code. The scrolling was very jerky when i executed the app. after applying almost 4 hours and with the help of lazy loading i was able to run my app smoothly. I stored the data which is retrieved from url into an array then applied the concept in tableView:cellForRowAtIndexPath: method..

谢谢你们对我的帮助...

Thanks you guys for helping me ...

这篇关于如何在表格视图的单元格中使用UIWebView时提高性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆