NSLayoutConstraints and ShinobiControls


#1

Hi,

we would like to know whether shinobi controls are compatible with NSLayoutConstraints ?

for example, with code like this :

[self.view addConstraint:
    [NSLayoutConstraint
        constraintWithItem: self.view
        attribute: NSLayoutAttributeCenterX
        relatedBy: NSLayoutRelationEqual
        toItem: myShinobiGrid
        attribute: NSLayoutAttributeCenterX
        multiplier: 1.0f
        constant: 0.0f]];

Currently, it doesn't work since we can create a ShinobiGrid without providing a frame to its init method. Any idea ?

#2

I’ve made it work by initializing with a zero-rect.

[[ShinobiChartalloc] initWithFrame:CGRectZero];

 But note that ShinobiChart has some serious issues with alignment in the layout of graph, axises and tooltip when using non-fixed frame sizes.


#3
duemunk
I've made it work by initializing with a zero-rect.

[[ShinobiChartalloc]
initWithFrame:CGRectZero];
 But note that ShinobiChart has some serious issues with alignment in the layout of graph, axises and tooltip when using non-fixed frame sizes.

Hi Duemunk,

thanks for your reply.

Unfortunately, when I try your proposal, my app shutdowns abruptly saying :“SGrid must have a non-empty frame assigned to produce a grid.”

Am I missing something ?

As far as your last sentence is concerned :“ShinobiChart has some serious issues with alignment in the layout of graph, axises and tooltip when using non-fixed frame sizes.”, it does mean that, according to your own experience, we should avoid using NSLayoutConstraints with Shinobi[Chart | Grid], right ?


#4
Unfortunately, when I try your proposal, my app shutdowns abruptly saying :"SGrid must have a non-empty frame assigned to produce a grid."
Am I missing something ?

It is important that all parent views to your ShinobiChart has a frame set as well. NSLayoutConstraints seems to do its work when laying out views, and _not_ when they are actually added as a subview. So make sure that your all views in the entire view hierarchy has a frame set (at least CGRectZero). 

I don’t know what your NSLayoutConstraints skills are, but always remember .translatesAutoresizingMaskIntoConstraints = NO;

As far as your last sentence is concerned :"ShinobiChart has some serious issues with alignment in the layout of graph, axises and tooltip when using non-fixed frame sizes.", it does mean that, according to your own experience, we should avoid using NSLayoutConstraints with Shinobi[Chart | Grid], right ?

Unfortunatly, yes! I have reported this issue to Shinobi and please do it yourself if you experience this as well. You’ll notice it when tooltips aren’t aligning with graphs, and graphs aren’t aligning with axises.

I have this issue, not only for NSLayoutConstraints, but also when animating the frame with UIViewAnimations. So static is (unfortunately) the only way to go.