Note that there are some explanatory texts on larger screens.

plurals
  1. POSupporting both AutoLayout and traditional layout
    primarykey
    data
    text
    <p>I have a custom subclass of UIButton that I want to re-use in multiple projects, some of which use interface builder and storyboards, and some of which may not. It involves setting the button's frame in several places.</p> <p>If I add</p> <pre><code> self.translatesAutoresizingMaskIntoConstraints = YES; </code></pre> <p>in the initialization, everything looks and works right, however, I get:</p> <pre><code>Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) Will attempt to recover by breaking constraint…etc </code></pre> <p>logged to the console. However, if I set</p> <pre><code> self.translatesAutoresizingMaskIntoConstraints = NO; </code></pre> <p>none of the button sizing works and the button is completely broken.</p> <p><strong>Is there a way I can suppress the error since it seems to degrade to the right thing or can I somehow manually remove the offending constraint?</strong></p> <p>I've tried dumping the constrains after the button is initialized, however, it does not seem to contain the constraint AutoLayout ends up breaking.</p> <p>Edited: Below are links to a sample project and then my button code. It works great when auto layout is turned off in the storyboard, however, when auto layout is turned on, the buttons seem to position at the origin (seems to be because when initWithCoder is called, the buttons don't have superviews or any position information).</p> <p><a href="http://www.kudit.com/dump/KFB.zip" rel="nofollow">http://www.kudit.com/dump/KFB.zip</a></p> <p><a href="http://www.kudit.com/dump/KuditConfirmButton.zip" rel="nofollow">http://www.kudit.com/dump/KuditConfirmButton.zip</a></p>
    singulars
    1. This table or related slice is empty.
    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.
 

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