Shr*_*dha 6 objective-c uitableview uiscrollview ios swift
我在我的应用程序中使用了几个UITableView.其中一些包含几行,而一些只有两个.我需要的是:如果表包含多行,那么在用户甚至拖动表格之前,滚动条应该是可见的.或者换句话说,是否可以使滚动条始终可见?
Kum*_* KL 13
您可以闪烁它们,但没有选项让它们始终可见:
[ScrollView flashScrollIndicators];
Run Code Online (Sandbox Code Playgroud)
UITableView是UIScrollView的子类,因此您可以直接使用它
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.tableView performSelector:@selector(flashScrollIndicators) withObject:nil afterDelay:0];
}
Run Code Online (Sandbox Code Playgroud)
查看更多信息: UIScrollView - 显示滚动条
迅速:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.tableView.flashScrollIndicators()
}
Run Code Online (Sandbox Code Playgroud)
小智 10
Swift 3.0
1)计时器
var timerForShowScrollIndicator: Timer?
Run Code Online (Sandbox Code Playgroud)
2)方法
/// Show always scroll indicator in table view
func showScrollIndicatorsInContacts() {
UIView.animate(withDuration: 0.001) {
self.tableView.flashScrollIndicators()
}
}
/// Start timer for always show scroll indicator in table view
func startTimerForShowScrollIndicator() {
self.timerForShowScrollIndicator = Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(self.showScrollIndicatorsInContacts), userInfo: nil, repeats: true)
}
/// Stop timer for always show scroll indicator in table view
func stopTimerForShowScrollIndicator() {
self.timerForShowScrollIndicator?.invalidate()
self.timerForShowScrollIndicator = nil
}
Run Code Online (Sandbox Code Playgroud)
3)使用
startTimerForShowScrollIndicator在viewDidAppear
stopTimerForShowScrollIndicator在viewDidDisappear
| 归档时间: |
|
| 查看次数: |
8687 次 |
| 最近记录: |