10

का उपयोग करना चाहता है, तो मैं एक प्रोग्राम व्यू कंट्रोलर प्रोग्रामेटिक रूप से कार्यान्वित कर रहा हूं। जब मैं परियोजना चलाने का प्रयास, मैं त्रुटि मिली:ऐप प्रतिनिधि को विंडो प्रॉपर्टी को कार्यान्वित करना होगा यदि वह मुख्य स्टोरीबोर्ड फ़ाइल

2012-11-07 22:46:34.719 myTableViewControl[12021:c07] The app delegate must implement the   window property if it wants to use a main storyboard file. 
2012-11-07 22:46:34.722 myTableViewControl[12021:c07] -[AppDelegate setWindow:]:  unrecognized selector sent to instance 0x7674e70 
2012-11-07 22:46:34.723 myTableViewControl[12021:c07] *** Terminating app due to uncaught  exception 'NSInvalidArgumentException', reason: '-[AppDelegate setWindow:]: unrecognized  selector sent to instance 0x7674e70' 
*** First throw call stack: 
(0x1c8e012 0x10cbe7e 0x1d194bd 0x10df7ea 0x1c7dcf9 0x1c7d94e 0x1d60 0x107b7 0x10da7  0x11fab 0x23315 0x2424b 0x15cf8 0x1be9df9 0x1be9ad0 0x1c03bf5 0x1c03962 0x1c34bb6 0x1c33f44  0x1c33e1b 0x117da 0x1365c 0x1bd2 0x1b05) 
libc++abi.dylib: terminate called throwing an exception 
(lldb) 

जब मैं कोड चलाने के लिए, यह main.m पर लटका और पता चलता है कि

"thread1: signal SIGABRT"

@autoreleasepool {return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 

मेरी कोड के रूप में है निम्नलिखित: AppDelegate.h

// 
// AppDelegate.h 
// myTableViewControl 
// 
// Created by Max on 12-11-5. 
// Copyright (c) 2012年 Max. All rights reserved. 
// 

#import <UIKit/UIKit.h> 

@interface AppDelegate : UIResponder <UIApplicationDelegate> 

@property (strong, nonatomic) UINavigationController *navigationController; 


@end 

AppDelegate.m

+०१२३५१६४१०
// 
// AppDelegate.m 
// myTableViewControl 
// 
// Created by Max on 12-11-5. 
// Copyright (c) 2012年 Max. All rights reserved. 
// 

    #import "AppDelegate.h" 
    #import "firstViewController.h" 


@implementation AppDelegate 
@synthesize navigationController; 


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions 
{ 
    // create the base window 
    UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    window.backgroundColor = [UIColor greenColor]; 
    self.window = window; 

    [window release]; 

    // this is the home page from the user's perspective 

    FirstViewController *fvc = [[FirstViewController alloc] init]; 

    UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:fvc]; 
    self.navigationController = nc; 

    [fvc release]; 
    [nc release]; 

    // show them 
    [self.window addSubview: nc.view]; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 

@end 

FirstViewController सूची दृश्य नियंत्रक है।

उत्तर

15

आप एक स्थानीय चर के रूप में अपनी खिड़की पैदा कर रहे हैं और फिर इसे उपयोग करने के लिए जैसे कि यह एक संपत्ति self.window का उपयोग करके थे कोशिश कर रहा। इसे एक संपत्ति बनाओ।

+4

फिलिप सही है। आप हेडर फ़ाइल से इस लाइन को याद कर रहे हैं: '@property (मजबूत, nonatomic) UIWindow * विंडो;' – Cashew

+0

thnx तो .... बहुत। मैं आईओएस पर नया लड़का हूं, आपके लिए लड़के की मदद – max

+1

के लिए बहुत सराहना की है, साथ ही, जब आपके पास पहले से ही '@ property' है और यह अभी भी रनटाइम त्रुटि फेंकता है, तो देखें कि आपके पास इसके लिए' @ संश्लेषण 'भी है। यह किसी भी तरह चमत्कारी ** बिना एक्सकोड 4.5 और आईफोन 5 के लिए काम करता है। मैंने किसी अन्य संयोजन की कोशिश नहीं की है, क्योंकि मुझे पहले से ही यह त्रुटि मिली है। –