У меня есть приложение с кнопкой, покрывающей весь экран, и с маленькими кнопками в верхней части этой кнопки. Когда я нажимаю кнопку, я пишу текст, который показывает положение пальца, но когда я кладу палец на определенные области, где я ничего не вижу, кнопка перестает работать (нижняя правая область экрана), я уверен, что там там ничего нет Вот код:
.h файл:
{
UIButton *BigButton;
CGPoint FingerPos;
bool isFingerDown;
UILabel *FingerPosLabel;
}
-(void)Update;
-(IBAction)FingerMoved:(id)sender withEvent:(UIEvent*)event;
-(IBAction)FingerPressed:(id)sender withEvent:(UIEvent*)event;
-(IBAction)FingerReleased:(id)sender withEvent:(UIEvent*)event;
.m файл
{
viewDidLoad
{
BigButton = [UIButton buttonWithType:UIButtonTypeCustom];
[BigButton setFrame:CGRectMake(0, 0, 300, 480)];
[self.view addSubview:BigButton];
FingerPos = CGPointMake(0, 0);
isFingerDown = false;
FingerPosLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 300, 50)];
[self.view addSubview:FingerPosLabel];
[FingerPosLabel setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]];
[FingerPosLabel setTextColor:[UIColor redColor]];
[BigButton addTarget:self action:@selector(FingerPressed:withEvent:) forControlEvents:UIControlEventTouchDown];
[BigButton addTarget:self action:@selector(FingerReleased:withEvent:) forControlEvents:UIControlEventTouchUpInside];
[BigButton addTarget:self action:@selector(FingerMoved:withEvent:) forControlEvents:UIControlEventTouchDragInside];
}
-(IBAction)FingerPressed:(id)sender withEvent:(UIEvent *)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint endingPosition = [touch locationInView:self.view];
FingerPos = endingPosition;
isFingerDown = true;
}
-(IBAction)FingerMoved:(id)sender withEvent:(UIEvent *)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint endingPosition = [touch locationInView:self.view];
FingerPos = endingPosition;
}
-(IBAction)FingerReleased:(id)sender withEvent:(UIEvent *)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint endingPosition = [touch locationInView:self.view];
FingerPos = endingPosition;
isFingerDown = false;
}
Я уверен, что над кнопкой BigButton нет никаких кнопок или видов любого вида, хотя есть кнопка над невидимой областью, хотя и далеко вверх