uitableview - UITableViewRowAction is too wide in iOS 11 -
i use following trick in order have images in table view row actions:
how manage equal width uitableviewrowaction in ios8.0?(more,delete,etc actions)
uitableviewrowaction *completeaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@" " handler:^(uitableviewrowaction *action, nsindexpath *indexpath) { ... }]; completeaction.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"myimagehere"]];
but no longer works ios 11 - width of row action button big image it's repeated:
is there fix this?
i had same problem , able fix it. however, solution quite hacky , needs explanation:
we'll have implement own uitableview, modifies layout of it's subviews , subsubviews in layoutsubviews(). view contains action buttons uiswipeactionpullview , subview. type not available @ compile time (maybe knows how check type?), can check type uikit.uiview , check if view has same amount of subviews (uibutton) defined action buttons.
we want avoid our subview wider sum of widths of our action buttons. in case need fix size , position of our uiswipeactionpullview. furthermore need fix positioning of uibutton.
my code gives example 3 fixed width action buttons:
class customtableview: uitableview { public customtableview(cgrect frame, uitableviewstyle style) : base(frame, style) { } public override void layoutsubviews() { base.layoutsubviews(); var buttonsize = 54; foreach (var actionview in subviews) { if (actionview.gettype().fullname == "uikit.uiview" && actionview.subviews.length == 3) { if (actionview.frame.width >= buttonsize* 3) { actionview.frame = new cgrect(frame.width - 3 * buttonsize, actionview.frame.y, buttonsize* 3, buttonsize); int = 0; foreach (var button in actionview.subviews) { button.frame = new cgrect(i * buttonsize, 0, buttonsize, buttonsize); i++; } } } } } }
Comments
Post a Comment