91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

自定義UITableViewCell 并修改cell的deleteButton

發布時間:2020-07-30 06:25:32 來源:網絡 閱讀:1598 作者:zql5666641 欄目:開發技術

//
//  Cell.h
//  Demo2
//
//  Created by apple-zql on 13-6-19.
//  Copyright (c) 2013年 qian bodong. All rights reserved.
//

#import <UIKit/UIKit.h>


@protocol myCellDelegate <NSObject>

- (void)commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;

@end

@interface myCell : UITableViewCell

@property (nonatomic, assign) id<myCellDelegate> *myCellDelegate;
@property (nonatomic, retain) NSIndexPath *indexPath;

@end






//
//  Cell.m
//  Demo2
//
//  Created by apple-zql on 13-6-19.
//  Copyright (c) 2013年 qian bodong. All rights reserved.
//

#import "myCell.h"
#import <UIKit/UIControl.h>
#import <QuartzCore/QuartzCore.h>
@implementation myCell

@synthesize indexPath;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
   self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
   if (self) {
       // Initialization code
   }
   return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
   [super setSelected:selected animated:animated];

   // Configure the view for the selected state
}


- (void)layoutSubviews
{
   [super layoutSubviews];

//    NSLog(@"row is %d",row);
   for (UIView *subview in self.subviews) {
       if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {

           for (UIView *v in subview.subviews) {
               v.hidden = YES;
               if (self.showingDeleteConfirmation == NO)
               {
                   [self.layer removeAllAnimations];
                   [UIView animateWithDuration:0.4f animations:^(void){
                       [subview viewWithTag:101].frame = CGRectMake(6, 4, 63, 34);
                   }completion:^(BOOL finished) {
                       [[subview viewWithTag:101] removeFromSuperview];
                       [[subview viewWithTag:100] removeFromSuperview];
                   }];
                   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                   break;
               }

               if (self.showingDeleteConfirmation == YES) {
                   UIButton *delbuton = [[UIButton alloc] initWithFrame:CGRectMake(6, 4, 63, 34)];
                   [delbuton setImage:[UIImage p_w_picpathNamed:@"btn06_on(delete)_bookmark@2x.png"] forState:UIControlStateNormal];
                   [delbuton addTarget:self action:@selector(deleteBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
                   delbuton.tag = 100;
                   [subview addSubview:delbuton];
                   UIView *layer_view = [[UIView alloc] init];
                   layer_view.frame = CGRectMake(6, 4, 63, 34);
                   layer_view.backgroundColor = [UIColor whiteColor];
                   layer_view.tag = 101;
                   [subview addSubview:layer_view];

                   [UIView beginAnimations:@"me" context:nil];
                   [UIView setAnimationDuration:0.4f];
                    layer_view.frame = CGRectMake(6, 4, 0, 34);
                   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                   [UIView commitAnimations];
                   [delbuton release];
                   [layer_view release];
                   break;
               }
           }
       }
   }
}


- (void) willTransitionToState:(UITableViewCellStateMask)state{
   [super willTransitionToState:state];
//    NSLog(@"row is %d     row",row);
   //UITableViewCellStateShowingDeleteConfirmationMask
   if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) {
       for (UIView *subview in self.subviews) {
           if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
               //this is delete button

           }

           if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellContentView"]) {
               //this is contentView

           }
       }
   }
   //UITableViewCellStateDefaultMask
   if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateDefaultMask){
       for (UIView *subview in self.subviews) {
           if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
               //this is delete button
           }

           if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellContentView"]) {
               //this is contentView

           }
       }
   }
   NSLog(@"     delete show %d",self.showingDeleteConfirmation);
}

- (void) deleteBtnClicked:(id)sender
{
   [(id)self.myCellDelegate commitEditingStyle:UITableViewCellEditingStyleDelete forRowAtIndexPath:indexPath];
}

- (void)didTransitionToState:(UITableViewCellStateMask)state
{
   [super didTransitionToState:state];
}
@end

 然后 在Viewcontroller中實現 delegate的方法即可

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

临湘市| 东乡县| 涪陵区| 兰溪市| 蓬安县| 理塘县| 广州市| 南乐县| 汝州市| 呼伦贝尔市| 老河口市| 深州市| 长岭县| 青冈县| 陈巴尔虎旗| 房产| 宜阳县| 万盛区| 抚远县| 恩施市| 四川省| 玉龙| 平原县| 建阳市| 武胜县| 仁怀市| 和林格尔县| 仙桃市| 紫金县| 文昌市| 万源市| 六安市| 淮安市| 高雄市| 乃东县| 博白县| 老河口市| 霍山县| 清原| 淮阳县| 平遥县|