Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 从UIN按钮拨打电话号码_Xcode_Ios5_Uiapplication - Fatal编程技术网

Xcode 从UIN按钮拨打电话号码

Xcode 从UIN按钮拨打电话号码,xcode,ios5,uiapplication,Xcode,Ios5,Uiapplication,我把所有的问题都找遍了,似乎找不到答案 我有以下几点意见。这是崩溃,每次你点击的电话号码。我回到数据库,将电话号码格式化为5551235555,而不是(555)-123-5555 - (IBAction)callPhone:(UIButton *)sender{ Bar *items = self.detailItem; NSURL *pn = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", items.ba

我把所有的问题都找遍了,似乎找不到答案

我有以下几点意见。这是崩溃,每次你点击的电话号码。我回到数据库,将电话号码格式化为5551235555,而不是(555)-123-5555

- (IBAction)callPhone:(UIButton *)sender{

    Bar *items = self.detailItem;
    NSURL *pn = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", items.barPhone]];
    [[UIApplication sharedApplication] openURL:pn];
}

- (void)setCallButton:(UIButton *)callButton{

    Bar *items = self.detailItem;
    [callButton setTitle:items.barPhone
                forState:UIControlStateNormal];
}

任何代码指导都将是可取的。

Bar*items=self.detailItem未启动,因此它返回nil。请尝试以下操作:

Bar *items = [[Bar alloc] init];
items = self.detailItem;

或者,您应该做的是将
作为此特定类的ivar。然后您可以启动
一次,并在整个课程中使用它。

堆栈跟踪是什么?你确定
items.barPhone
不是零吗?是的,我检查了它显示的号码。我在上面添加的setTitle也可以很好地工作。然而,“pn”显示为零。很明显,为什么它不工作,但不确定为什么它为零。没有错误消息,只是(lldb)项目没有问题,所有内容都正确读取。此信息是来自TableView的一段。创建“pn”似乎有问题。它为零,但
项。barPhone
具有正确的值。pn为零。试试我上面描述的。如果
items.barPhone
不为零,则pn不为零。
items.barPhone
不为零或无法正确设置按钮标题。我尝试了你的代码,假设
应该是
。我得到相同的breakkay,尝试添加
NSLog(@“Bar Item:%@”,self.detailItem)直接在
Bar*items=self.detailItem之后并查看它在控制台中打印的内容。我觉得自己像个白痴。我一定是不小心在这一行设置了断点。去掉这个,一切都很好。我以为我疯了。