I am having a problem with my UITableViewCell\'s appearance on the iPad. This problem arose sometime between iOS 7 and now, but I don\'t know for sure when it started. On an iPo
Use the width same as that of [UIApplication sharedApplication].keyWindow.frame.size.width
rather than hardcoding the values.
This is due to Apples new readable content margins in iOS9 intended to make content more readable in wider views (iPad Pro).
You can turn this feature off by setting
tableView.cellLayoutMarginsFollowReadableWidth = false
in viewDidLoad
Try this code:
protected void Draw()
{
Accessory = UITableViewCellAccessory.DisclosureIndicator;
Layer.BorderColor = UIColor.Green.CGColor;
Layer.BorderWidth = 1f;
Frame = new CGRect(0, 0, [UIApplication sharedApplication].keywindow.frame.size.width, 42);
ContentMode = UIViewContentMode.ScaleToFill;
AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
ContentView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
ContentView.MultipleTouchEnabled = true;
ContentView.ContentMode = UIViewContentMode.Center;
ContentView.ClipsToBounds = true;
ContentView.Layer.BorderColor = UIColor.Brown.CGColor;
ContentView.Layer.BorderWidth = 1f;
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
//!! - Hack for ipad layout issue with disclosure indicator
if (Accessory == UITableViewCellAccessory.DisclosureIndicator && UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
{
ContentView.Frame = new CGRect(0, 0, [UIApplication sharedApplication].keywindow.frame.size.width - 32, ContentView.Frame.Size.Height);
foreach (var view in Subviews.OfType<UIButton>())
{
view.Frame = new CGRect([UIApplication sharedApplication].keywindow.frame.size.width - 24, view.Frame.Y, 8, view.Frame.Height);
}
}
}