I've been creating my own buttons by subclassing UIButton and drawing the buttons programatically. In order to provide touch functions I've been using the addTarget:action:forControlEvent method but I've come unstuck.
Even though I can use the addTarget method to capture touch events, only the sender gets sent to the selector and so no touch information is available (locationInView etc.)
For example, creating the button;
And the selector;
As far as I can figure out, there's no way to prototype the buttonPressed selector so that you can pass it touch information in the same way that;
does.
Can anyone give me some pointers?
Thanks
Even though I can use the addTarget method to capture touch events, only the sender gets sent to the selector and so no touch information is available (locationInView etc.)
For example, creating the button;
Code:
UIButton *myButton = [[UIButton alloc] initWithFrame:CGRectMake(100,100,50,50)];
[myButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown];
[self.view addSubview:myButton];
And the selector;
Code:
-(void) buttonPressed:(id)sender
{
....
}
As far as I can figure out, there's no way to prototype the buttonPressed selector so that you can pass it touch information in the same way that;
Code:
-(void) touchBegain:(NSSet *)touches withEvent:(UIEvent *)sender
Can anyone give me some pointers?
Thanks