gpt4 book ai didi

objective-c - 如何发送 swift 选择器引用到 Objective C 属性

转载 作者:行者123 更新时间:2023-11-30 13:31:32 25 4
gpt4 key购买 nike

我在 objective-c 类中有属性@property(非原子,分配)SEL buttonSelector,它有按钮来显示东西

- (void)setUpBarButton:(id)vc {
UIBarButtonItem * optionsItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Options"] style:UIBarButtonItemStylePlain target:vc action:buttonSelector];
optionsBarItem.imageInsets = UIEdgeInsetsMake(0.0, 2.0, 0.0, 2.0);

self.navigationItem.rightBarButtonItems = @[self.optionsItem];
}

因此,从 swift 类中,我使用上述方法,因此我必须从 swift 类发送选择器引用

self.buttonSelector= #selector(tapbutton:)

但它给出了一个错误

最佳答案

你的代码有很多错误。共有三个按钮变量:

optionsItem
self.optionsItem
optionsBarItem

为什么还要有一个选择器变量?只需处理选择器中的任何不同情况即可!

关于objective-c - 如何发送 swift 选择器引用到 Objective C 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36527751/

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