I have a Popup-View which contains two labels, a tableview and button. I created a ViewController as in Display UIViewController as Popup in iPhone described.
My special requirement is now, that the tableview is not necessary in all cases, so I tried to hide it and expected a reduced height of the Popup-View. But I always get the same height. I also tried to use a UIStackView, but the height of the view wasn't changed in case of hiding the tableview.
I also need to have the view in center of the display in both cases of height.
@interface AuthorizationMessageViewController ()
@property (weak, nonatomic) IBOutlet UIView *messageView;
@property (weak, nonatomic) IBOutlet UILabel *titelLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailsLabel;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UIButton *okButton;
- (IBAction)okButtonTouchUp:(id)sender;
@end
@implementation AuthorizationMessageViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.messageView.layer.cornerRadius = 5;
    self.messageView.layer.masksToBounds = YES;
    self.messageView.backgroundColor = COLOR_BACKGROUND_WHITE;
    self.messageView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    self.tableView.separatorColor = [UIColor clearColor];
    self.tableView.backgroundColor = COLOR_BACKGROUND_WHITE;
    self.titelLabel.text = WHLocalizedString(@"EventHeaderAuthorization", nil);
    [self setupView];
}
- (void)setupView
{
    NSString *ns_messageText;
    ns_messageText = @"test";
    if (YES)
    {
        ns_messageText = @"Hide"
        [self.tableView setHidden:YES];
    }
    else
    {
        ns_messageText = @"No Hide"
        [self.tableView setHidden:NO];
    }
    self.detailsLabel.text = ns_messageText;
    self.detailsLabel.textColor = COLOR_TEXT_GREY_KEY;
    self.detailsLabel.numberOfLines = 0;
    [self.detailsLabel sizeToFit];
}
#pragma mark - Table view data source
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 21;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"testCell"];
    UILabel *weekDayLabel = (UILabel *)[cell viewWithTag:10];
    weekDayLabel.text = @"weekday";
    weekDayLabel.textColor = COLOR_TEXT_GREY_KEY;
    weekDayLabel.font = FONT_LIGHT_SIZE_15;
    UILabel *testLabel = (UILabel *)[cell viewWithTag:11];
    testLabel = @"testLabel"
    testLabel = COLOR_TEXT_GREY_KEY;
    testLabel = FONT_LIGHT_SIZE_15;
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    return cell;
}
I hope that someone has a solution or an idea for that.
 
    
 
     
    