2014-03-19 31 views
0

這是我的pList。根數組名是mainList:Tableview中的兩個不同的單元格

enter image description here

我想看看@ 「BankaAdi」 並@我的tableview 「Urun」(taksitler陣列)。

我想我應該創建第二個單元格寫@「Urun」因爲我的主要細胞只寫@「BankaAdi」與此代碼:

cell.textLabel.text = 
    [[mainList objectAtIndex:indexPath.row] objectForKey:@"BankaAdi"]; 

我怎麼能看到我的@「Urun」串在我的的tableview?

+0

仍然沒有答案!請別人幫我.. – leonthegosu

+0

大家好嗎? – leonthegosu

+0

所以你想有一個兩節的表?我對嗎? –

回答

0

從我的理解,你需要的是一張有兩個不同部分的表格。因此,在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath中,您需要根據該部分設置您的單元格。

下面是它看起來應該像:

- (NSInteger)numberOfRowsInSection:(NSInteger)section 
{ 
    if (section == 1) 
    { 
    // for first part 
    return array1.length; 
    } 
    else 
    { 
    // for second part 
    return array2.length; 
    } 
} 


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 2; 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell cell = nil; 
    if (indexPath.section == 0) 
    { 
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1 forIndexPath:indexPath]; 
    cell.textLabel.text = [[mainList objectAtIndex:indexPath.row] objectForKey:@"Adi"]; 
    cell.detailTextLabel.text= [NSString stringWithFormat:@"%.2f TL",[[[mainList objectAtIndex:indexPath.row] objectForKey:@"dAdi"] floatValue]]; 
    } 
    else 
    { 
    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2 forIndexPath:indexPath]; 
    cell.textLabel.text = [[mainList objectAtIndex:indexPath.row] objectForKey:@"Adi"]; 
    cell.detailTextLabel.text= [NSString stringWithFormat:@"%.2f TL",[[[mainList objectAtIndex:indexPath.row] objectForKey:@"dAdi"] floatValue]]; 
    } 
    return cell; 
} 
+0

首先感謝您的回答......我試圖再次解釋我的問題。請看看我的問題。 – leonthegosu

相關問題