自从sdk升级到ios7之后,问题不断,最近又发现一个问题,
在点击cell删除的时候,删除按钮被前面的view所覆盖,就去google了一下,在stackoverflow上找到了相应的解答,
就是自定义一个uitableviewcell的子类,然后重写layoutSubviews方法,其它的什么也不用动
方法如下:
第一种解决办法:
02
- (
void
)willTransitionToState:(UITableViewCellStateMask)state {
03
[super willTransitionToState:state];
04
[self sendSubviewToBack:self.backgroundView];
05
dispatch_async(dispatch_get_main_queue(), ^{
06
[self sendSubviewToBack:self.backgroundView];
10
- (
void
)didTransitionToState:(UITableViewCellStateMask)state {
11
[super didTransitionToState:state];
12
[self sendSubviewToBack:self.backgroundView];
第二种解决办法:
03
[super layoutSubviews];
05
for
(UIView *subview in self.subviews) {
07
for
(UIView *subview2 in subview.subviews) {
09
if
([NSStringFromClass([subview2
class
]) isEqualToString:@
"UITableViewCellDeleteConfirmationView"
]) {
11
[subview bringSubviewToFront:subview2];
第三种解决办法(个人感觉比较简洁 ):
3
[super layoutSubviews];
6
[self sendSubviewToBack:self.contentView];
第四 种解决办法:
1
- (
void
) layoutSubviews {
2
[super layoutSubviews];
4
if
([ [ [UIDevice currentDevice] systemVersion] compare: @
"7.0"
options: NSNumericSearch] != NSOrderedAscending) {
6
self.backgroundView.frame = CGRectMake(0, self.backgroundView.frame.origin.y,
7
self.backgroundView.frame.size.width, self.backgroundView.frame.size.height);