ios 点击navbar 标题栏 tableview返回顶部

一、设置navbar触摸事件
code

二、tableview返回顶部事件

- (void)viewDidLoad {
    [super viewDidLoad];
        self.navigationController.navigationBar.userInteractionEnabled=YES;
    UITapGestureRecognizer * tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(scrollToTop:)];
    [self.navigationController.navigationBar addGestureRecognizer:tap];
}

-(void)scrollToTop:(UITapGestureRecognizer *)sender{
    [self.tableView setContentOffset:CGPointMake(0,-50) animated:YES];
}
相关文章
相关标签/搜索