Pregunta

Estoy intentando cambiar de vista entre los controladores de vista en mi aplicación para el iPhone, pero estrellado. Básicamente estoy cambiando de mainScreen a prueba.

Me sale un error en el depurador:

0x01d6a000  <+0000>  push   %ebp
0x01d6a001  <+0001>  mov    %esp,%ebp
0x01d6a003  <+0003>  int3   
0x01d6a004  <+0004>  leave  (HIGHLIGHTED)
0x01d6a005  <+0005>  ret    
0x01d6a006  <+0006>  nopw   %cs:0x0(%eax,%eax,1)

mainscreen.h

#import <UIKit/UIKit.h>

@interface MainScreen : UIViewController {

}

-(IBAction)btnFirstPage:(id)sender;

@end

mainscreen.m

#import "MainScreen.h"
#import "test.h"

@implementation MainScreen

-(IBAction)btnFirstPage:(id)sender{

 test1 = [[test1 alloc] 

    initWithNibName:@"test"  (test may not respond to -alloc)

    bundle:nil];

    [self.view addSubview:test1.view];

/* etc. */

test.h

#import <UIKit/UIKit.h>

@interface test : UIViewController {
}

@end
¿Fue útil?

Solución

Esto parece extraño: test1 = [[test1 alloc] ...]. Está enviando el mensaje alloc a una variable, que supongo es inicialmente el puntero nulo, y por lo tanto está siendo ignorada en silencio. Usted debe invocar alloc el tipo de clase de test1, no test1 sí mismo.

Otros consejos

test1 = [[prueba alloc] initWithNibName: @ "test" undle: nil]; // aquí debe ser prueba. No test1

Al crear objetos de clases que tiene que utilizar métodos alloc y estáticas allocWithZone utilizan en la clase NSObject. Así que hay que utilizar el nombre de clase. No es el nombre de la variable. (Prueba1)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top