【问题标题】:call segue right when another segue ends当另一个 segue 结束时调用 segue
【发布时间】:2012-08-08 19:21:30
【问题描述】:

为什么不能在另一个 segue 结束时调用 segue?我想一定是我的代码错误或无法调用?

- (IBAction)optionTapped
{
    if (greeting)
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alerta!" message:@"something.." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
            [self performSegueWithIdentifier:@"firstSegue" sender:itemToSent];
            greeting = NO;
        }
    else
        {
            [self performSegueWithIdentifier:@"anotherSegue" sender:nil];
        }
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"anotherSegue"]) {
        UIViewController *viewController = segue.destinationViewController;
        OptionsViewController *controller = (OptionsViewController *)viewController;
        controller.delegate = self;
    } else if ([segue.identifier isEqualToString:@"firstSegue"]) {
        UINavigationController *navigationController = segue.destinationViewController;
        CCGetViewController *controller = (CCGetViewController *)navigationController.topViewController;
        controller.delegate = self;
        controller.itemToSent = sender;
    }

- (void)firstSegueViewController:(CCGetViewController *)controller didFinishAddItem:(InfoListItems *)item
{
    itemToSent = item;
    [self dismissViewControllerAnimated:YES completion:nil];
    if (scanTap) {
        [self scanTapped];
    } else if(infoTap){
        [self optionTapped];
    }
}

还有一件事:“firstSegue”被嵌入到 NavigationController 中,“anotherSegue”只是一个视图控制器。

【问题讨论】:

    标签: objective-c storyboard segue uistoryboardsegue


    【解决方案1】:

    我尝试不断移动 segue,但我也失败了。

    所以我尝试将第一个 segue 和第二个 segue 之间的间隔设置为一秒。

    这很好用!当你在红色窗口中按下按钮时,会出现绿色窗口,之后会自动出现蓝色窗口。

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        [self performSelector:@selector(segue) withObject:nil afterDelay:1.0];
    }
    
    - (void)segue
    {
        [self performSegueWithIdentifier:@"toBlue" sender:self];
    }
    

    您可以下载示例项目并运行它:

    https://github.com/weed/p120812_DoubleSegue

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-15
      • 1970-01-01
      • 2018-06-17
      • 2016-09-20
      • 1970-01-01
      • 1970-01-01
      • 2019-06-16
      • 1970-01-01
      相关资源
      最近更新 更多