2012-01-03 3 views
1
- (void)applicationDidFinishLaunching:(UIApplication *)application { 
    NSError *error = nil; 
    NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:@"username"]; 
    NSString *str = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:@"mybibleapp" error:&error]; 
    NSLog(@"previous un"); 
    NSLog(@"%@", str); 
    if(str != nil) 
    { 
     main_page *detailViewController = [[main_page alloc] initWithNibName:@"main_page" bundle:nil]; 
     // Pass the selected object to the new view controller. 
     // detailViewController.localStringtextnote = localStringtextnote; 
     [self.navigationController pushViewController:detailViewController animated:YES]; 
     [detailViewController release]; 
    } 

property navigationController not found on object of appdelegate 그래서 난이 코드는 페이지가 main_page로 리디렉션됩니다 위의AppDelegate에 탐색 내가 main_page 페이지로 이동이 코드를 삽입 오류

main_page *log = [[main_page alloc] initWithNibName:@"main_page" bundle:nil]; 
[window addSubview:tabController.view]; 
[window addSubview:log.view]; 
[window makeKeyAndVisible]; 

의 insted 넣어 오류를 표시하지만 아무것도 작동하지 않습니다 이런 식으로. main_page의 탐색 기능이 작동하지 않습니다. main_page에서 페이지를 리디렉션 할 수 없습니다. 그렇다면 이러한 오류를 해결하기 위해 무엇을 할 수 있을까요?

답변

1

당신은 프록시의있는 viewDidLoad에서, MainWindow를의있는 navigationController에로드 한 후 다음과 같은 일을한다 펜촉없이 "프록시"의 ViewController를 만들 수 있습니다

NSError *error = nil; 
NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:@"username"]; 
NSString *str = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:@"mybibleapp" error:&error]; 
NSLog(@"previous un"); 

NSLog(@"%@", str); 

UIViewController *controller; 

if (!error && nil != str) { 
    controller = [[DetailViewController alloc] init]; 
} else { 
    controller = [[LoginViewController alloc] init]; 
} 
[[self navigationController] pushViewController:controller animated:YES]; 
[controller release]; 
+0

선생님은 무엇을 의미하는 프록시입니까? 나는 tabbar 응용 프로그램을하고 있어요, 사실 첫 번째 tabbarview는 두 번째 페이지입니다. tabbarview는 mainpage입니다. 그래서 사용자 alredy가 로그인 페이지가 아닌 mainpage를 표시해야하는 경우 원합니다. 로그인 페이지 표시 – stackiphone

+0

죄송합니다. 프록시 란 "중개자"를 의미합니다. UIViewController는 창을 어지럽히 지 않고 문제를 처리하거나이 문제를 처리합니다. – ferostar

+0

ok, chk .thanks – stackiphone

0

초기 페이지로드는 일반적으로 MainWindow.xib 펜촉에서 처리됩니다. 수동으로로드하지 않아도됩니다.

템플릿에서 새 프로젝트를 만든 다음 appDelegate 및 MainWindow.xib의 설정 방법을 살펴보십시오.

+0

그래서이 탐색 problm을 handile 할 수있는 방법이 무엇입니까? – stackiphone

+0

첫 번째보기 컨트롤러의 viewDidLoad 섹션에서보기 컨트롤러 설정을 수행해야합니다. ferostar와 같은 것이 좋습니다. AppDelegate에 탐색 컨트롤러가 없기 때문에 오류가 발생하는 이유는 self.navigationController를 호출 할 때 오류가 발생하기 때문입니다. – Dancreek

관련 문제