Kiran
Kiran

Reputation: 1289

Programmatically created grouped table view

I have created a grouped table view & I had a edit button in the title bar & I can able to navigate to other page on click of every row after pressing edit button

now by using following code I have designed the grouped table view programmatically but now edit button is not working on click of a row (after pressing edit) it's not navigating how can I fix this?

- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationItem.rightBarButtonItem = self.editButtonItem;

    tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 415)style:UITableViewStyleGrouped];
    tableView.dataSource = self;

    [self.view addSubview:tableView];
}

Upvotes: 0

Views: 124

Answers (3)

Andrew Ebling
Andrew Ebling

Reputation: 10283

Side note - although developers do often assign the view controller as the datasource and delegate of a UITableView, you may want to consider farming these responsibilities out to another object.

UIViewController subclasses do have a habit of becoming so-called "god" classes, taking on lots of responsibilities (hence violating the Single Responsibility Principle) and also making them difficult to unit test.

Upvotes: 0

Ruben Marin
Ruben Marin

Reputation: 1637

You're missing

tableView.delegate = self;

Upvotes: 1

visakh7
visakh7

Reputation: 26400

@Ruben is right. Set the delegate of the tableView and Implement the UITableViewDelegate methods

Upvotes: 0

Related Questions