gpt4 book ai didi

cocoa - 调用按钮上的方法

转载 作者:行者123 更新时间:2023-12-03 17:26:10 25 4
gpt4 key购买 nike

在按钮“gobtn”上调用名为“inserttable”的方法是否正确,该方法是在应用程序委托(delegate)中声明的?

gobtn= [[UIButton alloc] initWithTitle:nil style:UIBarButtonItemStyleBordered target:self  action:@selector(inserttable:)];

最佳答案

所以我认为您希望此按钮调用 -(void)inserttable{} 这是一个委托(delegate)方法?

一种方法是

gobtn= [[UIButton alloc] initWithTitle:nil style:UIBarButtonItemStyleBordered target:self  action:@selector(inserttable)]; // without the colon if the method takes no parameters..

-(void)inserttable
{
//Do what stuff you want
.
.
[appdelegate inserttable];// or this if you intend on passing the buttons action to call
//inserttable of the appdelegate.
}

gobtn= [[UIButton alloc] initWithTitle:nil style:UIBarButtonItemStyleBordered target:adddelegate  action:@selector(inserttable)]; // without the colon if the method takes no parameters..

关于cocoa - 调用按钮上的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4525287/

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