我点击按钮时无法增加xib视图大小,

时间:2016-11-10 08:33:19

标签: objective-c xib

点击按钮我无法看到视图(xib,即VPProcessNewJobDataVC)的大小增加,我已经尝试过优先级,layoutIfNeeded等等。我已经在同一个VPProcessNewJobDataVC.m文件中写了按钮动作

此方法属于一个类:

-(void)menuItemQARequest: (id) sender {

  vpaController=[[VPProcessNewJobDataVC alloc] initWithNibName:@"VPProcessNewJobDataVC" bundle:[NSBundle mainBundle]];
  vpaController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
  vpaController.delegate=self;
  vpaController.modalPresentationStyle = UIModalPresentationFormSheet;
  //[vpaController.view setTranslatesAutoresizingMaskIntoConstraints:NO];
   vpaController.preferredContentSize=CGSizeMake(600, 400);

  NSLog(@"View frame is  %@", NSStringFromCGRect(vpaController.view.frame));
  [self.jobsSplitVC presentViewController:vpaController animated:YES completion:nil];
}

此方法在xib类中:

-(IBAction)okBtnAction:(id)sender {

    self.tableView.hidden=NO;
    CGRect theFrame = self.view.frame;
    [self.view setFrame:CGRectMake(2.0, 3.0, 800.0, 1000.0)];
    [self.view addSubview:self.tableView];
}

1 个答案:

答案 0 :(得分:0)

对于调整大小和重新布局视图,布局周期必须调用。 在调整框架大小后尝试调用[self layoutIfNeeded]