Clancey / FlyoutNavigation

Other
95 stars 87 forks source link

View constraint issues #23

Open ghost opened 11 years ago

ghost commented 11 years ago

First of all, thanks for a great component!

Unfortunately in complex layouts I am running into issues with view constraints. In my ViewControllers, I often use a Style Sheet of sorts to set my views correctly since I often add and remove views programmatically. Though everything works with the FlyoutNavigation Menu correctly, I get weird errors when I rotate. This is very likely due to the way that I create the views using the style sheet.

Here is the Error:


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) ( "NSAutoresizingMaskLayoutConstraint:0x100ec920 h=-&- v=&&- UITableView:0xe95c600.width == UIView:0xc2b0d80.width - 1222", "NSAutoresizingMaskLayoutConstraint:0x100f53c0 h=-&- v=-&- UIView:0xc2b0d80.width == UIView:0xc2aa780.width + 448", "NSAutoresizingMaskLayoutConstraint:0x1003cfb0 h=-&- v=-&- UIView:0xc2aa780.width == UIWindow:0xc29aeb0.width", "NSAutoresizingMaskLayoutConstraint:0xc028970 h=--- v=--- H:[UIWindow:0xc29aeb0(768)]" ) Will attempt to recover by breaking constraint NSAutoresizingMaskLayoutConstraint:0x100ec920 h=-&- v=&&- UITableView:0xe95c600.width == UIView:0xc2b0d80.width - 1222


The constraint that actually throws the error is actually a FlyoutNavigation.NavigationTableView-Width Constraint. The debugger fixes it correctly so everything works, but it is clearly still an issue.

Other Details: --Only happens on iPad. --My "Style Sheet" is based on the UIScreen.MainScreen, See below:

    public StyleSheet ()
    {
    }

    public static RectangleF GetViewFrame()
    {
        RectangleF frame = UIScreen.MainScreen.Bounds;
        if (IsLandscape) {
            float tempHeight = frame.Height; 
            frame.Height = frame.Width;
            frame.Width = tempHeight;
        }
        frame.Height = frame.Height - statusBarHeight;
        return frame;
    }

Thanks for any help you can provide.