2011-10-28 37 views
1

我想知道是否有可能將某種圖標/圖像分配給iPad應用程序中UISplitViewController左側的導航表單元格。HowTo? UISplitViewController TableCell Image

例如接下來的圖像行1 ...

http://www.cre8ive.kr/blog/wp-content/uploads/SplitViewTest_03.png

我想與編輯

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

的方法來處理這個。

這裏是我

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];  
    } 
    cell.textLabel.text = [NSString stringWithFormat:@"%i", indexPath.row +1]; 
    //Let the magic happen here :D 
    UIImage *image = [UIImage imageNamed:@"deviantart_dark.png"]; 
    //Nothing changes :(
    [[cell imageView] setImage:image]; 
    return cell; 
} 

任何想法?

回答

0

你可以使用下面的代碼,

cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage:imageNamed:@"deviantart_dark.png"]]; 
+0

Tryed它,這裏是結果 http://mbdesigns.de/Bildschirmfoto%202011-10-28%20um%2007.39.55.png 我還嘗試使用單元格大小的全尺寸背景圖像,但看起來相同。 我不認爲蘋果允許在splitviewcontroller導航中的圖標:( –

+0

確定他們這樣做,你可以發佈你使用的整個代碼,並且可以通過移除textLabel部分來嘗試,只設置背景顏色和文本textLabel – sElanthiraiyan

+0

這樣做的工作 - 但仍然有一個問題... 當我點擊單元格 - 背景消失(所以圖標/圖像)是不可見的等... 有沒有辦法設置背景對於細胞的活動狀態? –