Re: 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: Expected a view
Re: 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: Expected a view
- Subject: Re: 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: Expected a view
- From: Donald Hall <email@hidden>
- Date: Mon, 30 Dec 2013 14:57:39 -0700
Doh! I woke up this morning and realized that I had reversed the order of toolbar and topLayoutGuide when trying to sort out the original exception caused by the extraneous space character, and hadn't put them back. Now it works! Thanks again.
Actually I had to change the space from 20px to 0px to get the effect I wanted - to fit snugly to the bottom of the status bar. In my xib file, since I don't have access to topLayoutGuide I put in a constraint of toolbar to superview of 0 and gave it a priority of 750. I add my constraint in viewDidLoad (for iOS 7 only). It overrides the one from the xib file as it has higher priority. Thus the screen looks right in both iOS 6 and iOS 7.
Don
------------
Don Hall
Apps & More Software Design, Inc.
http://www.appsandmore.com
email@hidden
On 2013-12-30, at 12:40 AM, Roland King <email@hidden> wrote:
> That code would put the toolbar above the top layout guide by 20px, is that what you want? I'd think you'd want to put it below the top layout guide else it'll go off the top of the screen in some cases.
>
> Take a look at the frame your toolbar ended up with and see where it's gone.
>
> On 30 Dec, 2013, at 2:50 pm, Donald Hall <email@hidden> wrote:
>
>> Roland,
>>
>> Thanks for the quick reply! Yes that was the problem. I just copied straight from Apple's example. I guess they got it wrong. :-(
>>
>> Unfortunately, this caused the toolbar to disappear on the iPad simulator. I'll have to try another approach to getting the toolbar to not underlap the status bar.
>>
>> Best, Don
>> ------------
>> Don Hall
>> Apps & More Software Design, Inc.
>> http://www.appsandmore.com
>> email@hidden
>>
>> On 2013-12-29, at 11:36 PM, Roland King <email@hidden> wrote:
>>
>>> Do you really have a space between V: and [toolbar]? I'd remove that.
>>>
>>>
>>>
>>> On 30 Dec, 2013, at 2:28 pm, Donald Hall <email@hidden> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I am trying to add a layout constraint to my container view programmatically by putting the following code in the view controller (which I got and modified from Apple's UIViewController docs):
>>>> -------------
>>>> [toolbar setTranslatesAutoresizingMaskIntoConstraints: NO];
>>>> id topGuide = self.topLayoutGuide;
>>>> NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings (toolbar, topGuide);
>>>> [self.view addConstraints:
>>>> [NSLayoutConstraint constraintsWithVisualFormat: @"V: [toolbar]-20-[topGuide]"
>>>> options: 0
>>>> metrics: nil
>>>> views: viewsDictionary]];
>>>> [self.view layoutSubviews]; // You must call this method here or the system raises an exception
>>>> -------------
>>>> "toolbar" is a UIToolBar at the top of the view.
>>>>
>>>> This doesn't work. I get the following:
>>>>
>>>> 'NSInvalidArgumentException', reason: 'Unable to parse constraint format:
>>>> Expected a view
>>>> V: [toolbar]-20-[topGuide]
>>>> ^'
>>>>
>>>> Does anyone have any ideas where I am going wrong? I tried using the view instead of topGuide, but got the same error message.
>>>>
>>>> I am trying to keep the tool bar from underlapping the status bar in iOS 7, while keeping iOS 6 compatibility. (Xcode 5.0.2, Base SDK iOS 7.0)
>>>>
>>>> Thanks, Don
>>>>
>>>> ------------
>>>> Don Hall
>>>> Apps & More Software Design, Inc.
>>>> http://www.appsandmore.com
>>>> email@hidden
>>>>
>>>>
>>>> _______________________________________________
>>>>
>>>> Cocoa-dev mailing list (email@hidden)
>>>>
>>>> Please do not post admin requests or moderator comments to the list.
>>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>>>
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>
>>>
>>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden