Uitableview 如何从UIViewController填充表视图
我想在我的scrollview上添加4个UITableView,并使用一些不同的数组来弹出它们(假设每个数组有一个数组)。我也将这个滚动视图添加到了我的Uitableview 如何从UIViewController填充表视图,uitableview,ios5,uiviewcontroller,Uitableview,Ios5,Uiviewcontroller,我想在我的scrollview上添加4个UITableView,并使用一些不同的数组来弹出它们(假设每个数组有一个数组)。我也将这个滚动视图添加到了我的self.view(我在UIViewController类上做这些事情)。我如何填充我的表格视图有人能帮忙吗 更多详细信息: 这里是一个屏幕截图; 这是我的UIViewControllerClass的界面 #import <UIKit/UIKit.h> @interface MainMenu : UIViewController&
self.view
(我在UIViewController类上做这些事情)。我如何填充我的表格视图有人能帮忙吗
更多详细信息:
这里是一个屏幕截图;
这是我的UIViewControllerClass的界面
#import <UIKit/UIKit.h>
@interface MainMenu : UIViewController<UITableViewDelegate>
@property (retain, nonatomic) IBOutlet UIScrollView *scrollView;
@property (retain, nonatomic) IBOutlet UITableView *group1;
@property (retain, nonatomic) IBOutlet UITableView *group2;
@property (retain, nonatomic) IBOutlet UITableView *group3;
@property (retain, nonatomic) IBOutlet UITableView *group4;
@end//i drag/dropped from IB, so there is no problem with synthesizes..
dude,首先您将使uiviewcontroller取消所有4个表的委托和数据源,然后您将为每个表分配不同的标记。。然后您将添加委托和数据源协议。。。您将像普通的uitableviewcontroller一样实现datasource和委托方法。。。所有这些方法都接收Uitableview参数,因此您将测试此表视图的标记,如:
...
if (tableView.tag == 10) {
//implement the table 1
NSArray *array=[NSArray arrayWithObjects:@"one",@"two",@"tree", nil];
cell.textLabel.text = [array objectAtIndex:indexPath.row];
} else if (tableView.tag == 20) {
//implement the table 2
} else if (tableView.tag == 30) {
//implement the table 3
} else if (tableView.tag == 40) {
//implement the table 4
}
return cell;
这样,您将使用相同的方法来执行所有表视图。dude,首先您将使uiviewcontroller取消所有4个表的委托和数据源,然后您将为每个表分配不同的标记。。然后您将添加委托和数据源协议。。。您将像普通的uitableviewcontroller一样实现datasource和委托方法。。。所有这些方法都接收Uitableview参数,因此您将测试此表视图的标记,如:
...
if (tableView.tag == 10) {
//implement the table 1
NSArray *array=[NSArray arrayWithObjects:@"one",@"two",@"tree", nil];
cell.textLabel.text = [array objectAtIndex:indexPath.row];
} else if (tableView.tag == 20) {
//implement the table 2
} else if (tableView.tag == 30) {
//implement the table 3
} else if (tableView.tag == 40) {
//implement the table 4
}
return cell;
这样,您将使用相同的方法执行所有表视图。您没有在界面中输入数据源,还必须实现以下方法:-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section;您没有在接口中输入数据源,还必须实现以下方法:-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section;但是如何实现-(NSInteger)tableView:(UITableView*)tableView numberofrowsinssection:(NSInteger)section{}它不接受switch()-case..我解决了这个问题,已经解决了很多(我像你说的那样使用了标记),但是如何实现-(NSInteger)tableView:(UITableView*)tableView numberofrowsinssection:(NSInteger)section{它不接受switch()-case..我解决了这个问题,已经很多了(我使用了你说的标签)