Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.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 UITableVIewController在滚动上显示文本_Ios_Uitableview_Pull To Refresh - Fatal编程技术网

Ios UITableVIewController在滚动上显示文本

Ios UITableVIewController在滚动上显示文本,ios,uitableview,pull-to-refresh,Ios,Uitableview,Pull To Refresh,我想在用户滚动tableview时显示它的一些文本(我猜是在标题部分)。有点像拉刷新,但只是一个消息。有人知道最好的方法吗?我只是想显示文本,所以我认为UIRefresh控件有点过时了。谢谢 以下是在表格视图标题中放置消息的代码: - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{ UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0,

我想在用户滚动tableview时显示它的一些文本(我猜是在标题部分)。有点像拉刷新,但只是一个消息。有人知道最好的方法吗?我只是想显示文本,所以我认为UIRefresh控件有点过时了。谢谢

以下是在
表格视图标题中放置消息的代码:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 20)];
    label.text = @"Hello, World!";
    label.textColor = [UIColor blackColor];
    self.tableView.tableHeaderView = label;
    [self.tableView setContentInset:UIEdgeInsetsMake(-label.bounds.size.height, 0.0f, 0.0f, 0.0f)];
} 

这不是一个常见的UI模式,可能意味着这是有原因的。必须检测表格的滚动,在表格滚动单元格的同时增加标题视图的大小。听起来像是编写复杂代码的诀窍。我会用我的消息创建一个视图。将其放置在tableview上方,使其高度为1px,可见性为隐藏。检测滚动,并将其可见性切换为可见,并设置动画,将视图的帧设置为需要的大小(从下到上)。如果合理的话,现在让我来举个例子。当然,如果消息可以被放置在适当的位置并隐藏,那么它将只是一个简单的检测滚动并将标签设置为可见。这就是您的意思吗?您所说的“当用户滚动时”是什么意思?您是否希望在标题
tableViewHeader
中显示消息,而不是
UIRefreshControl