2
votes

I am working with UITableView now and what I an having is

MyClass.h

@interface MyClass : UIViewController {

}

@property (strong , strong) UILabel *name;

@property (strong , strong) UILabel *add;

and

MyClass.m

-(NSInteger)tableView:(UITableView *)atableView numberOfRowsInSection:(NSInteger)section{

return 3 ;
 }

-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"cell";
tableCell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
...................................................

return tableCell; 

}

When I put i break point at numberOfRowsInSection, it seems that it is not being executed at all. It is confusing me now. Please advice if you have encountered it before.

Thanks

1
Please revise your code before posting. Your @property is in the wrong place. And the code you omitted with dots, plays major role about what to display.He Shiming
i have just edited...the first thing I just wanna make sure that numberOfRowsInSection is being executed or not. Otherwise, displaying is nothing....tranvutuan

1 Answers

3
votes

The most common cause of this is not setting your view controller as the table view delegate and datasource. If it's built in storyboard, you can do this by selecting the connections inspector on the table and dragging those properties to the view controller.

Otherwise, set it in code like this:

self.tableView.delegate = self;
self.tableView.datasource = self;