2014-03-03 49 views

回答

0

@Stonz是正確的,你需要使用一個原型,並在cellForRowAtIndexPath

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

    // use a prototype cell 
    static NSString *CellIdentifier = @"imageCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    //ImageViews 
    UIImageView *image1 = (UIImageView *)[cell viewWithTag:1]; 
    [image1 setImage:[UIImage imageNamed:@"stack"]]; 
    UIImageView *image2 = (UIImageView *)[cell viewWithTag:2]; 
    [image2 setImage:[UIImage imageNamed:@"super"]]; 
    UIImageView *image3 = (UIImageView *)[cell viewWithTag:3]; 
    [image3 setImage:[UIImage imageNamed:@"android"]]; 

    //Label 
    UILabel *label1 = (UILabel *)[cell viewWithTag:4]; 
    label1.text = @"Stackoverflow"; 
    UILabel *label2 = (UILabel *)[cell viewWithTag:5]; 
    label2.text = @"Superuser"; 
    UILabel *label3 = (UILabel *)[cell viewWithTag:6]; 
    label3.text = @"Android"; 

    return cell; 

} 

我添加一些代碼創建DEMO PROJECT爲您

,這裏是一個Screenshot

+1

非常感謝meda。圖像和標籤應該是動態的,因爲我不會在所有行中都有相同的圖像和標籤 – user3199271

+0

這些是動態原型單元格,它最多可以載入您的圖像 – meda

+1

謝謝meda。我明白了。你能告訴我更多的設計問題嗎?這是iPAD應用程序,假設我有6張圖像,比如像3行中的圖像,就像2行一樣,也不會出現滾動,我應該去查看桌面視圖還是應該靜態圖像。就像我會在我的應用程序中有6或7種這樣的屏幕,但具有不同的圖像。請讓我知道 – user3199271

1

您需要創建自定義UITableViewCell才能實現此目的。標準單元的顯示內容非常有限。有幾個在線教程(只是谷歌「自定義的UITableViewCell」)這裏是一個:Table View Cells

+0

謝謝。我知道如何創建一個自定義單元格,你能告訴我如何創建3列。 – user3199271

+0

您可以將標籤和圖像排列在自定義單元內您想要的位置。這就是你如何創建3列。 – Aaron

+0

你是說你想要3個獨立滾動的列嗎?因此,在第2列中向下滾動會將第1列和第3列保留在哪裏? – Stonz2

相關問題