亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在UITableView單元格中進行編輯時,自定義刪除按鈕

在UITableView單元格中進行編輯時,自定義刪除按鈕

iOS
湖上湖 2019-10-18 10:05:04
我走過了這個問題,顯示下面的代碼:-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{    return @"Sagar";}如果我想要一個自定義圖像而不是默認的紅色按鈕怎么辦?
查看完整描述

3 回答

?
慕容708150

TA貢獻1831條經驗 獲得超4個贊

luvieere是正確的-如果您想要相同的“刪除”隱喻,則希望將其保留在Apple提供的紅色按鈕上。為什么要改變它?它是全球公認的刪除按鈕的標準。

雖然,如果您想要完全改變滑動行為的Tweetie之類的東西,則可以使用ABTableViewCell之類的東西,您只需在自己的視圖中繪制即可。進行自定義表格視圖,覆蓋-touchesBegan:withEvent :,然后檢查是否有觸摸。計算兩次觸摸的增量(在touchesMoved:withEvent:中),然后移動自己的視圖。


查看完整回答
反對 回復 2019-10-18
?
白衣非少年

TA貢獻1155條經驗 獲得超0個贊

在自定義單元中實現此方法


- (void)willTransitionToState:(UITableViewCellStateMask)state{

    [super willTransitionToState:state];

    if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) {

        for (UIView *subview in self.subviews) {

            if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {

                UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];

                [deleteBtn setImage:[UIImage imageNamed:@"delete.png"]];

                [[subview.subviews objectAtIndex:0] addSubview:deleteBtn];

                [deleteBtn release];

            }

        }

    }

}


查看完整回答
反對 回復 2019-10-18
  • 3 回答
  • 0 關注
  • 665 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號