2011-10-06 39 views
1

在accessoryView /披露區域創建帶有「信息符號」的UITableViewCell的最佳方式是什麼?就像iTunes Connect app那樣,當你登錄的時候有一個Account Name單元,它有一個「信息」按鈕,你可以點擊。它基本上在左邊有文本Account Name,然後是用於輸入帳戶名稱的文本字段,右邊是可以單擊的信息圖標。如何在accessoryView /披露區域創建一個帶有「信息符號」的UITableViewCell? (如iTunes Connect應用程序)

問題方面: - 其中UITableViewCell風格是它使用? - 有沒有辦法將info按鈕設置爲公開類型?或者它是一個自定義單元格,您必須將自己的圖像放在那裏 - 然後根據以上項目的答案,如何捕捉信息按鈕按鈕按下以觸發某些幫助文本以顯示爲模式對話框

背景 - 我想用它作爲一種手段,允許用戶在每個項目上獲得基於上下文的幫助。

回答

2

嘗試這種根據其中u希望

UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight]; 
button.frame = CGRectMake(3,8,30, 30); 
[button addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventTouchUpInside]; 
[cell.contentView addSubview:button]; 
+1

或者只設置信息按鈕作爲附件view:'cell.accessoryView = button;' – Nekto

+0

謝謝 - 我試過了「cell.accessoryView = button」的方法。然而,我注意到,當我點擊內容視圖子視圖的UITextField時,附件視圖區域中有一個陰影/偏移量信息圖像......任何想法? – Greg

+0

這裏是我看到的陰影的例子 - 再次一切看起來不錯,直到我點擊textField,然後出現陰影:http://postimage.org/image/32nafruxw/ – Greg

2

我想你想要的是 你可以只設置一個細節附件視圖設置框:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

cell.accessoryType = UITableViewCellAccessoryDetailDisclosureIndicator; 

這給出了一個小箭頭>在右邊。當用戶點擊一個單元格時,tableView委託獲取didSelectRowAtIndexPath:消息。使用披露指標,您通常會通過推送包含所需信息的新viewController進行響應。

[self.navigationController pushViewController:self.itemHelpVC animated:YES]; 
+0

謝謝蘇茲 - 但我其實想要的info/help圖標(就像在iTunes Connect應用程序中一樣) - Ron/Nikto的答案是99%的方法,但是我只是在點擊contentView中的textField後在accessoryView中獲得陰影/偏移量信息圖像細胞的面積。 – Greg

0

從iOS的8 UITableViewCellAccessoryDe​​tailButton有一個信息按鈕的形式,所以你只需要這樣:

cell.accessoryType = UITableViewCellAccessoryDetailButton; 

結果:

tableviewcell with accessory detail button

相關問題