如何使一个电话与按下一个按钮- XCode



我想知道是否有可能创建一个按钮,在按下时调用某个数字(000)?

请把一切都写下来,因为我是新手。

我所说的一切是指我应该在头文件和实现文件中放入的内容。

使用说明:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAnimated: animated];
    UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
    button.frame = (CGRect){100,100,100,100};
    [button addTarget: self action: @selector(makeCall:) forControlEvents: UIControlEventTouchDown];
    [self.view addSubview: button];
}
- (void)makeCall:(id)sender
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"tel://000]];
}

最新更新