-1

내 응용 프로그램에서 UINavigationController을 사용하고 있으며 어떤 이유로 인해 CompanyView라는 third xib으로 페이지를 전환 할 수 없습니다. 첫 번째에서 두 번째이지만 세 번째에서 세 번째로 바뀌지 않습니다. 나는 아마 뭔가 잘못하고 있지만 누군가 내 코드를 살펴볼 수 있다면 멋질 것입니다. 나는 내가 믿는 바르게 설정된 버튼을 가지고있다. 다음은보기를 변경하지 않습니다 xib.h file입니다 :UINavigationController를 사용하여 다른보기로 이동

#import "MenuView.h" 

@implementation MenuView 

-(IBAction)btnClicked:(id)sender { 

    CompanyView * companyView = [[CompanyView alloc] init]; 

    companyView.title = @"Company"; 

    [self.navigationController pushViewController:companyView animated:YES]; 

    [companyView release]; 
} 



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (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]; 
    // Do any additional setup after loading the view from its nib. 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

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

@end 

답변

0

이 당신의 회사보기 이런 식으로 초기화하십시오 :

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

@interface MenuView : UIViewController 

-(IBAction)btnClicked:(id)sender; 

@end 

가 여기에 .m file 내 코드입니다.

CompanyView *companyView = [[CompanyView alloc] initWithNibName:@"CompanyView" bundle:nil]; 
+0

도움을 줄 수 있습니다. 내 CompanyView.h 및 .m 파일에 추가해야하는 코드가 있습니까? – Maple

0

이 내가 그것을 설정하는 방법입니다

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
     CategoryPresetViewController *controller = [[CategoryPresetViewController alloc] initWithPVCDelegate:avc]; 
     controller.title = [[factoryCategoryNameArray objectAtIndex:indexPath.row] retain]; 
     if (controller != nil){ 
      [self.navigationController pushViewController:controller animated:YES]; 

     [controller release]; 
} 

어쩌면 그것 아직 전환하지 ... 흠 당신에게

+0

어리석은 일은 미안하지만이 코드를 어디에 둘 수 있는지 알고 있습니까? 특수 존 (Special John) 어디서나 .m 파일에 위치 시켰습니까? – Maple

+0

다음 뷰로 이동하기 위해 무엇을 누르는가가 테이블 행을 눌렀을 때를위한 것이기 때문에 - (void) tableView : (UITableView *) tableView didSelectRowAtIndexPath : (NSIndexPath *) indexPath {' . 또한 필요에 따라'[factoryCategoryNameArray objectAtIndex : indexPath.row]'를 변경해야합니다. 그래서 controller.title = @ "새로운 제목은 여기에"; avc는 당신과 일치하지 않을 것이며, avc는 activityViewController입니다. 따라서 AVC가 무엇이든 일치하도록 변경하십시오. –

+0

@Maple은 이것을 배우기 위해 사용한 첫 번째 튜토리얼로 연결시켜줍니다. :] http://www.iosdevnotes.com/2011/03/uinavigationcontroller-tutorial/ –

관련 문제