gpt4 book ai didi

cocoa-touch - iOS - 如何检测哪个按钮触发了 segue,以及如何根据按钮显示其内容

转载 作者:行者123 更新时间:2023-12-02 00:11:43 24 4
gpt4 key购买 nike

我的问题是我有一个内部有不同按钮的 View :所有按钮都连接到同一个 segue(这是出于特定原因,我知道制作不同的 segue 会更容易,但这正是我需要的现在)。

我如何检测哪个按钮启动了我的新转场,以及如何根据该决定更改新转场上的数据? (例如,我的新 segue 在 imageview 中,它应该为每个按钮加载不同的图像)

最佳答案

在方法 -prepareForSegue:sender: 中,在 sender 参数中,您有一个对启动 segue 的控件的引用,例如:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"yourIdentifier"]) {
UIButton *senderButton = (UIButton *)sender;
// do what ever you need with the button and segue
}
}

关于cocoa-touch - iOS - 如何检测哪个按钮触发了 segue,以及如何根据按钮显示其内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14932162/

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