Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 views
in Technique[技术] by (71.8m points)

ios9 - CNContactViewController forUnknownContact unusable, destroys interface

[Appears to be fixed in iOS 10!] So what follows applies to iOS 9 only...


I have been experimenting with Apple's new Contacts framework, and I've found a huge bug in one of the three forms of CNContactViewController. It destroys the surrounding interface so that your app becomes useless; the user is stuck.

To make this bug easy to see, I've posted an example project at https://github.com/mattneub/CNContactViewControllerBug.

To experiment, run the project and do the following steps:

  1. Tap the button (Unknown Person).

  2. Grant access if requested.

  3. You are shown the partial contact, in our navigation interface (note the Back button at the top).

  4. Tap Add to Existing Contact. The contact picker appears.

  5. Tap Cancel. It doesn't actually matter what you do from here, but tapping Cancel is simplest and is the fastest way to reach the bug.

  6. We are now back at the partial contact, but the navigation interface is gone. The user has no way to escape from this interface. The app is hosed.

Just to clarify, here are screenshots of the steps you need to take:

enter image description here

Tap Add to Existing Contact to see this:

enter image description here

Tap Cancel to see this; observe that it is the same as the first screen shot, but the navigation bar is gone:

enter image description here

I've tried many ways to work around this bug, but there seems to be no way. As far as I can tell, this window is being presented by the framework "out-of-process" and is not part of your app. You can't get rid of it.

So what's the question? I guess it's this: can anyone show me a way to make this view controller (in this form) usable? Is there a workaround I haven't found?

EDIT This bug appeared in iOS 9.0 and is still present in iOS 9.1. In a comment, @SergeySkopus reports that switching to the deprecated Address Book framework doesn't help; the bug is in the underlying structure somewhere.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I've hidden the UINavigationController method for show or hide the navigation bar by using categories:

@interface UINavigationController (contacts)
@end

@implementation UINavigationController (contacts)

- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated {
    NSLog(@"Hide: %d", hidden);
}
@end

This way the CNContactViewController cannot make the navigation bar to disappear. Setting a breakpoint on NSLog I discovered that this method is called by the private [CNContactViewController isPresentingFullscreen:].

By checking if the self.topViewController of the navigation controller is kind of class CNContactViewController you could decide if hiding or not the navigation bar.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...