ios - Counting the amount of sections in tableView -
i want show amount of sections of tableview somewhere badge.
the first problem outcome of 0.
i've declared int in tableviewcontroller.h section.
in .m file:
- (void)viewdidappear:(bool)animated { self.section = [self.tableview numberofsections]; nslog(@"number of sections in tableview %d", self.section); } why still 0 outcome? there somewhere in numberofsectionsintableview need count amount of sections?
thanks
update:
in tableview set al scheduledlocalnotifications. made set of 2 notifications linked each other. so 2 rows of scheduledlocalnotifications in each section.
this have in tableview:
- (nsinteger)numberofsectionsintableview:(uitableview *)tableview { homecoming (int)[[[uiapplication sharedapplication] scheduledlocalnotifications] count]/2; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { // homecoming number of rows in section. homecoming 2; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } // configure cell... int rowindex = (indexpath.section*2) + indexpath.row; // list of local notifications nsarray *localnotifications = [[uiapplication sharedapplication] scheduledlocalnotifications]; uilocalnotification *localnotification = [localnotifications objectatindex:rowindex]; homecoming cell; }
you can find number of sections in tableview after numberofsectionsintableview method call. so, initialize variable in numberofsectionsintableview method before homecoming statement.
ios objective-c uitableview
No comments:
Post a Comment