我開始了一個標籤式應用程序項目,並在我的第一個觀點我想獲得一個填充的列表,所以我宣佈一個類似的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