I created a .xib file form my custom view. I created .h/.m files for that view. I ctrl dragged from button to header file to create an IBAction and set the value to touchUpInside. Here is what is happening:
http://screencast.com/t/R1WTpK7xp
WTF?
It triggers event when up is outside the button?
EDIT:
Here is the screenshot:
And what is the thing with down vote? I don't see a point in that.
View.h
#import <UIKit/UIKit.h>
#import "DrawingViewDelegate.h"
@interface DrawingBottomToolbarView : UIView
@property (weak) id <DrawingViewDelegate> delegate;
- (IBAction)lineSegmentButtonPush:(id)sender;
@end
View.m
#import "DrawingBottomToolbarView.h"
@implementation DrawingBottomToolbarView
@synthesize delegate;
- (id)initWithFrame:(CGRect)frame
{
NSLog(@"frame");
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self addSubview:[[[NSBundle mainBundle] loadNibNamed:@"DrawingBottomToolbarView" owner:self options:nil] objectAtIndex:0]];
//[[[NSBundle mainBundle] loadNibNamed:@"DrawingBottomToolbarView" owner:self options:nil] objectAtIndex:0];
//[self addSubview:self.];
}
return self;
}
//-(id)initWithCoder:(NSCoder *)aDecoder{
//
// NSLog(@"coder");
// if ((self = [super initWithCoder:aDecoder])){
// [self addSubview:[[[NSBundle mainBundle] loadNibNamed:@"DrawingBottomToolbarView" owner:self options:nil] objectAtIndex:0]];
// }
// return self;
//}
- (IBAction)lineSegmentButtonPush:(id)sender
{
NSLog(@"line push");
}
@end
I don't get it where is the problem.
EDIT 2:
I tried setting buttons as outlets and add target/action in code and same thing happens:
.h
@property (weak, nonatomic) IBOutlet UIButton *lineSegmentButton;
.m
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self addSubview:[[[NSBundle mainBundle] loadNibNamed:@"DrawingBottomToolbarView" owner:self options:nil] objectAtIndex:0]];
self.currentSelectedPathSegment = NoneSegment;
[self.lineSegmentButton addTarget:self action:@selector(lineSegmentButtonPush:) forControlEvents:UIControlEventTouchUpInside];
}
return self;
}
EDIT 3: Here is where I add two views. drawing view is created in code, bottomToolbar is created from .xib file.
kBottomToolbarHeight is constant with same value as height defined in .xib file.
- (void)viewWillAppear:(BOOL)animated
{
[self.view addSubview:self.drawingView];
[self.view addSubview:self.bottomToolbar];
CGRect selfRect = self.view.bounds;
CGRect drawingViewRect = selfRect;
CGRect bottomToobarRect = selfRect;
drawingViewRect.size.height = selfRect.size.height - kBottomToolbarHeight;
bottomToobarRect.size.height = kBottomToolbarHeight;
bottomToobarRect.origin.y = drawingViewRect.size.height;
self.drawingView.frame = drawingViewRect;
self.bottomToolbar.frame = bottomToobarRect;
}