开发路上行人稀,常有大神较高低。如今开发xx载,还是当年小菜鸡!😆小菜鸡之前页面布局遵守的原则是能用storyboard就不用代码,因为最近项目用的是纯代码,走了不少坑,项目上线了把自己走过的坑记录一下。
先说点题外的,在动画处理方面,
+ (void)settingConfigStatus:(SHConfigurationStatus)configStatus {
switch(configStatus) {
case SHConfigurationStatusCancel: {
[self sharedView].animationImageView.hidden = NO;
[self sharedView].iconImageView.hidden = YES;
[self sharedView].animationImageView.animationDuration = 1.0;
//设置重复次数,0表示不重复
[self sharedView].animationImageView.animationRepeatCount = 0;
[[self sharedView].animationImageView setAnimationImages:[NSArray arrayWithObjects:
[UIImageimageNamed:@"smartV1.2_配置中1"],
[UIImageimageNamed:@"smartV1.2_配置中2"],
[UIImageimageNamed:@"smartV1.2_配置中3"],
[UIImageimageNamed:@"smartV1.2_配置中4"],
nil]];
[[self sharedView].animationImageView startAnimating];
[self sharedView].promptInfoLabel.text = @" "; // 空格防止label高度为0
[self sharedView].promptInfoLabel.textColor = [UIColor grayColor];
[[selfsharedView].operationButtonsetTitle:@"取消配置"forState:UIControlStateNormal];
}
break;
case SHConfigurationStatusSuccess: {
[self sharedView].animationImageView.hidden = YES;
[self sharedView].iconImageView.hidden = NO;
[[self sharedView].iconImageView setImage:[UIImage imageNamed:@"smartV1.2_配置成功"]];
[self sharedView].promptInfoLabel.text = @"配置成功";
[self sharedView].promptInfoLabel.textColor = [UIColor blackColor];
[[self sharedView].operationButton setTitle:[[self sharedView].leftButtonTitle isEqualToString:@"确定"] ? @"确定": @"继续" forState:UIControlStateNormal];
[self sharedView].leftButtonTitle = @"";
}
break;
case SHConfigurationStatusFailure: {
[self sharedView].animationImageView.hidden = YES;
[self sharedView].iconImageView.hidden = NO;
[[self sharedView].iconImageView setImage:[UIImage imageNamed:@"smartV1.2_连接超时"]];
[self sharedView].promptInfoLabel.text = @"配置失败,请重试";
[self sharedView].promptInfoLabel.textColor = [UIColor blackColor];
[[self sharedView].nextButton setTitle:[[self sharedView].leftButtonTitle isEqualToString:@"取消"] ? @"取消" : @"下一个" forState:UIControlStateNormal];
[[self sharedView].wifiConfigButton setTitle:@"wifi配置" forState:UIControlStateNormal];
[[self sharedView].operationButton setTitle:@"重试" forState:UIControlStateNormal];
[self sharedView].leftButtonTitle = @"";
}
break;
case SHConfigurationStatusComplete: {
[self sharedView].animationImageView.hidden = YES;
[self sharedView].iconImageView.hidden = NO;
[[self sharedView].iconImageView setImage:[UIImage imageNamed:@"smartV1.2_完成所有配置"]];
[self sharedView].promptInfoLabel.text = @"已经完成所有配置";
[self sharedView].promptInfoLabel.textColor = [UIColor blackColor];
[[selfsharedView].operationButtonsetTitle:@"立即体验"forState:UIControlStateNormal];
}
break;
default:
break;
}
}
一个UIImageView上,先调用setAnimationImages 之后再调用 setImage的话图片显示会乱、之前也碰到过在一个UIImageView上调用setAnimationImages两次也是不行的、因为这个原因只能笨笨的在同一个位置上放上两个imageView,这个问题某位大神指点下,不胜感激。
书归正传,使用Masonry布局,setNeedsUpdateConstraints这个方法是要在初始化视图的时候调用的,不然布局方法是不会走的,然后页面上空空的,然后你会就会有点小失落。
relayout
在配置失败的时候有时是两个按钮操作,有时又有三个按钮,在对一个控件调整布局的时候刚开始用mas_makeConstraints老是出错,最后了解到应该用mas_remakeConstraints这个方法。
github上的demo代码 RelayoutView
网友评论