0
嗨我目前正在为客户的项目工作,我需要访问电话联系人。在ButtonAction上访问联系人并执行Segue
我设法要求允许访问联系人,我处理两种不同的状态(授予,拒绝)。 显然,客户希望下面的工作流程:
- 创下添加按钮
- 要求允许
- 授予: 执行SEGUE与上市
- 否认所有接触tablewview:执行顺着接下去一个不同的观点,并不断询问初始按钮命中授予访问联系人
我管理完整的流程,并提取了c完整的数据。没有I M卡有两个问题:
- 我不能得到申请许可alertview再次弹出的(从 我了解用户需要设置这在应用程序 设置 - >应用隐私设置)。它是否正确?
- 看来,如果访问被授予第一次,我 执行segue tableview是空的,因为数据数组是无 (我不明白为什么)。
- (void)addButtonTouched { [self.addressBook accessAddressBook]; [self.activityView startActivityViewWithMessage:@"Wait a second"]; if (access) { self.contactsArray = [self.addressBook getAllContacts]; if (self.contactsArray.count != 0) { [self performSegueWithIdentifier:@"addEntrySegue" sender:self]; } else { [self performSegueWithIdentifier:@"noContactsSegue" sender:self]; } }
我是不是推动尽快到下一个视图控制器来填补self.contactsArray
?
我的另一种方法是在授予访问权限后向我的rootViewController发送Notificaion,然后执行segue。这是我能得到的最接近的结果,但ViewController推迟了8-10秒。
> - (void)receivedNotification:(NSNotification *)notification {
> if (access) {
> self.contactsArray = [self.addressBook getAllContacts];
> if (self.contactsArray.count != 0) {
> [self performSegueWithIdentifier:@"addEntryrSegue" sender:self];
> } else {
> [self performSegueWithIdentifier:@"noContactsSegue" sender:self];
> }
> }
> }
在此先感谢。我希望我解释得很好。