Tuesday, 14 July 2015

iOS 8.3 crashes when installing nil constraints on "toItem" views (AUTOLAYOUT)

A multiplier of 0 or a nil second item together with a location for the first attribute creates 
an illegal constraint of a location equal to a constant. Location attributes must be specified in 
pairs.
                                       
OR
[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: 
A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant. Location attributes must be specified in pairs'



While working with iOS 8.3, I found a independent bug which is generate when you are going to user Auto layout manually.  If you construct layout constraints manually. e.g.

  
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.view1
attribute:NSLayoutAttributeRight
relatedBy:NSLayoutRelationEqual
toItem:self.view2
attribute:NSLayoutAttributeLeft
multiplier:1 
constant:0];
Under iOS 8.3, if you also link against the 8.3 SDK, NSLayoutConstraint has gotten a little pickier. If you accidentally pass in nil for the second view, and that contradicts the the attribute being specified, you’ll now get an exception. Previous OS releases appear to have quietly ignored this transgression on your code’s part.



Tuesday, 25 November 2014

Removing viewcontrollers from navigation stack

Removing viewcontrollers from navigation stack :

Use this code and enjoy:

NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self.navigationController.viewControllers];

// [navigationArray removeAllObjects];    // This is just for remove all view controller from navigation stack.

[navigationArray removeObjectAtIndex: 2];  // You can pass your index here
self.navigationController.viewControllers = navigationArray;

Friday, 12 September 2014