我正在創建一個使用Web服務的應用程序。並檢索用戶列表,並獲取像圖像,用戶ID和名稱等詳細信息。我在表視圖中顯示與用戶有關的所有信息,因此每個單元格表格視圖有一張圖片,裏面有表格。我正在使用自定義單元格類來創建單個單元格。選擇表格中的任何一行都會顯示詳細視圖(使用導航),其中顯示了較大的圖像以及與我選擇的特定用戶相關的所有詳細信息。如何提高在表視圖的單元格中使用UIWebView的性能?
在自定義單元格和詳細視圖類我正在使用web視圖來顯示圖像。 但是,當我運行應用程序的圖像得到了一點延遲顯示和相同的細節視圖發生。
是否有任何替代方案,以便我可以提高表視圖的性能,這樣我就可以順利滾動表視圖,而無需在圖像加載和詳細視圖中進行任何延遲? 這裏是代碼...
- (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服務並獲取有關用戶的所有數據。
任何幫助,非常感謝。在此先感謝
我嘗試了圖像視圖還,但我應用程序崩潰了幾次。你有沒有與該班級的任何聯繫。感謝您的回覆 – Rakesh 2010-12-02 05:43:38
文檔位於http://api.three20.info/interface_t_t_styled_text_table_cell.php - 實際上甚至有一個函數(`[TTStyledText textFromXHTML:]`),它將簡單的XHTML轉換爲可以粘貼的樣式文本塊在細胞中。 – Ertebolle 2010-12-02 05:48:37