Friday, December 6, 2013

UITableView beginners to use! Jiji Ji! ! ! !

code a.h file is as follows:

# Import

@ Interface tableviewtest: UIView
{
UITableView * DataTable;


}
@ Property (nonatomic, retain) IBOutlet UITableView * DataTable;

@ End


code a.m file is as follows:
# 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];
}
Pictures
/ / cell.imageView.image = image ;/ / unselected cell when/ / Cell.imageView.highlightedImage = highlightImage ;/ / select the cell after pictures
/ / Set up the cell.
/ / NSString * timeZoneName = [timeZoneNames objectAtIndex: indexPath.row];
cell.textLabel.text = @ "test";
return cell;

}

@ End


The problem is that now I do not know how to add data in TABLEVIEW, and ask advice! ! ! ! !
Reply:
[Tableview reloadData];

No comments:

Post a Comment