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 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.
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.
source share