我有一個表格視圖,其中數字單元格不固定,並且會不斷變化。我必須在桌腳的最後一個單元格後顯示兩個動作按鈕。如何在我的最後一個細胞後正確放置它們?我知道最後一個單元格和這些按鈕之間的像素間距。任何代碼示例都會非常有用。桌面頁腳視圖中的按鈕位置
1
A
回答
0
您可以隨時將兩個按鈕添加到最終的單元格。
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
return [myCellDataArray count]+1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
if (indexPath.row > [myCellDataArray count]) {
cell = [tableView dequeueReusableCellWithIdentifier:@"Button Cell"];
if (cell == nil) {
UIButton *firstButton = [[UIButton alloc] init];
//customization
UIButton *secondButton = [[UIButton alloc] init];
//customization
[cell addSubView:firstButton];
[cell addSubView:firstButton];
}
} else {
// normal stuff
}
如果你想定製你需要設置它的標籤,以獨特的東西,即firstButton.tag = 100
現有的按鈕,然後通過firstButton = (UIButton *)[cell viewWithTag:100];
設置firstButton。確保你定義了firstButton
,以便它在範圍內!
希望這會有所幫助!
1
你有沒有試過將它們粘在一個視圖中並將其設置爲頁腳視圖?
在添加之前,您需要給它正確的高度;寬度會自動設置爲表格的寬度。將其設置爲合理的寬度(例如320)並使用自動調整大小或使用自定義UIView子類並實現-layoutSubviews。
相關問題
- 1. 在桌面視圖下添加按鈕
- 2. jQuery mobile:頁面按鈕的位置
- 3. 如何維護桌面視圖中的按鈕圖像狀態
- 4. 圖像按鈕裏面的div位置
- 5. 在桌面視圖中點按鈕 - 錯誤的單元格
- 6. 如何更改桌面視圖之外的標籤文本時,在桌面視圖中的按鈕是點擊
- 7. 按鈕位置在列表視圖android
- 8. 桌面視圖按鈕點擊需要在iOS中pickerview
- 9. 獲取桌面圖標的位置?
- 10. 獲取桌面上圖標的位置
- 11. 在頁面底部的位置頁腳
- 12. 如何修復桌面的位置如何修復桌面的位置如何修改桌面位置
- 13. iPhone桌面視圖 - 一些按鈕/操作問題
- 14. 「Overscroll」桌面視圖
- 15. 在列表視圖中查找按鈕的位置
- 16. 如何在頁面上設置按鈕位置
- 17. 應用CSS設置位置裏面的圖標按鈕
- 18. 按鈕onClick在視圖模式列表視圖中獲取錯誤的位置
- 19. 桌面視圖中的圖像
- 20. 如何在一個充滿按鈕的桌面視圖中推動標籤?
- 21. 如何測量頁面中的列表視圖行位置
- 22. 帶手勢和按鈕的自定義頁腳視圖
- 23. 在表格視圖單元末尾添加頁腳的按鈕
- 24. 按鈕位置
- 25. 返回頁首頁腳中的按鈕
- 26. 我該如何讓three20在桌面視圖中記住我的滾動位置?
- 27. 位於頁面底部的CSS位置頁腳
- 28. 位於頁面底部的tcpdf位置頁腳
- 29. 卡片視圖上的Android按鈕,點擊卡片視圖的位置
- 30. 在按鈕上獲取文本框值在桌面視圖中單擊
UITableView是Cocoa Touch的一部分,而不是Cocoa。 – 2010-11-23 05:39:49
我的不好。感謝您糾正我! – Abhinav 2010-11-23 05:47:43