Kee*_*ano 4 iphone objective-c ios4
这听起来很简单,从教程中看起来很容易.
我从他们的单词完全按照教程,仍然无法让我的UITableView上显示数组.
这是我的代码.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
salesArray = [[NSMutableArray alloc] init];
//Add items
[salesArray addObject:@"Credit"];
[salesArray addObject:@"Debit"];
[salesArray addObject:@"EBT"];
//Set the title
self.navigationItem.title = @"Sale Type's";
}
-(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{return [salesArray count];}
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[[UITableViewCell alloc]initWithFrame:CGRectZero
reuseIdentifier:CellIdentifier]autorelease];
}
NSString *value = [salesArray objectAtIndex:indexPath.row];
cell.textLabel.text = value;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
是的,我已经在.h文件和.m文件中声明了它.
任何方向的任何帮助都会很棒,谢谢!
声明你salesArray
的财产,并在cellForRowAtIndexPath
,使用
cell.textLabel.text = [self.salesArray objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6102 次 |
最近记录: |