Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use this for more <strong>advanced use:</strong></p> <ol> <li>finds custom accesoryView (cell.accesoryView)</li> <li>if empty, find generated accesoryView (UIButton) if cell has</li> <li>if the UIButton doesn't exists, find cell contet view (UITableViewCellContentView)</li> <li>if the cell contet view doesn't exists, use cell view</li> </ol> <p>Can be use for <strong>UIActionSheet</strong> or <strong>UIPopoverController</strong>.</p> <p><strong>Here is my code:</strong></p> <pre><code>UIView *accessoryView = cell.accessoryView; // finds custom accesoryView (cell.accesoryView) if (accessoryView == nil) { UIView *cellContentView = nil; for (UIView *accView in [cell subviews]) { if ([accView isKindOfClass:[UIButton class]]) { accessoryView = accView; // find generated accesoryView (UIButton) break; } else if ([accView isKindOfClass:NSClassFromString(@"UITableViewCellContentView")]) { // find generated UITableViewCellContentView cellContentView = accView; } } // if the UIButton doesn't exists, find cell contet view (UITableViewCellContentView) if (accessoryView == nil) { accessoryView = cellContentView; } // if the cell contet view doesn't exists, use cell view if (accessoryView == nil) { accessoryView = cell; } } [actionSheet showFromRect:**accessoryView.bounds** inView:**accessoryView** animated:YES]; </code></pre> <p>Tested in iOS 4.3 to 5.1</p> <p><strong>Best to use as custom method:</strong></p> <pre><code>-(UIView*)getViewForSheetAndPopUp:(UITableViewCell*)cell; </code></pre> <p>And method code:</p> <pre><code>-(UIView*)getViewForSheetAndPopUp:(UITableViewCell*)cell { UIView *accessoryView = cell.accessoryView; if (accessoryView == nil) { UIView *cellContentView = nil; for (UIView *accView in [cell subviews]) { if ([accView isKindOfClass:[UIButton class]]) { accessoryView = accView; break; } else if ([accView isKindOfClass:NSClassFromString(@"UITableViewCellContentView")]) { cellContentView = accView; } } if (accessoryView == nil) { accessoryView = cellContentView; } if (accessoryView == nil) { accessoryView = cell; } } return accessoryView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload