我想在我的scrollview中添加4个UITableViews,并用一些不同的数组弹出它们(让我们说我每个都有一个数组)。我已经将这个滚动视图添加到我的self.view
(我在UIViewController类上做这个东西)。我怎样才能填充我的桌面视图任何人都可以帮忙吗?如何从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..
我想填充这些tableview中具有不同的阵列,如何处理这种情况..?非常感谢
附加说明;我想这样的事情,但没有效果:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [group1 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSArray *array=[NSArray arrayWithObjects:@"one",@"two",@"tree", nil];
cell.textLabel.text = [array objectAtIndex:indexPath.row];
return cell;
}
您没有在界面中输入数据源,您还必须实现该方法: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; – WhiteTiger 2012-04-19 11:59:16