- (voID)loadVIEw { self.vIEw = [UIVIEw new]; self.vIEw.translatesautoresizingMaskIntoConstraints = NO; self.navigationItem.Title = @"Landing Page"; UIbutton *buildExercisesbutton = [UIbutton buttonWithType:UIbuttonTypeRoundedRect]; self.buildExercisesbutton = buildExercisesbutton;// buildExercisesbutton.frame = CGRectMake(20,312,164,44); self.buildExercisesbutton.translatesautoresizingMaskIntoConstraints = NO; [self.buildExercisesbutton setTitle:@"Build Exercises" forState:UIControlStatenormal]; [self.buildExercisesbutton addTarget:self action:@selector(buildExercisesbuttonpressed) forControlEvents:UIControlEventtouchUpInsIDe]; [self.vIEw addSubvIEw:self.buildExercisesbutton]; UIbutton *organiseExercisesbutton = [UIbutton buttonWithType:UIbuttonTypeRoundedRect]; self.organiseExercisesbutton = organiseExercisesbutton;// organiseExercisesbutton.frame = CGRectMake(192,44); self.organiseExercisesbutton.translatesautoresizingMaskIntoConstraints = NO; [self.organiseExercisesbutton setTitle:@"Organise Exercises" forState:UIControlStatenormal]; [self.organiseExercisesbutton addTarget:self action:@selector(organiseExercisesbuttonpressed) forControlEvents:UIControlEventtouchUpInsIDe]; [self.vIEw addSubvIEw:self.organiseExercisesbutton]; NSDictionary *variables = NSDictionaryOfVariableBindings(buildExercisesbutton,organiseExercisesbutton); NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-[buildExercisesbutton(organiseExercisesbutton)]-[organiseExercisesbutton]-|" options:NSLayoutFormatAlignAlltop | NSLayoutFormatAlignAllBottom metrics:nil vIEws:variables]; [self.vIEw addConstraints:constraints]; constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[buildExercisesbutton]-|" options:0 metrics:nil vIEws:variables]; [self.vIEw addConstraints:constraints];}
在vIEwDIDAppear中,我打印出按钮的帧.他们给出了奇怪的价值,我不知道它是否相关.实际上,按钮在屏幕中央彼此并排显示.
buildExercisesbutton: {{20,-63},{164,44}}organiseExercisesbutton: {{192,44}}解决方法 您需要为要添加按钮的视图定义约束,或将translatesautoresizingMaskIntoConstraints属性设置为YES. 总结
以上是内存溢出为你收集整理的ios – UIButton在使用自动布局时停止工作全部内容,希望文章能够帮你解决ios – UIButton在使用自动布局时停止工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)