我有成绩屏幕( Storyboard)。它首先包含 UIView
,然后包含 UITableView
。当 UITableView
隐藏时 [self.headerView setHidden : YES]
那么 UITableView
应该出现。我该如何解决这个问题。
这是我的代码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
if(_presentingScoresDetailList.count == 0){
// Display a message when the table is empty
UILabel *messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
messageLabel.text = @"No grade found in this assignment";
messageLabel.textColor = [UIColor blackColor];
messageLabel.numberOfLines = 0;
messageLabel.textAlignment = NSTextAlignmentCenter;
messageLabel.font = [UIFont fontWithName:@"Palatino-Italic" size:20];
[messageLabel sizeToFit];
self.gradeDetailTableView.backgroundView = messageLabel;
self.gradeDetailTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}else{
[[ScoreManager sharedGradeManager] getGradeDetail:_gradeSelectedRow.gradID WithCompletionHandler:^(NSError *error, NSArray *scoresDetail) {
if (!error) {
_presentingGradeDetailList = scoresDetail;
[self.gradeDetailTableView reloadData];
}
}];
}
if(_scoreSelectedRow.pointsPossible >0 ){
_pointsHeaderLabel.text = [NSString stringWithFormat:@"%ld/%ld pts", (long)_gradescoreSelectedRow.pointsTaken, (long)_gradeSelectedRow.pointsPossible];
_percentageHeaderLabel.text = [NSString stringWithFormat:@"%ld", _gradeSelectedRow.gradePercentage];
}else{
//you can use tools to hide/show a uiview
[self.headerView setHidden:YES];
_pointsHeaderLabel.text = @"--";
_percentageHeaderLabel.text = @"--";
_percentageSignLabel.text = @"";
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNotificationAlertButton) name:kNewNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hideNotificationAlertButton) name:kNoNotification object:nil];
if([AppSession sharedSession].currentServerNotification)
[self.notificationAlertButton setHidden:NO];
else
[self.notificationAlertButton setHidden:YES];
}
我的要求是当第一个UIView
隐藏时,UITableView
应该出现(调整窗口大小)。
由于我是 Android 开发人员并且我是 IOS 新手,所以我无法快速跟上
最佳答案
您应该看看 autoLayout
和 sizeClasses
,它们会自动为您调整大小。
既然你是初学者,我强烈建议你这个 post , 以及更广泛的整个网站 :]
关于ios - 隐藏 UIView 时屏幕自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30506361/