Access iOS 7 hidden UITableViewCellScrollView?

匿名 (未验证) 提交于 2019-12-03 02:50:02

问题:

Apple change the UITableViewCell hierarchy in iOS 7

Using iOS 6.1 SDK

<UITableViewCell>    | <UITableViewCellContentView>    |    | <UILabel> 

Using iOS 7 SDK

<UITableViewCell>    | <UITableViewCellScrollView>    |    | <UITableViewCellContentView>    |    |    | <UILabel> 

My problem is that the UITableViewCellScrollView.layer.masksToBounds = TRUE by default and i need it to be false.

I tried the following:

UIView * scrollView = [self.subviews objectAtIndex:0]; scrollView.layer.masksToBounds = NO; 

and

[self.myLabel.superview.layer setMasksToBounds:NO]; 

But non of them changes the UITableViewCellScrollView. How can i access this scrollview?

回答1:

The only way to access the new CellScrollView is by accessing the cell superview after it was created.

I added the following cellForRowAtIndexPath:

cell = [[UICustomTableViewCell alloc] init]; UIView *cellScrollView = cell.myLabel.superview; [cellScrollView.layer setMasksToBounds: NO]; 

I think Apple should give us a way to access this new ScrollView without hacking.



回答2:

Objective-C:

UIView *cellScrollView = [[cell contentView] superview]; [cellScrollView setClipsToBounds:NO]; 

Swift:

let cellScrollView = cell.contentView.superview cellScrollView?.clipsToBounds = false 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!