2011-02-24 19 views
7

Estoy tratando de hacer una aplicación donde presiona un botón y luego aparece un UIAlertView y hay un UIView dentro de él con 3 botones personalizados. Hasta ahora todo funciona. Cuando hago clic en uno de los 3 botones quiero cambiar la imagen de un UIImageView y eso también funciona. El problema es que, de la nada, aparece una sigla cada vez que intento iniciar mis aplicaciones.Configuración self.window.rootViewController causas SIGABRT

El SIGABRT suceder en mi AppDelegate.m en esta línea:

self.window.rootViewController = self.viewController; 

Si alguien me puede ayudar a que sería grande y por cierto no soy muy utilizado para Xcode y Objective-C, así que no tengo una pista de por qué esto está sucediendo.

Aquí es mi 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 

Aquí está mi 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

¿Dónde está el código para inicializar la ventana y viewController? ¿Puedes publicar eso, por favor? – fbrereto

+0

Estoy recibiendo el mismo problema :( –

Respuesta

2

vaya a "TheNameOfYourProjetdelegate" en MainWindow.xib.

En "puntos de venta" de "TheNameOfYourProjetdelegate" Usted debe tener viewController, a continuación, hacer un "arrastre de control" a la ventana y ejecutar la aplicación

5

La propiedad UIWindow RootViewController no existe antes de iOS4. Si intenta ejecutar este código en un dispositivo con iOS 3 o anterior, se bloqueará.

En su AppDelegate, puede usar addSubview en su lugar.

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

O, consulte con el preprocesador: "#if __IPHONE_OS_MIN_VERSION_REQUIRED> = __ IPHONE_4_0" – aksommerville

+0

He estado buscando esto durante aproximadamente 2 horas en Internet. Hay tanta mierda por ahí, la respuesta increíble funcionó la primera vez gracias TumbleCow. Esto es un verdadero juego de palabras cuando trabajas en diferentes versiones de XCode. También ten en cuenta que si trabajas con versiones anteriores de iOS, cambia el brazov7 a armv6 en tu configuración de compilación en xcode 4. –

4

Esto también ocurre si la vista del propietario del archivo no se ha configurado o configurado incorrectamente. Asegúrese de que la propiedad de visualización del propietario del archivo de su ViewController.xib esté configurada a su vista. Me tomó un tiempo descubrirlo.

Cuestiones relacionadas