0

我正在一个屏幕(即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);

}

第一屏.h

<UIKit/UIKit.h>

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

@end

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

4

2 回答 2

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);

}

希望对你有帮助

于 2013-01-09T14:12:41.397 回答
0

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

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

  secondFile *nextView = [[secondFile alloc]initWithNibName:@"secondFile" bundle:nil];
  [self presentModalViewController:nextView animated:YES];
于 2013-01-09T14:16:38.717 回答