ios - 隐藏 UIView 时屏幕自动调整大小

标签 ios objective-c iphone uitableview uiview

我有成绩屏幕( 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 新手,所以我无法快速跟上

最佳答案

您应该看看 autoLayoutsizeClasses,它们会自动为您调整大小。

既然你是初学者,我强烈建议你这个 post , 以及更广泛的整个网站 :]

关于ios - 隐藏 UIView 时屏幕自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30506361/

相关文章:

iphone - 创建并加载用于 openGL 的 RGBA4444 RGBA5551 中的 .png

iOS 卡片滑动动画和 ScrollView

ios - url.isFileReferenceURL() 在 IOS 中为本地文件返回 false

iphone - ios amazon s3 上传视频文件

ios - 如何在用户登录后自动更新 ViewController

ios - IBAction 方法中调用的完成处理程序

iphone - 自动布局困惑 : Constraints for ScrollView with WebView and Header/Footer Views

ios - 在OpenGL场景背景中绘制纹理四边形

带有部分的 iOS tableView - 如何获取全局索引

objective-c - 如何在 objective-c 中释放 "delegate"内存?