2013-01-09 68 views
0

我正在一個屏幕(即第一屏幕)到下一個屏幕(即第二個文件)中進行導航。我的代碼是在firstFile.m是:iphone中的導航相關問題

- (IBAction)onClick:(id)sender 
{ 

secondFile* dest = [[secondFile alloc] initWithNibName:@" secondFile" bundle:nil]; 
[self.navigationController pushViewController:dest animated:YES]; 


NSString* uname = txtUserName.text; 
NSLog(@"usr name is : %@",uname); 

} 

firstScreen.h

<UIKit/UIKit.h> 

@interface nevigationViewController : UIViewController 
@property (weak, nonatomic) IBOutlet UIButton *btnNevigation; 
@property (weak, nonatomic) IBOutlet UITextField *txtUserName; 
- (IBAction)onClick:(id)sender; 

@end 

問題是,日誌打印,但導航不執行。請你能告訴我上面的代碼有什麼問題嗎?

+0

是否正確初始化您的導航控制器? –

+0

請檢查你的導航是否初始化或不使用:NSLog(@「%d」,self.navigationController); –

+0

initWithNibName:@「secondFile」< - 查看空間。 – Bhavin

回答

0

只需從secondFile* dest = [[secondFile alloc] initWithNibName:@" secondFile" bundle:nil];

刪除空格@ 「secondFile」如果問題仍然生存,如果你不根本不需要navigationController,只需簡單地使用:

secondFile *nextView = [[secondFile alloc]initWithNibName:@"secondFile" bundle:nil]; 
    [self presentModalViewController:nextView animated:YES]; 
0

試試這個: -

- (IBAction)onClick:(id)sender 
{ 

secondFile* dest = [[secondFile alloc] initWithNibName:@"secondFile" bundle:nil]; 
[self.navigationController pushViewController:dest animated:YES]; 


NSString* uname = txtUserName.text; 
NSLog(@"usr name is : %@",uname); 

} 

希望它可以幫助你

+0

我刪除了空格。仍然沒有工作... – Kels

+0

嘗試presentModalViewController –

+0

thaks,我的問題是解決.... – Kels