1

私は少しこの問題を解決していますが、何もできません。 私は主にストーリーボードに立っているビューコントローラを持っています。そのビューコントローラ内で、アクションに接触型を渡す特定のアクションが発生したとき。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) 

おかげ

+0

で試すことができますか? –

+0

完了する前に、ナビゲーションバーを表示していないので、私は他にもキャンセルするための別の方法が必要です。 – shuson

答えて

1

あなたは、このコードの前に、ナビゲーションやが表示されないdidcomplete後

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 unkvc = CNContactViewController(forUnknownContact: con) 

           unkvc.delegate = self 
           unkvc.allowsEditing = true 
           unkvc.allowsActions = true 
           unkvc.title = "Edit Contact" 

    self.navigationController?.isNavigationBarHidden = false 

    self.navigationController?.navigationItem.hidesBackButton = true 

    self.navigationController?.pushViewController(unkvc, animated: false) 
+0

それは動作しませんでした。新しいコントローラを開けません。 – shuson

+0

編集された回答を参照してください。 – shuson

+0

ありがとう!私の問題は、現在のnavigationControllerのために隠されたNavigationBarにあった – moonvader

関連する問題