1、建立继承UIImageView的Objective-C category类类名为:ForScrolllView
在UIImageView+ForScrollView类的.m中加入以下代码:
#define noDisableVerticalScrollTag 836913
#define noDisableHorizontalScrollTag 836914
@implementation UIImageView (ForScrollView)
- (void) setAlpha:(float)alpha {
if (self.superview.tag == noDisableVerticalScrollTag) {
if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin) {
if (self.frame.size.width < 10 && self.frame.size.height > self.frame.size.width) {
UIScrollView *sc = (UIScrollView*)self.superview;
if (sc.frame.size.height < sc.contentSize.height) {
return;
}
}
}
}
if (self.superview.tag == noDisableHorizontalScrollTag) {
if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleTopMargin) {
if (self.frame.size.height < 10 && self.frame.size.height < self.frame.size.width) {
UIScrollView *sc = (UIScrollView*)self.superview;
if (sc.frame.size.width < sc.contentSize.width) {
return;
}
}
}
}
[super setAlpha:alpha];
}
2、在初始化UITableView的ViewController中加入tag值:
//一直显示滚动条
_tableView.tag = 836913;//836914是UITableView滚动条的正常现象,即拉至头至尾即消失
3、在加载至完成时还可重新绑定数据
//重新绑定数据
[_tableView reloadData];
[_tableView flashScrollIndicators];
让UITableView的滚动条一直存在,布布扣,bubuko.com
原文:http://www.cnblogs.com/tanwen1989/p/3628958.html