Je suis en train de mettre en œuvre le scénario suivant: Il y a un écran appelé: étude (cet écran est le RootViewController de mon onglet contrôleur de bar)plusieurs tables sur écran unique programme (sans fichier xib) iphone
Dans cet écran, je dois afficher deux tables différentes: mots et phrases
je dois faire programatically (sans un fichier nIB). Donc, je suis en train d'écrire le loadview pour la vue comme contrôleur d'étude:
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
//creating the view for the screen "Study"
CGRect cgRct = CGRectMake(0, 0, 320, 367); //define size and position of view
UIView *myStudyView = [[UIView alloc] initWithFrame:cgRct]; //initilize the view
myStudyView.autoresizesSubviews = YES; //allow it to tweak size of elements in view
myStudyView.backgroundColor = [UIColor brownColor];
self.view = myStudyView; //set view property of controller to the newly created view
[myStudyView release];
//creating the view for the "words" and instantiating the view controller
WordsTableViewController *wordsTVC = [[[WordsTableViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
cgRct = CGRectMake(0, 10, 320, 100);//define size and position of view
UIView *myWordsView = [[UIView alloc] initWithFrame:cgRct];//initilize the view
myWordsView.autoresizesSubviews = YES;//allow it to tweak size of elements in view
wordsTVC.view = myWordsView;//set view property of controller to the newly created view
[myWordsView release];
[self.view addSubview:wordsTVC.view];
//creating the view for the "phrases" and instantiating the view controller
PhrasesTableViewController *phrasesTVC = [[[PhrasesTableViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
cgRct = CGRectMake(0, 120, 320, 100); //define size and position of view
UIView *myPhrasesView = [[UIView alloc] initWithFrame:cgRct]; //initilize the view
myPhrasesView.autoresizesSubviews = YES; //allow it to tweak size of elements in view
phrasesTVC.view = myPhrasesView; //set view property of controller to the newly created view
[myPhrasesView release];
[self.view addSubview:phrasesTVC.view];
}
Je vois juste la couleur de fond brun de l'écran d'étude. Les deux tables n'apparaissent pas. Je suis sûr de faire une erreur fondamentale comme je suis un débutant total pour le développement de l'iPhone. BTW, WordsTableViewController et PhrasesTableViewController sont des sous-classes TableViewController définies séparément.
Appréciez votre aide. -Achilles
Utilisez la fonction d'indentation Markdown pour clarifier votre code. – jbm