简体   繁体   中英

Screen auto resize when UIView is hidden

I have grade screen (storyboard). It contain UIView first & then UITableView . When UITableView is hidden [self.headerView setHidden : YES] then UITableView should come up. How can i sort out this.

This is my code

     - (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];
}

MY Requirement is when first UIView is hidden, UITableView should come up (resize windows).

Since I am android dev & I am new to IOS , I couldn't catch up quickly

You should have a look at autoLayout and sizeClasses , which will do the resize automatically for you.

Since you're a beginner, I highly suggest you this post , and more widely the entire site :]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM