gpt4 book ai didi

ios - 使用 shouldPerformSegueWithIdentifier 在 Controller 之间传递参数

转载 作者:行者123 更新时间:2023-11-28 19:52:28 26 4
gpt4 key购买 nike

我正在尝试执行 shouldPerformSegueWithIdentifier 并在 Controller 之间传递一些参数。

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {

if ([identifier isEqualToString:@"myid" ]) {
return NO;

}

mydestviewcontroller* my = [segue destinationviewcontroller];
my.stringtopass= data;



return YES;


}
}

我在 [segue destinationviewcontroller] 的 segue 上遇到错误相反,如果我使用 prepare for segue 它不会显示。我需要在 segue 发生之前执行一些检查,如果发生,我需要将参数传递给目标 Controller 。伙计们帮帮我!!

最佳答案

在 Controller 之间传递一些参数使用prepareForSegue

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

if([segue.identifer isEqualToString:"myId"]) {
mydestviewcontroller* my = [segue destinationViewController];
my.stringtopass= data;

}

关于ios - 使用 shouldPerformSegueWithIdentifier 在 Controller 之间传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28429962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com