这是我的所有代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(pushTableViewController:)];
self.navigationItem.leftBarButtonItem = leftItem;
}
- (void)pushTableViewController:(id)sender {
TableViewController *tableViewController = [[TableViewController alloc]init];
[self.navigationController pushViewController:tableViewController animated:YES];
}
TableViewController
代码为:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIBarButtonItem *myMessageButton = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStylePlain target:self action:@selector(myMessageButtonClicked:)];
self.navigationItem.leftBarButtonItem = myMessageButton;
UITableView *scrollTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
scrollTableView.delegate = self;
scrollTableView.dataSource = self;
[self.view addSubview:scrollTableView];
}
- (void)myMessageButtonClicked:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
}
使用最简单的方法来使用UITableView
,并实施scrollViewDidScroll
当我将UITableView
滚动到底部,然后popViewControllerAnimated
我崩溃了。
是IOS的这个BUG?或者我哪里出错?
答案 0 :(得分:1)
问题是,tableview尝试在动画viewController期间访问scrollViewDidScroll
委托方法。所以在达到底部滚动后,在popViewController之前将datasource
和delegate
设置为Nil。
答案 1 :(得分:0)
试试这个
ExampleviewController * example = [[ExampleviewController alloc]] init];
[self.navigationController pushViewController:example animated:YES];
检查声明UIScrollView Delegate不是