2011-02-24 16 views
7

का कारण बनता है जहां आप एक बटन दबाते हैं जहां आप एक बटन दबाते हैं तो UIAlertView आता है और इसमें 3 कस्टम बटन के साथ UIView है। अब तक सबकुछ काम करता है। जब मैं 3 बटन में से किसी एक पर क्लिक करता हूं तो मैं UIImageView की छवि को बदलना चाहता हूं और यह भी काम करता है। समस्या यह है कि जब भी मैं अपने ऐप्स शुरू करने का प्रयास करता हूं, तब से कहीं भी एक सिगबर्ट नहीं हो रहा है।स्वयं को सेट करना। Window.rootViewController SIGABRT

SIGABRT इस लाइन पर मेरी AppDelegate.m में होती हैं:

self.window.rootViewController = self.viewController; 

किसी मेरी मदद कर सकते हैं कि बहुत अच्छा होगा और जिस तरह से im द्वारा बहुत xcode और के लिए इस्तेमाल नहीं ऑब्जेक्टिव-सी तो मैं नहीं है एक संकेत यह क्यों हो रहा है।

यहाँ मेरी viewController.h

#import UIKit/UIKit.h (i removed < > cause they were hiding everything inbetween in the post.) 

@interface savingstatusViewController : UIViewController { 

    UIView *loginView; 
    UIImageView *statusImage; 
    UIAlertView * MyTicketAlert; 

} 

- (IBAction)status:(id)sender; 

@property (nonatomic, retain) IBOutlet UIView *loginView;  
@property (nonatomic, retain) IBOutlet UIImageView *statusImage; 
@property (nonatomic, retain) IBOutlet UIAlertView * MyTicketAlert; 

- (IBAction)green:(id)sender; 
- (IBAction)yellow:(id)sender; 
- (IBAction)red:(id)sender; 

@end 

है यहाँ मेरी viewController.m

#import "savingstatusViewController.h" 

@implementation savingstatusViewController 

@synthesize loginView; 
@synthesize statusImage,MyTicketAlert; 

- (void)dealloc 
{ 
    [super dealloc]; 
} 

- (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. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
} 

- (void)viewDidUnload 
{ 
    [self setLoginView:nil]; 
    [self setStatusImage:nil]; 
    [super viewDidUnload]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return YES; 
} 

- (IBAction)status:(id)sender 
{ 
    MyTicketAlert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:nil 
            otherButtonTitles: nil]; 
    [MyTicketAlert addSubview:loginView]; 
    [MyTicketAlert show]; 
    MyTicketAlert.frame = CGRectMake(0, 1000, 440, 110); 
} 

- (IBAction)green:(id)sender 
{ 
    statusImage.image = [UIImage imageNamed:@"etat_controle.png"]; 

    [MyTicketAlert dismissWithClickedButtonIndex:0 animated:YES]; 
} 

- (IBAction)yellow:(id)sender 
{ 
    statusImage.image = [UIImage imageNamed:@"etat_attention.png"]; 

    [MyTicketAlert dismissWithClickedButtonIndex:0 animated:YES]; 
} 

- (IBAction)red:(id)sender 
{ 
    statusImage.image = [UIImage imageNamed:@"etat_danger.png"]; 

    [MyTicketAlert dismissWithClickedButtonIndex:0 animated:YES]; 
} 

@end 
+0

विंडो शुरू करने और नियंत्रक देखने के लिए कोड कहां है? क्या आप इसे पोस्ट कर सकते हैं, कृपया? – fbrereto

+0

मुझे एक ही समस्या मिल रही है :( –

उत्तर

2

जाने के लिए "TheNameOfYourProjetdelegate" MainWindow.xib में है।

"TheNameOfYourProjetdelegate" के "आउटलेट" में आप ViewController होना आवश्यक है, तो आपके आवेदन

5

UIWindow rootViewController संपत्ति iOS4 से पहले अस्तित्व में नहीं है चलाने के लिए अपनी खिड़की एट के लिए एक "नियंत्रण खींचें" है। यदि आप इस कोड को आईओएस 3 या पुराने वाले डिवाइस पर चलाने की कोशिश कर रहे हैं, तो यह क्रैश हो जाएगा।

अपने ऐपडिलेगेट में, आप इसके बजाय addSubview का उपयोग कर सकते हैं।

//self.window.rootViewController = self.viewController; // Only iOS >= 4 
[self.window addSubview:self.viewController.view]; 
[self.window makeKeyAndVisible]; 
return YES; 
+0

या, प्रीप्रोसेसर से जांचें: "#if __IPHONE_OS_MIN_VERSION_REQUIRED> = __ IPHONE_4_0" – aksommerville

+0

इंटरनेट पर लगभग 2 घंटे के लिए इसकी तलाश कर रहे थे। वहां बहुत सारे बकवास हैं, अद्भुत जवाब पहली बार काम करता है धन्यवाद TumbleCow। यह अलग-अलग XCode संस्करणों में काम करते समय एक असली गेटू है। यह भी ध्यान रखें कि यदि आप पुराने आईओएस संस्करणों के साथ काम कर रहे हैं तो armv7 को armcode6 में xcc 4 में अपनी बिल्ड सेटिंग्स में बदलें।? –

4

यह तब भी होता है जब फ़ाइल का स्वामी दृश्य सेट या गलत तरीके से सेट नहीं किया गया हो। सुनिश्चित करें कि आपके ViewController.xib की फ़ाइल की स्वामी दृश्य संपत्ति आपके दृश्य पर सेट है। मुझे समझने के लिए थोड़ी देर लग गई!