Saturday, November 7, 2026
HomeiOS Developmentios - UIButton just isn't displaying under the TableView

ios – UIButton just isn’t displaying under the TableView

[ad_1]

I’ve a view-controller, to which I add a tableView, and a “Accomplished” Button.

I’m ready so as to add the tableview to my view controller efficiently, however my “Accomplished” button doesn’t show.

The tableview is meant to show on the prime of the view, and the accomplished button is meant to show on the backside, beneath the tableview.

Solely the tableview shows and it takes up the entire display.

Are you able to please advise what the difficulty is? Is there one thing incorrect with my constraints?

Thanks!

@interface MyView : UIViewController<UITableViewDelegate, UITableViewDataSource>

@finish

@interface MyView ()

@property (nonatomic, sturdy) UITableView *tableView;
@property (nonatomic, sturdy) UIButton *doneButton;

@finish

@implementation MyView

- (void)viewDidLoad {
    [super viewDidLoad];
    _tableView = [[UITableView alloc] initWithFrame:CGRectZero];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    self.view.backgroundColor = [UIColor yellowColor];
    [_tableView registerClass:UITableViewCell.class forCellReuseIdentifier:@"cell"];
    [self.view addSubview:_tableView];
    [_tableView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [NSLayoutConstraint activateConstraints:@[
        [_tableView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor constant:10],
        [_tableView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor constant:-10],
        [_tableView.topAnchor constraintEqualToAnchor:self.view.topAnchor constant:20],
        [_tableView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
    ]];
    self.view.largeContentTitle = @"Title";
    self.title = @"Title";
    _doneButton = [UIButton buttonWithType:UIButtonTypeSystem];
    _doneButton.backgroundColor = [UIColor blueColor];
    [self.view addSubview:_doneButton];
    [_doneButton setTranslatesAutoresizingMaskIntoConstraints:NO];
    [NSLayoutConstraint activateConstraints:@[
        [_doneButton.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
        [_doneButton.trailingAnchor constraintEqualToAnchor:_tableView.trailingAnchor],
        [_doneButton.topAnchor constraintEqualToAnchor:_tableView.bottomAnchor],
        [_doneButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
    ]];

    //[_tableView.bottomAnchor constraintEqualToAnchor:_doneButton.topAnchor].lively = YES;
    // Do any further setup after loading the view.
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments