【发布时间】:2015-03-14 22:13:46
【问题描述】:
叠花!
我再次来到蜂巢之心寻求帮助。这次是一个非常特殊的问题,不幸的是,我无法理解它。
该问题与使用 UIRefreshControl 的下拉刷新机制有关。当它由 - 下拉启动时,下拉本身可以正常工作。当我想手动触发加载时,它也可以正常工作,但有一个阻塞问题 - 活动指示器的颜色不会更改为它设置的色调。
-viewDidLoad
_publicationsRefreshControl = [[UIRefreshControl alloc] init];
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:NSLocalizedString(localizationRefreshControlTitle, nil) attributes:@{NSFontAttributeName : [UIFont fontWithName:fontLatoRegular size:14], NSForegroundColorAttributeName : [UIColor whiteColor]}];
_publicationsRefreshControl.attributedTitle = attributedTitle;
_publicationsRefreshControl.tintColor = [UIColor whiteColor];
[_publicationsRefreshControl addTarget:self action:@selector(refreshPublications:) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:_publicationsRefreshControl];
这会正确初始化 UIRefreshControl,并且当您下拉 CollectionView 时它确实可以工作。
当我使用以下方法时:
- (void)action {
[_publicationsRefreshControl beginRefreshing];
[_collectionView setContentOffset:CGPointMake(0, _collectionView.contentOffset.y - _publicationsRefreshControl.frame.size.height) animated:YES];
[_publicationsRefreshControl sendActionsForControlEvents:UIControlEventValueChanged]; }
要手动开始刷新,活动指示器的颜色不会变为白色。它保持默认颜色。我尝试在所有可能的放置组合中设置 action 方法中的 tintColor 属性,但无济于事。
有趣的是,如果我拉下集合视图并先开始刷新,然后尝试手动开始刷新,它将正确地着色为白色。仅当我尝试先手动刷新时才会出现颜色问题。
我尝试过的其他选项:
- 尝试调用 tintColorDidChange
- 试图手动更改底层ActivityIndicatorView的Style
感谢任何人愿意提供的任何帮助:)
【问题讨论】:
-
你成功了吗?
-
恐怕我没有。我只是在手动刷新时不显示刷新控件。
标签: objective-c uirefreshcontrol tintcolor