Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何添加UIRefreshControl_Ios_Uitableview_Uirefreshcontrol - Fatal编程技术网

Ios 如何添加UIRefreshControl

Ios 如何添加UIRefreshControl,ios,uitableview,uirefreshcontrol,Ios,Uitableview,Uirefreshcontrol,我想将UIRefreshControl添加到我的应用程序中,该应用程序在下拉表时从数据库中获取记录,我已经完成了以下代码,但它给了我类似的错误 2014-08-06 12:31:56.263 QuizUsindDB[1183:60b] -[ScoreViewController readScoreFromDatabase]: unrecognized selector sent to instance 0x8d3d8e0 2014-08-06 12:31:56.266 QuizUsindDB[1

我想将UIRefreshControl添加到我的应用程序中,该应用程序在下拉表时从数据库中获取记录,我已经完成了以下代码,但它给了我类似的错误

2014-08-06 12:31:56.263 QuizUsindDB[1183:60b] -[ScoreViewController readScoreFromDatabase]: unrecognized selector sent to instance 0x8d3d8e0
2014-08-06 12:31:56.266 QuizUsindDB[1183:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ScoreViewController readScoreFromDatabase]: unrecognized selector sent to instance 0x8d3d8e0'
*** First throw call stack:
(
    0   CoreFoundation                      0x018f81e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x016778e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01995243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x018e850b ___forwarding___ + 1019
    4   CoreFoundation                      0x018e80ee _CF_forwarding_prep_0 + 14
    5   libobjc.A.dylib                     0x0168982b -[NSObject performSelector:withObject:] + 70
    6   UIKit                               0x003393b9 -[UIApplication sendAction:to:from:forEvent:] + 108
    7   UIKit                               0x00339345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    8   UIKit                               0x0043abd1 -[UIControl sendAction:to:forEvent:] + 66
    9   UIKit                               0x0043afc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
    10  UIKit                               0x0043ac06 -[UIControl sendActionsForControlEvents:] + 48
    11  UIKit                               0x00a227e9 -[UIRefreshControl _setRefreshControlState:notify:] + 404
    12  UIKit                               0x00a22650 -[UIRefreshControl setRefreshControlState:] + 48
    21  CoreFoundation                      0x0195d43e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
    22  CoreFoundation                      0x0189e5cb __CFRunLoopRun + 1963
    23  CoreFoundation                      0x0189d9d3 CFRunLoopRunSpecific + 467
    24  CoreFoundation                      0x0189d7eb CFRunLoopRunInMode + 123
    25  GraphicsServices                    0x038ec5ee GSEventRunModal + 192
    26  GraphicsServices                    0x038ec42b GSEventRun + 104
    27  UIKit                               0x00337f9b UIApplicationMain + 1225
    28  QuizUsindDB                         0x0001038d main + 141
    29  libdyld.dylib                       0x01e41701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
UIRefreshControl的代码如上所示:

-(void)pullToRefresh
{
    self.refreshControl = [[UIRefreshControl alloc] init];
    self.refreshControl.tintColor = [UIColor blackColor];
    [self.refreshControl addTarget:self action:@selector(readScoreFromDatabase)
                  forControlEvents:UIControlEventValueChanged];
    [self.myTable addSubview:self.refreshControl];
    [self.refreshControl endRefreshing];

}
我在viewDidLoad中调用了[self pullToRefresh]

上面的代码用于初始化和调用选择器以刷新表。 我无法识别错误,有人能指出我的错误吗。

更改此行:

[self.refreshControl endRefreshing];
为此:

[self.refreshControl beginRefreshing];
在表视图完成必要的数据重新加载后,应调用EndRefresh方法


此外,崩溃日志表明您的-[ScoreViewController readScoreFromDatabase]:函数不存在。

它给我的错误是,“UIRefreshControl”没有可见的@interface声明选择器“startRefreshing”。您调用的方法也有问题。ScoreViewController正在调用readScoreFromDatabase方法。确保该函数存在。日志显示,readScoreFromDatabase方法不存在,您可以使用相同的拼写在self中重新检查您的方法,并且在方法声明中没有参数变量。