Search code examples
iosuitableviewright-to-left

Access private class from UITableView/UITableViewCell


For some RTL purpose, I need to adjust the frame of some subviews like '_UITableViewCellSeparatorView' in UITableViewCell and 'UITableViewIndex' in UITableView.

Here is my code:

for (UIView *view in [self subviews]) {
            // separator view
            if ([view isKindOfClass:NSClassFromString(@"_UITableViewCellSeparatorView")]) {
                CGRect frame = view.frame;
                frame.origin.x = 0;
                view.frame = frame;
            }
        }

if ([self.superview isKindOfClass:[UITableView class]]) {
            UITableView* tableView = (UITableView*)self.superview;
            UIView* indexView = [[tableView subviews] lastObject];

            if ([indexView isKindOfClass:NSClassFromString(@"UITableViewIndex")]) {

                indexViewWidth = indexView.frame.size.width;
            }                
        }

I wonder whether these changes will be passed by Apple review team? I only know that we must not use or call private APIs. Thanks!


Solution

  • With the release of iOS 9 and full RTL support, workarounds like this should no longer be necessary.