correct indexPath.row selection in TableView which has multiple sections?

前端 未结 2 1896
忘了有多久
忘了有多久 2021-01-15 12:19

i am having tableview with multiple sections .each section is having different no of rows. when i select in particular row in particular section, how can i find correct inde

2条回答
  •  离开以前
    2021-01-15 12:47

    UITableview sends the delegate a

    willSelectRowAtIndexPath: and didSelectRowAtIndexPath: message

    and it send a

    UITableViewSelectionDidChangeNotification notifications to observers.

    By listening to these messages your will know what rows are selected.

    There is a template in xCode with a UITableView which is a good starting point for learning UITableView. Your could implement it around an NSArray of strings as your datasource. That way focusing your learning effort on the UITableView code.

    Best way is really to make a simple UITableView and flesh out the delegate methods along with the any calls to observers step by step.

    Apples class reference will get you a long way.

提交回复
热议问题