大家好我正在我的主要ViewController
某个UIView
自定义类中实现..所有都显示但只有KPHomeInfluenceUser
不可见..绝对是一个愚蠢的问题或者缺乏关注,但你可以解释为什么你没有看到它?我在做什么是实施UIView
自定义类的错误方法?如果我的方法有误,你可以描述正确的方法吗?我见过很多程序员用这种方式实现类....请原谅我的愚蠢问题
- (void)viewDidLoad {
[super viewDidLoad];
[self scrollView];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.calendar clearAllDataToHomeCalendarAndReloadData];
[self.calendar scrollHomeCalendarToCurrentDayAndMonth];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] init];
_scrollView.backgroundColor = [UIColor clearColor];
_scrollView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:self.scrollView];
[self.scrollView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES;
[self.scrollView.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor].active = YES;
[self.scrollView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES;
[self.scrollView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES;
[self calendar];
[self influenceUser];
[self homeBottom];
}
return _scrollView;
}
-(KPHomeCalendar *)calendar {
if (!_calendar) {
_calendar = [[KPHomeCalendar alloc] init];
_calendar.translatesAutoresizingMaskIntoConstraints = NO;
[self.scrollView addSubview:self.calendar];
[self.calendar.topAnchor constraintEqualToAnchor:self.baseUserPhoto.topAnchor constant:-5].active = YES;
[self.calendar.leftAnchor constraintEqualToAnchor:self.baseUserPhoto.rightAnchor constant:10].active = YES;
[self.calendar.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:-10].active = YES;
[self.calendar.heightAnchor constraintEqualToConstant:85].active = YES;
}
return _calendar;
}
-(KPHomeInfluenceUser *)influenceUser {
KPHomeInfluenceUser *influence = [[KPHomeInfluenceUser alloc] init];
influence.translatesAutoresizingMaskIntoConstraints = NO;
[self.scrollView addSubview:influence];
[influence.topAnchor constraintEqualToAnchor:self.calendar.bottomAnchor constant:0].active = YES;
[influence.leftAnchor constraintEqualToAnchor:self.scrollView.leftAnchor constant:10].active = YES;
[influence.rightAnchor constraintEqualToAnchor:self.scrollView.rightAnchor constant:-10].active = YES;
[influence.heightAnchor constraintEqualToConstant:100].active = YES;
return influence;
}