没有UITableViewController的UIRefreshControl不调用选择器 [英] UIRefreshControl without UITableViewController not calling selector

查看:107
本文介绍了没有UITableViewController的UIRefreshControl不调用选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIViewController,其中有一个UITableView作为子视图。我正在尝试在桌子上添加一个下拉菜单。

I have a UIViewController that has a UITableView as a subview. I am trying to add a pull-to-refresh on the table.

下面是我发现的一些示例和讨论此处,我显示了UIRefresh,但从未调用选择器。我没有收到发生拉动动作的通知。

Following some examples and discussions that I found here, I have the UIRefresh showing but it never calls the selector. I am not getting notified that the pull action happened.

我不能使用UITableViewController作为我的主控制器,因为我需要在屏幕底部添加一个固定按钮。

I cannot use a UITableViewController as my main controller as I need to add a fixed button at the bottom of the screen.

我感觉自己缺少了一些希望对其他人显而易见的东西。

I have the feeling I am missing something out that hopefully is obvious to someone else.

@interface ActivityViewController ()<UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate>
@end



- (void)viewDidLoad{

    [super viewDidLoad];

    _myTableView.delegate = self;

    _myTableView.dataSource = self;

    _tableViewController = [UITableViewController new];

    _tableViewController.tableView = _myTableView;

    [self addChildViewController:_tableViewController]; // Not sure this is necessary

    _refreshControl = [UIRefreshControl new];

    [_refreshControl addTarget:self action:@selector(loadMoreData) forControlEvents:UIControlEventValueChanged];

    _tableViewController.refreshControl = _refreshControl;

}

- (void)loadMoreData{

    NSLog(@"loadMoreData");
}


推荐答案

好的,现在可以了。但是我不确定为什么!我有点离开了,改变了其他需要做的事情,然后昨晚再次测试,它开始工作了。我承认我有点困惑。我使用了以前的帖子此处中给出的答案中的以下代码几天之前。因此,感谢您的时间和投入。

Ok this is now working. But I am not sure why!! I kinda left it for a bit, changed other things that needed doing and then tested once more last night and it was working. I admit I am a bit confused. I used the code below from this answer given in earlier posts here as I did a few days ago. So thank you for the time and input. It works perfect now, as expected.

// Refresh control
UITableViewController *tableViewController = [[UITableViewController alloc] init];
tableViewController.tableView = self.myTableView;

self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(loadMoreData) forControlEvents:UIControlEventValueChanged];
tableViewController.refreshControl = self.refreshControl;

这篇关于没有UITableViewController的UIRefreshControl不调用选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆