2011-06-14 3 views
1

내 응용 프로그램은 탭 모음 응용 프로그램입니다. 하단에는 두 개의 탭이 있고 첫 번째 탭에는 새 창으로 연결되는 버튼이 있습니다. xcode에서 코드를 빌드하면 성공합니다. 시뮬레이터에서 앱을 실행하고 새 창으로 연결되는 버튼을 클릭하면 앱이 다운됩니다. 이것은 "FirstViewController"과 "GuitarBrandsViewController"에 대한 내 코드iPhone 시뮬레이터에서 버튼을 누르면 앱이 다운됩니다. Xcode 3.2.5

입니다 FirstViewController.h-

#import <UIKit/UIKit.h> 
#import "GuitarBrandsViewController.h" 


@interface FirstViewController : UIViewController { 
    FirstViewController *firstViewController; 

    IBOutlet UIWindow *window; 
    IBOutlet UIWindow *GuitarBrands; 
} 

@property (nonatomic, retain) IBOutlet UIWindow *window; 

-(IBAction)gotoGuitarBrands; 

@end 

FirstViewController.m

#import "FirstViewController.h" 


@implementation FirstViewController 
@synthesize window; 

-(IBAction)gotoGuitarBrands{ 

    GuitarBrandsViewController *screen = [[GuitarBrandsViewController alloc] initWithNibName:nil bundle:nil]; 
    screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    [self presentModalViewController:screen animated:YES]; 
    [screen release]; 
} 

GuitarBrandsView Controller.h

#import <UIKit/UIKit.h> 
#import "FirstViewController.h" 

@interface GuitarBrandsViewController : UIViewController { 
    GuitarBrandsViewController *guitarBrandsViewController; 
    IBOutlet UIWindow *window; 
    IBOutlet UIWindow *Main; 
} 

@property (nonatomic, retain) IBOutlet UIWindow *window; 
-(IBAction)gotoMain; 

@end 

GuitarBrandsViewController.m

#import "GuitarBrandsViewController.h" 

@implementation GuitarBrandsViewController 
@synthesize window; 

-(IBAction)gotoMain{ 

    FirstViewController *screen = [[FirstViewController alloc] initWithNibName:nil bundle:nil]; 
    screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    [self presentModalViewController:screen animated:YES]; 
    [screen release]; 
} 
+1

인터페이스 빌더를 사용하지 않는 이유의 좋은 예입니다. 도움을 요청하는 것은 고통입니다 ... 귀하의 컨트롤이 선택자와 올바르게 연결되었는지 여부를 알려주는 방법은 없습니다 ... –

+0

xcode에서 표시되는 오류는 무엇입니까? –

답변

1

는 당신이 그것을 자신에 작동하지 않을 클래스 자체의 코드로 인터페이스 빌더를 사용하여 GuitarBrandsViewController를 만드는 가정합니다.

그러나 GuitarBrandsViewController를 초기화 할 때 NIB를 전달하지 않으므로 IB의 실제 NIB 정보없이 제어 클래스를 할당합니다. 대신

GuitarBrandsViewController *screen = [[GuitarBrandsViewController alloc] initWithNibName:nil bundle:nil]; 

사용

GuitarBrandsViewController *screen = [[GuitarBrandsViewController alloc] initWithNibName:@"GuitarBrandsViewController.xib" bundle:nil]; 

은 사용하는 실제 펜촉의 이름으로 펜촉 이름을 조정합니다.

관련 문제