【问题标题】:Screen auto resize when UIView is hidden隐藏 UIView 时屏幕自动调整大小
【发布时间】:2015-08-10 22:47:29
【问题描述】:

我有成绩屏幕(故事板)。它首先包含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 dev 并且我是 IOS 新手,所以我无法快速赶上

【问题讨论】:

    标签: ios objective-c iphone uitableview uiview


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-16
      • 2013-07-16
      • 1970-01-01
      • 2013-07-11
      • 2013-11-25
      • 1970-01-01
      • 2018-03-03
      相关资源
      最近更新 更多