私は少しこの問題を解決していますが、何もできません。 私は主にストーリーボードに立っているビューコントローラを持っています。そのビューコントローラ内で、アクションに接触型を渡す特定のアクションが発生したとき。IOS Swift CNContactViewControllerナビゲーションバーにUINavigation Controllerが表示されない
アクションは、渡された連絡先の新しい連絡先ビューコントローラーを開き、ユーザーがCNContactViewControllerごとに連絡先と対話できるようにします。 didCompleteWithメソッドのためにユーザーが連絡先を終了すると、ユーザーは終了しますが、実際に連絡先を作成せずに連絡先コントローラーを終了する方法はありません。
//change to new contact screen
let con = CNMutableContact()
con.givenName = familyComponents[0]
con.familyName = familyComponents[1]
let newEmail = CNLabeledValue(label: "Personal", value: objectComponents[2]
as NSString)
con.emailAddresses.append(newEmail)
con.phoneNumbers.append(CNLabeledValue(
label: "Home", value: CNPhoneNumber(stringValue: objectComponents[3])))
let newScreen = CNContactViewController(forUnknownContact: con)
newScreen.message = "Made using app"
newScreen.contactStore = CNContactStore()
newScreen.delegate = self
newScreen.allowsActions = true
let navigationController = UINavigationController(rootViewController:
newScreen)
self.present(navigationController, animated: true, completion: nil)
私はnavigationItemsからnavigationItemsにすべてを試してみました、このコード行でその半透明性を変更することが可能であるため、ナビゲーションバーがあるように私には思える:以下
navigationController.navigationBar.isTranslucent = true
方法:
func contactViewController(_ viewController: CNContactViewController,
didCompleteWith contact: CNContact?) {
viewController.dismiss(animated: true, completion: nil)
inContact = false
}
func contactViewController(_ shouldPerformDefaultActionForviewController:
CNContactViewController, shouldPerformDefaultActionFor property:
CNContactProperty) -> Bool {
return false
}
私はこの問題をあまりにも長く苦労しています。 ありがとう!
解決: これは機能しています。これはリンゴのフレームワークのバグだと分かります。この問題を解決するために、私は不明な連絡先から新しい連絡先に切り替えました。これは明らかにこのバグはありません。新しいコードの パート:
let newScreen = CNContactViewController(forNewContact: con)
newScreen.delegate = self
let navigationController = UINavigationController(rootViewController: newScreen)
self.present(navigationController, animated: true, completion: nil)
おかげ
で試すことができますか? –
完了する前に、ナビゲーションバーを表示していないので、私は他にもキャンセルするための別の方法が必要です。 – shuson