最近修改支付sdk有个需求,超过四张卡会显示滚动条的提示,并且一直存在,发现系统属性总是滑动的时候自己才出现,算距离又很费劲,
创建scrollView的一个Category
#define noDisableVerticalScrollTag 20000
#define noDisableHorizontalScrollTag 20001
h文件为
@interface UIImageView (ForScrollView)
@end
m文件为
#import "UIImageView+ForScrollView.h"
@implementation UIImageView (ForScrollView)
- (void) setAlpha:(CGFloat)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) {
NSLog(@"%@",NSStringFromCGRect(self.frame));
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];
}
当前使用的控制器里面
1. 在 viewDidLoad 内:
self.mTableView.tag = noDisableVerticalScrollTag;
2,要在
self.mTableView.tag 数据拿到并且界面刷新完毕以后展示出来
[_mTableView reloadData];
if (_fukaArray.count>4){
[self.mTableView flashScrollIndicators];
}
完美搞定!