I am creating a table view with a custom cell. I have used xib files for creating both. My table is performing as i wanted it to,but just one problem the cells of table View are not showing disclosure indicator.
The indicator is showing in xib file after setting it from attribute inspector but not in simulator.
I have added it programmatically also
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
InboxTableViewCell * cell = (InboxTableViewCell *)[tableView dequeueReusableCellWithIdentifier:[InboxTableViewCell reuseIdentifier]];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:customCellName owner:self options:nil];
cell = _tblVIewInboxCell;
_tblVIewInboxCell = nil;
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.lblTitleInbox.text = @"Title";
cell.lblSubTitleInbox.font = [UIFont fontWithName:@"Verdana" size:16.0];
cell.lblSubTitleInbox.text = @"SubTitle";
cell.lblSubTitleInbox.font = [UIFont fontWithName:@"Verdana" size:12.0];
return cell;
}
So can anybody please help me.
Thanks in advance.
I found this just now in a tutorial I was looking at. I found it here: http://www.codingexplorer.com/segue-uitableviewcell-taps-swift/
Or temporarily make the table view narrower just to see if they are there.
Hope this helps!
I have the same problem, but I finally figured out that I have implemented the layoutSubviews
methods, but forget to call the super.layoutSubviews
in the subclass. If you add it back, then you can see the disclosure.
So the solution will be like this
class WQPlaneCell: UITableViewCell {
@IBOutlet private weak var thumbnailImage: UIImageView!
@IBOutlet private weak var planeNoLabel: UILabel!
@IBOutlet private weak var planeTypeLabel: UILabel!
@IBOutlet private weak var ownerLabel: UILabel!
override func layoutSubviews() {
super.layoutSubviews() // This is important, don't forget to call the super.layoutSubviews
.... // do anything you want
}
}
I had a similar problem; I had added all the constraints for the elements (labels, images) inside the cell to the cell boundaries, it still didn't show the right most elements and disclosure indicator.
Turns out you also have to ADD CONSTRAINTS FOR THE PARENT TABLE VIEW TO ITS SUPERVIEW. Interface storyboard/Auto Layout doesn't issue any warnings for this.
This is only the case with custom TableView
. TableViewController
's have this sorted out already, so it's easy to miss out if you're moving from the latter to the former.
I set the accessory indicator for table view in the Interface Builder and had the same issue. I could fix this by setting it programmatically in tableView(cellForRowAt:). Moreover, this way you could set accessory indicator only for some of your table view cells, like this:
if indexPath.row != 3 {
cell.accessoryType = .disclosureIndicator
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With