在Tabbar DidSelectItem中使用NSNotification来调用向上滚动方法。
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"homeScrollUp" object:nil];
}
它工作得很好但是如何通过点击索引标签0两次来检测它?例如?
答案 0 :(得分:0)
如何链接此内容?确保在清理课程时使计时器无效。
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
NSUInteger indexOfTab = [[theTabBar items] indexOfObject:item];
if(indexOfTab==0) {
self.chosenIndexTapped++
}
self.tabPressTimer = [NSTimer scheduledTimerWithTimeInterval:smallTimeToAllowTap
target:self
selector:@selector(handleRecognisedTap)
userInfo:nil
repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:self.tabPressTimer forMode:NSRunLoopCommonModes];
}
-(void)handleRecognisedTap {
if(self.chosenIndexTapped>1){
//Scroll to top
}
self.chosenIndexTapped = 0 //Reset the taps on your chosen index
}