title: How to position activity indicator to the center of its superview using Auto Layout programmatically?
body: <p>Why the following code does not work for positioning activity indicator to the center of its superview:</p>
  
  <pre><code>UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc]
         initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
  
  [self.mysuperview addSubview:activityIndicator];
  [activityIndicator addConstraints:[NSLayoutConstraint 
                     constraintsWithVisualFormat:@"|-(&gt;=20)-[view(==100)]-(&gt;=20)-|"
                     options:NSLayoutFormatAlignAllCenterX | NSLayoutFormatAlignAllCenterY
                     metrics:nil
                     views:@{@"view" : self.mysuperview}]];
  </code></pre>
  
  <p>Activity indicator is positioned somewhere at the top left corner, definitely not in the centre.</p>
  
  <p>==================
  Update:
  FOUND SOLUTION: I have to turn off autoresizing constraints after creating indicator and then all solutions that where given work:</p>
  
  <pre><code> [activityIndicator setTranslatesAutoresizingMaskIntoConstraints:NO];
  </code></pre>
  
  <p>I found it on the link given by @Vignesh, so I accept his/her answer.</p>