Я новичок в Iphone и мне нужна помощь для отображения текста в виде таблицы.
Вот мой код:
.h
@class MainMenuViewController;
@interface RecherchePartenaireViewController : UIViewController <UINavigationControllerDelegate> {
MainMenuViewController *mainMenuViewController;
UINavigationController *navigationController;
GradientButton *rechercheButton;
RecherchePartenaireResultatListeViewControleur *recherchePartenaireResultatListeViewControleur;
IBOutlet UITableView *categorystable;
NSMutableArray *listData;
}
@property (nonatomic, retain) IBOutlet MainMenuViewController *mainMenuViewController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet GradientButton *rechercheButton;
@property (nonatomic, retain) IBOutlet RecherchePartenaireResultatListeViewControleur *recherchePartenaireResultatListeViewControleur;
@property (nonatomic, retain) IBOutlet UITableView *categorystable;
@property(nonatomic, retain) NSArray *listData;
@end
а в .м у меня:
@synthesize mainMenuViewController, navigationController, rechercheButton, recherchePartenaireResultatListeViewControleur,listData;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[mainMenuViewController release];
[navigationController release];
[rechercheButton release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
listData = [[NSMutableArray alloc] initWithObjects:@"iPhone", @"iPod", @"iPad",nil];
NSLog(@"hey %@",listData);
[rechercheButton useRedDeleteStyle];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
self.rechercheButton = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
// Customize the appearance of table view cells.
- (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];
}
// Set up the cell...
cell.textLabel.text = @"label";
/*[[cell textLabel] setText: [[listData objectAtIndex:indexPath.row] valueForKey:@"name"]];*/
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return listData;
}
@end
и я ничего не получаю от tableView. Где моя ошибка? Я видел много примеров в сети, но я не вижу, что я делаю неправильно. Кто-нибудь может мне помочь?