【发布时间】:2018-03-13 03:19:35
【问题描述】:
我有以下代码可以在应用内拨打电话。但是,每当我点击按钮时 - 什么都没有发生。有什么想法我可能做错了吗?
- (void)phonePressed:(id)sender
{
UIButton *btn = (UIButton* )sender;
NSString *key = [self.dictArray.allKeys objectAtIndex:btn.tag];
NSMutableArray *arrData = [self.dictArray objectForKey:key];
NSMutableDictionary *dict = [arrData objectAtIndex:btn.tag];
UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",[dict objectForKey:@"contact_phone"]]];
[application openURL:URL options:@{} completionHandler:^(BOOL success) {
if (success) {
NSLog(@"Opened url");
}
}];
}
【问题讨论】:
-
没有人知道 dictArray 是什么。
-
你能给我们看看你的dictArray吗??
-
如果您以编程方式添加了操作,则显示按钮选择器的代码;如果您使用故事板连接,则共享故事板按钮操作连接快照。
-
你能显示你要打开的网址吗? . ?
标签: ios objective-c uibutton ibaction