English 中文(简体)
装置上的布隆克屏幕;模拟器操作罚款
原标题:Blank screen on device; simulator working fine
  • 时间:2011-06-12 19:42:08
  •  标签:
  • iphone
  • ios

我写的是一架有导航控制器的SOS。 当我向Simulator开放时,它会受到罚款。 当我操作该装置时,在状态栏下播放了一个空白屏幕。 加上我可以指出,我的“根基勒”是默认的观点(我怀疑这是我问题的根源)。

@class RootViewController;

@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    RootViewController *viewController;

    UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet RootViewController *viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    // Set the navigation controller as the window s root view controller and display.
    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];

    // ...

    return YES;
}

GenViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Main Menu";
}

没有任何观点、观点和看法。

显示零件。

- (UITableViewCell *)tableView:(UITableView *)tv
        cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    tv.backgroundColor = [UIColor whiteColor];

    UITableViewCell *cell;
    if (indexPath.row == 0)
        cell = newsCell;
    else if (indexPath.row == 1)
        cell = configureCell;
    else if (indexPath.row == 2)
        cell = aboutCell;

    return cell;
}

- (NSInteger)tableView:(UITableView *)tv numberOfRowsInSection:(NSInteger)section
{
    return 0;
}

#pragma mark UITableViewDelegate Methods


- (CGFloat)tableView:(UITableView *)tv
heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 84;
}

- (void) tableView:(UITableView *)tv
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (0 == indexPath.row)
    {
    }
    else if (1 == indexPath.row)
    {
    }
    else if (2 == indexPath.row)
    {
    }
}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn t have a superview.
    [super didReceiveMemoryWarning];

    // Relinquish ownership any cached data, images, etc that aren t in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
    [tableView release];
    [newsCell release];
    [configureCell release];
    [aboutCell release];
}

RootViewController.h

@interface RootViewController : UIViewController
<UITableViewDataSource, UITableViewDelegate>
{
    UITableView *tableView;
    IBOutlet UIView *displaySplashScreen;
    IBOutlet UITableViewCell *newsCell, *configureCell, *aboutCell;
}

@property (nonatomic, retain) IBOutlet UITableView *tableView;
问题回答

There are a few issues here. First, your AppDelegate header should read:

@class RootViewController;

@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    RootViewController *rootViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

Then, in the implementation, add the root to the navigation controller and the navController to the window like this:

#import "RootViewController.h"

@implementation MyAppDelegate

@synthesize window;

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    rootViewController = [[RootViewController alloc] init];
    UINavigationController *navController = [[UINavigationController alloc] 
                                             initWithRootViewController:rootViewController];

    [window addSubview:[navController view]];
    [self.window makeKeyAndVisible];

    return YES;
}

PengOne s answer is correct, except I d make one small change. Do this:

#import "RootViewController.h"

@implementation MyAppDelegate

@synthesize window;

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    rootViewcontroller = [[RootViewController alloc] init];
    UINavigationController *navController = [[UINavigationController alloc] 
                                         initWithRootViewController:rootViewController];

    self.window.rootViewController = navController;

    [self.window makeKeyAndVisible];
    return YES;
}

It s a better way to show a nav controller. As PengOne also said, it has to be a problem with your Interface Builder file. Unhook everything then hook it up again to see if the problem persists. If it does, check to make sure everything is named correctly. Good luck!





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签