Xcode3.2.3を使用しています。今、私は単純なUITableビューを実行しています。そのために、このリンクを参照しました。
ここに記載されているすべての手順を実行しました。しかし、私のアプリケーションを起動すると、白い画面しか表示されません。テーブルビューはありません。解決策を教えてください。前もって感謝します。
MyCodeはAppDelegate.hです
#import <UIKit/UIKit.h>
@class TableBasicsViewController;
@interface TableBasicsAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
TableBasicsViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet TableBasicsViewController *viewController;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "TableBasicsViewController.h"
@implementation TableBasicsAppDelegate
@synthesize window;
@synthesize viewController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
@end
TableBasicViewController.h
#import <UIKit/UIKit.h>
@interface TableBasicsViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
}
@property (nonatomic, retain) NSArray *games;
@end
TableBasicViewController.m
#import "TableBasicsViewController.h"
@implementation TableBasicsViewController
@synthesize games;
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
self.games = [NSArray arrayWithObjects: @"Super Mario Bros.",
@"The Legend of Zelda", @"Blades of Steel",
@"Teenage Mutant Ninja Turtles", @"Excitebike",
@"Dr. Mario", @"Duck Hunt", @"Tetris", @"Ice Climber",
@"River City Ransom", @"Ninja Gaiden", @"Super Mario Bros. 3",
@"Mega Man 2", @"Kid Icarus", @"Metroid", @"Metal Gear",
@"Super Mario Bros. 2", @"Zelda II: The Adventure of Link",
nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section {
return [self.games count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Default";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = [self.games objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Selected: '%@'", [self.games objectAtIndex:indexPath.row]);
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (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.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
self.games = nil;
[super dealloc];
}
@end