如何多次调用 numberOfSectionsInTableView? [英] How can I call numberOfSectionsInTableView multiple times?
问题描述
我已经实现了 3 个代表 3 个日期的 UIButton.根据选择的按钮,我想显示不同的 UITableView,它代表选定的一天的事件时间表.
I have implemented 3 UIButtons that represents 3 dates. Depending on which button is selected, I want to display a different UITableView, which represents the selected day schedule of events.
根据选择的按钮,我会隐藏其他 2 个表格视图.
Depending on which button is selected, I hide the other 2 table views.
我有 3 个 UITableView,每个 UITableView 都包含在每个 UIView 中,例如 UITableView1 包含在 UIView1 中,用于选择的 UIButton1.
I have 3 UITableViews, each of which is contained within each UIView, for example, UITableView1 is contained within UIView1 for the selected UIButton1.
如何根据选择的按钮调用 numberOfSectionsInTableView 来返回节的数量?
How can it be possible to call numberOfSectionsInTableView to return the number of sections depending on which button is selected?
我有这样的事情:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
if (date1Selected == YES && date2Selected == NO && date3Selected == NO)
{
return [date1 count];
}
else if (date1Selected == NO && date2Selected == YES && date3Selected == NO)
{
NSLog(@"test");
return [date2 count];
}
}
然而,它似乎永远不会进入 else if.
However, it never seems to enter the else if.
我怎样才能做到这一点?
How can I achieve this?
推荐答案
点击 UIButton1
on click of UIButton1
[UITableView1 reloadData]
[UITableView1 reloadData]
点击UIButton2
[UITableView2 reloadData]
[UITableView2 reloadData]
点击UIButton3
[UITableView3 reloadData]
[UITableView3 reloadData]
这篇关于如何多次调用 numberOfSectionsInTableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!