2013-07-11 233 views
1
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

static NSString *[email protected]"Cell"; 
MagazineListCell* cell=(MagazineListCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
if(cell==nil) 
{ 
    NSArray *arr=[[NSBundle mainBundle]loadNibNamed:@"MagazineListCell" owner:nil options:nil]; 
    cell=(MagazineListCell *)[arr objectAtIndex:0]; 
    [cell setDelegate:self]; 
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
} 

NSMutableArray *arr=[[NSMutableArray alloc]init]; 
NSInteger startIndex; 
NSInteger endIndex; 

if(isLandscape) 
{ 
    startIndex=indexPath.row*3; 
    if (startIndex+3>[self.arrMagazine count ]) 
    { 
     endIndex=[self.arrMagazine count]; 
    } 
    else 
    { 
     endIndex=startIndex+3; 
    } 
} 
else 
{ 
    startIndex=indexPath.row*2; 
    if (startIndex+2>[self.arrMagazine count]) 
    { 
     endIndex=[self.arrMagazine count]; 
    } 
    else 
    { 
     endIndex=startIndex+2; 
    } 
} 
for (int x=startIndex; x<endIndex; x++) 
{ 
    [arr addObject:[self.arrMagazine objectAtIndex:x]]; 
} 
[cell setSelectedIndex:btnSegment.selectedSegmentIndex]; 
[cell contentForTableViewCell:arr setUIMode:isLandscape] ; 
arr=nil; 
return cell; 

} 
+0

你有沒有做過任何分析,找出什麼是花時間? – Wain

+0

爲什麼不在willRotateToIntefaceOrientation方法中保留if-else條件代碼?在這裏,每次重新載入表時,它都會被調用,即使它的方向相同。 – Mrunal

+0

這是不是好主意,將您的邏輯內cellForRowAtIndexPath,我可以知道如何以及何時將訪問存儲在單元格中的數據... – karthik

回答

0

檢查您的重用標識符是否正在設置,因爲您可能每次都創建單元。

主要的問題可能是你每次創建的數組,循環周圍填充然後傳遞給單元格。在您需要之前,您應該嘗試完成所有設置。

+0

循環是對myApp的imp因爲我有段控制並必須加載表對於每一個新的視圖 –

+0

@wain ...我已經完成了配置和顯示單元格在索引路徑行中的行爲一個 –

+0

什麼是分析顯示,因爲這是事實,我們目前正在做的是受過教育的猜測... – Wain