Skip to content

Instantly share code, notes, and snippets.

@projectxcappe
Created December 1, 2011 23:09
Show Gist options
  • Save projectxcappe/1420583 to your computer and use it in GitHub Desktop.
Save projectxcappe/1420583 to your computer and use it in GitHub Desktop.
addTarget to another class
//BCWebAdView.m
-(void)testmethod:(id)sender{
NSLog(@"testmethod");
}
//-----------//
//TLAdView.m
#import "TLAdView.h"
#import "BCWebAdView.h"
#import "TLUtil.h"
#import "BCWebAdView.h"
@implementation TLAdView
@synthesize adView;
@synthesize adButton;
@synthesize delegate;
BCWebAdView *instanceOfBCWebAdView;
//-----
-(void)createButtonTLAdView {
NSLog(@"createButtonTLAdView");
self.adButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[adButton setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 50.0f)];
adButton.backgroundColor = [UIColor greenColor];
adButton.opaque = YES;
[self.adButton setUserInteractionEnabled:YES];
[adButton addTarget:instanceOfBCWebAdView action:@selector(testmethod:) forControlEvents:UIControlEventTouchUpInside];
NSLog(@"thisbutton %@", adButton);
[self addSubview:adButton];
[self.adButton setNeedsDisplay];
[self setNeedsDisplay];
[self subviews];
}
//---------//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment