我开始了一个标签式应用程序项目,并在我的第一个观点我想获得一个填充的列表,所以我宣布一个类似的NSArray如下:的TableView到tabBarController
@interface agrospineFirstViewController : UIViewController <UITableViewDelegate ,UITableViewDataSource>
{
NSArray *JournalList;
}
@property (nonatomic,retain) NSArray *JournalList;
@end
,我加上了.M如下:
[super viewDidLoad];
//initialisation de la liste
JournalList = [NSArray arrayWithObjects:@"journal1",@"journal2",nil];
//initialisation du table View
UITableView* tableView=[[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]style:UITableViewStylePlain];
//population de la vue
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [JournalList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
// Configuration de la cellule
NSString *cellValue = [JournalList objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
我也DROP掉了tablelist到视图...但仍表现出对numberOfRowsInSection错误,要求更换“:”通过“;” 任何帮助意见改善?
谢谢您的时间
ü需要ALLOC您的阵列, JournalList = [[NSArray中的alloc] initWithObjects:@ “journal1”,@ “journal2”,零]。 – Charan 2012-04-12 09:45:17
你应该粘贴视图控制器的所有代码。 – 2012-04-12 09:56:25