2012-03-19 26 views
0

タブアプリケーションを作成し、日付ピッカーと丸矩形ボタンを含む最初のXIBファイルを作成しました。問題は私がそれを実行すると、何もシミュレータに表示されません。コメントアウトした実装ファイルのBidDatePickerViewControllerの "不完全な実装"に対して警告を1つだけ取得します。ここXIBファイルが表示されない

ファイルのためのコードである:

のViewControllerヘッダー:

#import <UIKit/UIKit.h> 

@interface BiDDatePickerViewController : UIViewController 

@property (strong, nonatomic)IBOutlet UIDatePicker *datePicker; 

-(IBAction):buttonPressed; 

@end 

のViewControllerの実装:

#import "BiDDatePickerViewController.h" 

@implementation BiDDatePickerViewController // Incomplete implementation 
@synthesize datePicker; 

-(IBAction)buttonPressed 
{ 
    NSDate *selected = [datePicker date]; 
    NSString *message = [[NSString alloc]initWithFormat:@"The date and time selected is: %@", selected]; 
    UIAlertView *alert = [[UIAlertView alloc] 
          initWithTitle:@"Date And Time Selected" 
          message:message 
          delegate:nil 
          cancelButtonTitle:@"Yes, I did." 
          otherButtonTitles:nil]; 
    [alert show]; 
} 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    NSDate *now = [NSDate date]; 
    [datePicker setDate:now animated:NO]; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
    self.datePicker = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

@end 

AppDelegate.m

移入 "BiDAppDelegate.h"

あなたがアプリケーションにしたいビューコントローラ(BiDDatePickerViewController)を表示するようにrootViewControllerを設定する必要があり
@implementation BiDAppDelegate 

@synthesize window = _window; 
@synthesize rootController; 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // Override point for customization after application launch. 
    [[NSBundle mainBundle] loadNibNamed:@"TabBarController" owner:self options:nil]; 
    [self.window addSubview:rootController.view]; 
    self.window.backgroundColor = [UIColor whiteColor]; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 
@end 

答えて

1

:didFinishLaunchingWithOptions:

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

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // Override point for customization after application launch. 

    [[NSBundle mainBundle] loadNibNamed:@"TabBarController" owner:self options:nil]; 

    [self.window addSubview:rootController.view]; 

    self.window.backgroundColor = [UIColor whiteColor]; 

    [self.window makeKeyAndVisible]; 

    BiDDatePickerViewController* viewController = [BiDDatePickerViewController new]; 
    [self.window.rootViewController presentModalViewController:viewController animated:NO]; 
    [viewController release]; 
    return YES; 
} 
0
-(BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions (NSDictionary *) launchOptions 

{ 

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

    self.window.backgroundColor = [UIColor whiteColor]; 

    BiDDatePickerViewController* viewController = [[BiDDatePickerViewController alloc]initWithNibName:@"TabBarController" bundle:nil]; 
    [self.window addSubview:rootController.view]; 
    [self.window makeKeyAndVisible]; 
    [viewController release]; 
     return YES; 
} 
関連する問題