a.h文件的代码如下:#import <UIKit/UIKit.h>@interface tableviewtest : UIView
{
UITableView *DataTable;
}
@property (nonatomic, retain) IBOutlet UITableView *DataTable;@end
a.m文件的代码如下:
#import "a.h"
@implementation tableviewtest
@synthesize DataTable;- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)layoutSubviews {
}- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// There is only one section.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of time zone names.
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
// Try to retrieve from the table view a now-unused cell with the given identifier.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
// If no cell is available, create a new one using the given identifier.
if (cell == nil) {
// Use the default cell style.
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
}
//cell.imageView.image=image;//未选cell时的图片
//cell.imageView.highlightedImage=highlightImage;//选中cell后的图片
// Set up the cell.
//NSString *timeZoneName = [timeZoneNames objectAtIndex:indexPath.row];
cell.textLabel.text = @"test";
return cell;
}@end
问题是现在不知如何在TABLEVIEW中添加数据,请教请教!!!!!
{
UITableView *DataTable;
}
@property (nonatomic, retain) IBOutlet UITableView *DataTable;@end
a.m文件的代码如下:
#import "a.h"
@implementation tableviewtest
@synthesize DataTable;- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)layoutSubviews {
}- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// There is only one section.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of time zone names.
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
// Try to retrieve from the table view a now-unused cell with the given identifier.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
// If no cell is available, create a new one using the given identifier.
if (cell == nil) {
// Use the default cell style.
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
}
//cell.imageView.image=image;//未选cell时的图片
//cell.imageView.highlightedImage=highlightImage;//选中cell后的图片
// Set up the cell.
//NSString *timeZoneName = [timeZoneNames objectAtIndex:indexPath.row];
cell.textLabel.text = @"test";
return cell;
}@end
问题是现在不知如何在TABLEVIEW中添加数据,请教请教!!!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货