【问题标题】:how to call a method directly instead of button action如何直接调用方法而不是按钮操作
【发布时间】:2011-11-24 12:28:23
【问题描述】:

我想直接在应用程序didFinishLaunchingWithOptions调用下面的方法。

目前这个动作是通过一个按钮触发的。没有按钮我怎么称呼它?

- (IBAction)toggleVertical:(id)sender
{
    [splitController toggleSplitOrientation:self];
    [self configureView];
}

【问题讨论】:

  • 嗯...通过调用它...

标签: objective-c methods action sender


【解决方案1】:

只需调用它

[self toggleVertical:nil];  

如果方法使用了 sender 参数,你必须把你的 UIButton 的引用放在里面:

[self toggleVertical:self.myButton];  

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-08
    相关资源
    最近更新 更多