0

我有一个问题,我WSLogin从我的Loginviewcontroller. 它成功返回了我的用户sessionId。然后我将此sessionId存储到字符串中并将此值发送到Searchviewcontroller但未成功将值提交到Searchviewcontroller.

当我成功登录时,我Searchviewcontroller通过标签栏控制器移动到。NSLog我在成功登录后searchviewcontroller单击时生成检查会话的值,然后返回给我,请告诉我如何解决这个问题?searchtabbarNSLog session id = null

这是代码

// LoginViewController.m file 
-(IBAction)Login:(id)sender
{
    wsobject = [[WSLogin alloc] init];
    sessId = wsobject.sessionId;
    NSLog(@"sessionidd = %@",sessId);
// it successfully return session id 
}

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

    SearchViewController *afc = (SearchViewController *) segue.destinationViewController;
    afc.sessionId = sessId;
// i have create sessionId property in SearchViewController 
}
// SearhViewController.m file 
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"sessionId = %@",sessionId);
//printing sessionId value but getting Null here when click on Searhtabbar
}
4

1 回答 1

0

我假设您已经为它进行了 segues,并且在身份检查器中给它起了一个名字,比如“goToNextView”。现在将以下代码放在您要跳转到下一个视图控制器的位置

-(IBAction)methodName:(id)sender
{
    [self performSegueWithIdentifier:@"goToNextView" sender:self];
}

然后在您的代码中修改为这样的 segue 委托方法做准备

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
            if ([segue.identifier isEqualToString:@"goToNextView"]) {
         DestinatonViewController *controller = segue.destinationViewController
        // set the properties value you want for destination View Controller
                controller.propertyName = yourValue;

希望这会有所帮助..

于 2013-06-16T05:47:02.263 回答