Unable to see iOS7 dynamic submission (work with iOS6)

I have my own TableViewCell. In a cell, I add two cross icons (using Unicode) to both sides of the cell. when the user clicks on the cell, he will display the cross member icon on the side.

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // add a cross _crossLabel = [self createCueLabel]; _crossLabel.text = @"\u274C"; _crossLabel.textAlignment = NSTextAlignmentLeft; // none of the following code works [self insertSubview:_crossLabel aboveSubview:self]; [self insertSubview:_crossLabel belowSubview:self]; [self addSubview:_crossLabel]; _crossLabel2 = [self createCueLabel]; _crossLabel2.text = @"\u274C"; _crossLabel2.textAlignment = NSTextAlignmentLeft; [self addSubview:_crossLabel2]; // add a pan recognizer UIGestureRecognizer* recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; recognizer.delegate = self; [self addGestureRecognizer:recognizer]; } return self; } 

For this, I used the code above. And _crossLabel was added to the Custom TableView Cell.

I used the Reveal App to check the layout of the iOS application enter image description here I see that _crossLabel is added to my cell. But I do not see the cross icon in my iOS 7 simulator. I tried different methods to add a subView, but none of them work.

enter image description here

But it works great on iOS6, and the layout is exactly the same as iOS 7 when I test the Reveal app.

Thanks for your help.

+4
source share
2 answers

Make sure you add cellView to the content, [self.contentView addSubView:_crossLabel2]; , not to the cell itself. You will see when using Reveal and checking iOS7 that in UITableViewCell UIKit has added / placed to UITableViewCellSCrollView above the cell view, so be careful with your insertSubview:belowSubview . Also, from your OutlineView of Reveal screenshot, the โ€œLocationCellโ€ view is grayed out, which means it is hidden.

Edit for reference only:
In iOS 7, the new UITableViewCellScrollView has its own set of clipToBounds properties. It's a hack, but if you [self.contentView.superview setClipsToBounds: NO]. The supervisor is the UITableViewCellScrollView on iOS7 and the cell itself on iOS6

+11
source

No need to add content content. You can simply access subview in iOS7 using

 [[cell.subviews lastObject] subviews] 
-one
source

Source: https://habr.com/ru/post/1502330/


All Articles