sorry for silly question, I am a beginner in obj-c.
I wanted to add a “load more” feature in my table, I performed that by creating 2 section. The problem now is that the first section to be built from the app is the second, not the first.
Attached the log of the first call of cellForRowAtIndexPath:
2012-10-02 00:07:50.626 ----[6321:c07] item :0
2012-10-02 00:07:50.626 ----[6321:c07] section :1
Isn’t supposed to be something like this:
2012-10-02 00:07:50.626 ----[6321:c07] item :0
2012-10-02 00:07:50.626 ----[6321:c07] section :0
So my app, at first launch, show only the “load more” cell, instead of the first rows of the first section. After the first “press” of the “load more” button, everything works properly.
Anyone can help me?
In
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPathmake sure you are checking theindexPathvariable for itssectionbefore initializing and return theUITableViewCell. If it’s the “load more” cell,indexPath.section == 1will be true. IfindexPath.section == 0, it is your first section table cells.Also make sure
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableViewand- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionare returning the correct numbers.Upon rereading your question, it sounds like you need to initialize your table with cell data before “load more” is pressed. What exactly does “load more” do to your table view’s backing data?