【问题标题】:Xcode-perform Segue in main view controller from action in popoverXcode-perform Segue 在主视图控制器中从弹出窗口中的操作
【发布时间】:2014-09-10 18:36:49
【问题描述】:

我正在创建一个需要登录或注册的 an。目前,登录和注册都是在主注销屏幕上的弹出视图中执行的。

因此,我需要触发一个 segue,以便在与我的弹出视图控制器不同的视图控制器中执行。这如何和/或这可能?

这是我在“registerViewController”(弹出视图)中的注册码,我想执行从“loggedOutViewController”到“mainViewController”(登录视图)的转换。

registerViewController.m:

- (void) registerNewUser {

PFUser *newUser = [PFUser user];
newUser.email = _emailField.text;
newUser.username = _usernameField.text;
newUser.password= _passwordField.text;
newUser[@"name"] = _nameField.text;

[newUser signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (!error) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"Registration Successful" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];

        //Where I need to call the segue

    } else {
        NSString *errorString = [error userInfo][@"error"];
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Oops" message:errorString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
    }
}];

抱歉,如果有人问过这个问题,我无法在任何地方找到解决问题的方法,如果您想/需要更多信息或代码,请告诉我。

【问题讨论】:

  • 请显示有问题的代码。没有代码,没有讨论。 ;)
  • 代码本身并没有真正的问题,因为我不知道如何去做。我会看看我可以发布什么。

标签: objective-c xcode ipad segue popover


【解决方案1】:

很难确切地知道您想要的行为是什么。这是一种方法:

// Display settings view
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SettingsVC *report = [storyboard instantiateViewControllerWithIdentifier:@"SettingsViewController"];
[self presentViewController:report animated:YES completion:nil];

用您自己的替换故事板和所需的视图控制器名称。此外,通过将 SettingsVC 替换为所需视图控制器的名称来确保您的视图控制器是正确的。

【讨论】:

  • 谢谢,您提供的代码很好地回答了我的问题。您的代码描述的行为几乎完全符合我的理想行为。我真的应该能够解决这个问题,但我很挣扎。谢谢!
  • 不用担心,很高兴它有帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-10-13
  • 1970-01-01
  • 2023-03-31
  • 2021-06-24
  • 1970-01-01
  • 1970-01-01
  • 2019-06-09
相关资源
最近更新 更多