Я работаю над движком OpenSource Magazine, который вы можете посмотреть на GitHub:
https://github.com/interactivenyc/Defrag
Я установил UIToolbar в UIView, который я назвал MenuPanel,По какой-то причине UIBarButtonItems в UIToolbar не вызывают свои действия должным образом.Вот синтаксис, который я использую для кнопок:
UIBarButtonItem *homeItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"home.png"] style:UIBarButtonItemStylePlain target:self action:@selector(buttonClicked:)];
Что происходит , так это то, что где бы я ни нажимал на своем экране, вместо этого вызывается UITapGestureRecognizer, объявленный в моем основном UIViewController,Это настраивается в этом блоке кода в моем главном контроллере UIViewController:
- (void)setupGestureRecognizers {
//NSLog(@"setupGestureRecognizer NEW");
UISwipeGestureRecognizer *swipeRecognizer;
swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRecognizer];
[swipeRecognizer release];
swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeRecognizer];
[swipeRecognizer release];
swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
[self.view addGestureRecognizer:swipeRecognizer];
[swipeRecognizer release];
swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionDown;
[self.view addGestureRecognizer:swipeRecognizer];
[swipeRecognizer release];
UITapGestureRecognizer *tapRecognizer;
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[self.view addGestureRecognizer:tapRecognizer];
[tapRecognizer release];
}
Я уверен, что у меня что-то довольно простое концептуально неправильно с тем, как я пытаюсь это сделать.Может кто-нибудь сказать мне, как я могу решить эту проблему?
Для справки, вы можете увидеть мой основной DefragViewController: UIViewController здесь:
https://gist.github.com/1431722
И мойПанель меню: UIV Просмотреть здесь:
gist.github.com / 1431728