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

时间:2015-05-28 12:17:17

标签: ios objective-c iphone uitableview uiview

我有成绩屏幕(故事板)。它首先包含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];
}

我的要求是隐藏第一个UIViewUITableView应该出现(调整窗口大小)。

因为我是android dev&我是IOS的新手,我无法赶快赶上

1 个答案:

答案 0 :(得分:1)

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

由于您是初学者,我强烈建议您post,以及更广泛的整个网站:]