Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何自定义包含导航栏、分段控件和表视图的视图?_Ios_Uitableview_Uinavigationbar_Uisegmentedcontrol - Fatal编程技术网

Ios 如何自定义包含导航栏、分段控件和表视图的视图?

Ios 如何自定义包含导航栏、分段控件和表视图的视图?,ios,uitableview,uinavigationbar,uisegmentedcontrol,Ios,Uitableview,Uinavigationbar,Uisegmentedcontrol,如何自定义包含导航栏、分段控件和表视图的视图?选项卡分段控件的每个段,显示不同的表视图。帮助我。我在用故事板 像这样第一件事是将分段控件链接到视图控制器,作为头文件中的一个出口 @property (strong, nonatomic) IBOutlet UISegmentedControl *segmentedControl; - (IBAction)segmentChanged:(id)sender; 接下来,当用户在头文件中选择一个段时,还需要将iAction方法链接到此分段控件 @p

如何自定义包含导航栏、分段控件和表视图的视图?选项卡分段控件的每个段,显示不同的表视图。帮助我。我在用故事板
像这样

第一件事是将分段控件链接到视图控制器,作为头文件中的一个出口

@property (strong, nonatomic) IBOutlet UISegmentedControl *segmentedControl;
- (IBAction)segmentChanged:(id)sender;
接下来,当用户在头文件中选择一个段时,还需要将iAction方法链接到此分段控件

@property (strong, nonatomic) IBOutlet UISegmentedControl *segmentedControl;
- (IBAction)segmentChanged:(id)sender;
完成此操作后,假设用户选择一个段时有三个单独的数据数组要重新加载tableview,则可以执行此操作:

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

switch(segmentedControl.selectedSegmentIndex){

case 0:

//create cell and assign array1 data
     break;
case 1:

//create cell and assign array2 data
     break;
case 2:

//create cell and assign array3 data
     break;
default:
     break;

}

return cell;

}
然后在IBAction方法中只需调用

[self.yourTableView reloadData];
这将允许您根据选定的段使用正确的数据重新加载tableView


希望这对您有帮助

您想做什么自定义?这是我的任务,不知道如何做@所以您的任务只是在点击段控制按钮或其他什么时更新tableview?