Xcode 从UIN按钮拨打电话号码
我把所有的问题都找遍了,似乎找不到答案 我有以下几点意见。这是崩溃,每次你点击的电话号码。我回到数据库,将电话号码格式化为5551235555,而不是(555)-123-5555Xcode 从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
- (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之后代码>并查看它在控制台中打印的内容。我觉得自己像个白痴。我一定是不小心在这一行设置了断点。去掉这个,一切都很好。我以为我疯了。