title: I have to add label and text field in one row programmatically with autolayout constraint but project crash
body: <p>here is my code. 
  I have to add label and text field in one row programmatically by adding  autolayout constraint  but project crash due to constraint not set properly
  plz help me to solve this error </p>
  
  <pre><code>-(void)autoLayoutProgrametacally
  {
  
  UIImageView *imgView = [[UIImageView alloc] init];
  imgView.contentMode = UIViewContentModeScaleAspectFit;
  imgView.translatesAutoresizingMaskIntoConstraints = NO;
  UIImage *image =[UIImage imageNamed:@"background.jpg"];
  [imgView setImage:image];
  [self.view addSubview:imgView];
  
  NSArray *imageViewHorConst = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[imgView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(imgView)];
  NSArray *imageViewVerConst = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[imgView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(imgView)];
  
  [self.view addConstraints:imageViewHorConst];
  [self.view addConstraints:imageViewVerConst];
  
  
  UILabel *FirstName = [[UILabel alloc] init];
  [FirstName setTranslatesAutoresizingMaskIntoConstraints:NO];
  [FirstName setNumberOfLines:1];
  [FirstName setText:@"First Name:"];
  [self.view addSubview:FirstName];
  UILabel *LastName = [[UILabel alloc] init];
  [LastName setTranslatesAutoresizingMaskIntoConstraints:NO];
  [LastName setNumberOfLines:1];
  [LastName setText:@"Last Name:"];
  [self.view addSubview:LastName];
  UITextField *txtFirstName=[[UITextField alloc]init];
  [txtFirstName setTranslatesAutoresizingMaskIntoConstraints:NO];
  UITextField *txtLastName=[[UITextField alloc]init];
  [txtLastName setTranslatesAutoresizingMaskIntoConstraints:NO];
  
  
  
  
  NSArray *FirstNameVerConst = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(10)-[FirstName]" options:NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllBottom metrics:nil views:NSDictionaryOfVariableBindings(FirstName)];
  NSArray *FirstNameHorConst = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(10)-[FirstName(txtFirstName)]-(10)-[txtFirstName]" options:NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllBottom metrics:nil views:@{@"FirstName":FirstName, @"txtFirstName":txtFirstName}];
  NSArray *LastNameVerConst = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-10-[LastName]" options:NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllBottom metrics:nil views:NSDictionaryOfVariableBindings(LastName)];
  NSArray *LastNameHorConst = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[LastName(txtLastName)]-(10)-[txtLastName]" options:NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllBottom metrics:nil views:@{@"LastName":LastName, @"txtLastName":txtLastName}];
  
  
  [self.view addConstraints:FirstNameVerConst];
  [self.view addConstraints:FirstNameHorConst];
  [self.view addConstraints:LastNameVerConst];
  [self.view addConstraints:LastNameHorConst];
  }
  </code></pre>