首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

UITableView菜鸟使用方法!

2012-05-02 
UITableView初学者使用方法!急急急!!!!a.h文件的代码如下:#import UIKit/UIKit.h@interface tableviewte

UITableView初学者使用方法!急急急!!!!
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中添加数据,请教请教!!!!!

[解决办法]
[tableview reloadData];

热点排行