kippe in der Lage, fügen Sie im click-Ereignis UIbutton

Ich bin erstellen benutzerdefinierte Ansicht zwei labels und Ein button. I cant get die Schaltfläche klicken. Ich bin auch der Versand der code ist unten.

.h-Datei

#import <UIKit/UIKit.h>


@interface customDeleteButton : UITableViewCell {

    IBOutlet UILabel *lbl;
    IBOutlet UILabel *lbl1;
 }
 @property(nonatomic,retain)IBOutlet UILabel *lbl;
 @property(nonatomic,retain)IBOutlet UILabel *lbl1;
 -(IBAction)btnClick:(id)sender;
 @end

.m-Datei

#import "customDeleteButton.h"


@implementation customDeleteButton
@synthesize lbl,lbl1;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
    //Initialization code.
    lbl = [[UILabel alloc] initWithFrame:CGRectMake(50, 10, 200, 20)];
    lbl1 = [[UILabel alloc] initWithFrame:CGRectMake(260, 10, 200, 20)];
    [self addSubview:lbl];
    [self addSubview:lbl1];

}
return self;
}

- (void)willTransitionToState:(UITableViewCellStateMask)state{

[super willTransitionToState:state];


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


for (UIView *subview in self.subviews) {

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

        UIButton *btn;


        btn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
        [btn addTarget:subview action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [btn setImage:[UIImage imageNamed:@"delete.png"] forState:UIControlStateNormal];
        btn.userInteractionEnabled=YES;
        btn.frame=CGRectMake(0,0,64,33);
        //UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
        //[deleteBtn setImage:[UIImage imageNamed:@"delete.png"]];
        [[subview.subviews objectAtIndex:0] addSubview:btn];
        //[deleteBtn release];

    }       

}
  } 

}
 -(void)btnClick:(id)sender
{
    NSLog(@"HTllo");
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

     [super setSelected:selected animated:animated];

//Configure the view for the selected state.
 }


- (void)dealloc {
    [super dealloc];
}
InformationsquelleAutor Akash | 2012-01-23
Schreibe einen Kommentar