Más contenido relacionado
Más de Yuichi Yoshida (10)
UIToolbarの同時タッチを防ぐ
- 19. /**!
* UIButtonをUIBarButtonItemにセット!
* addTergetで触ったタイミングを検出・・・!
**/!
UIButton *insideButton = [UIButton
buttonWithType:UIButtonTypeCustom];!
insideButton.bounds = CGRectMake(0, 0, 44, 44);!
[insideButton setImage:[UIImage imageNamed:@"hoge.png"]
forState:UIControlStateNormal];!
UIBarButtonItem *item = [[UIBarButtonItem alloc]
initWithCustomView:insideButton];
ないわー,絶対ないわー!
Storyboardとか使えないですやん
- 21. - (void)viewDidLoad {!
[super viewDidLoad];!
! C2ToolbarTapGestureRecognizer* tapGesture = !
! ! [[C2ToolbarTapGestureRecognizer alloc] initWithTarget:nil action:nil];!
! tapGesture.dummyDelegate = self;!
! tapGesture.delegate = self;!
! [self.toolbar addGestureRecognizer:tapGesture];!
}
カスタムのGestureRecognizerをUIToolbarにセット.
UINavigationControllerのサブクラスで
- 22. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {!
! self.state = UIGestureRecognizerStatePossible;!
! [self.dummyDelegate didBeginDummyTap:self];!
}!
!
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {!
! self.state = UIGestureRecognizerStateFailed;!
! [self.dummyDelegate didEndDummyTap:self];!
}!
!
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {!
! self.state = UIGestureRecognizerStateFailed;!
! [self.dummyDelegate didEndDummyTap:self];!
}
タップのダウン・アップを検出し,UINav.に送る