Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessory Disclosure indicator is not showing up in custom cell

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.

like image 640
vaibhav Avatar asked Oct 17 '14 12:10

vaibhav


4 Answers

I read this in a tutorial

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!

like image 65
cam_271 Avatar answered Oct 04 '22 05:10

cam_271


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
    }
}
like image 20
Enix Avatar answered Oct 04 '22 06:10

Enix


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.

like image 28
Nitin Nain Avatar answered Oct 04 '22 05:10

Nitin Nain


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
    }
like image 35
Oleksandr Sytnyk Avatar answered Oct 04 '22 05:10

Oleksandr Sytnyk