iphone中的导航相关问题

时间:2013-01-09 14:06:01

标签: iphone

我正在一个屏幕(即firstScreen)中进行下一个屏幕(即secondFile)的安装。我的代码在firstFile.m中:

- (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

问题是打印了日志但是没有执行导航。拜托,你能告诉我上面的代码有什么问题。

2 个答案:

答案 0 :(得分: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);

}

希望它可以帮到你

答案 1 :(得分:0)

只需从 @“secondFile”中删除空格即可 secondFile* dest = [[secondFile alloc] initWithNibName:@" secondFile" bundle:nil];

如果问题仍然存在,如果您根本不需要navigationController,那么只需使用:

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