1

I have an IOS App that can open a specific type of documents.

My App receives the document through:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

when it was not yet started or through

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 

when the App was already started.

When my App is already started the user may have already opened many views in my App. Next when my App is triggered to open the document, how can I open and navigate to the right view (closing the old hierarchy and open the new one to display the document)?

I have tried to use:

- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

with fromViewController = the rootViewController (retrieved using UIApplication & UIWindow) and the toViewController: the ViewController I need to display the document but without success.

Any ideas how to progress on this topic? Thanks,

Sébastien.

user523234
  • 14,323
  • 10
  • 62
  • 102
sebastien
  • 2,489
  • 5
  • 26
  • 47

1 Answers1

0

There isnt a quick answer to this question I faced your same problem, where i had a ReaderViewController that reads the documents I had a MainViewController that pushed the ReaderViewController as a modal controller

In my situation when the user opened an external document, i would do the following • pop the existing view controller • read the url, copy the file • open the document • present a new ReaderViewController with the new document

And that did it for me, But i dont think there will be an exact solution to be implemented in each case of openURL I think you should work on your view hierarchy more and study your own situation to see what views you should pop or dismiss and what views you should push or present

Omar Abdelhafith
  • 21,163
  • 5
  • 52
  • 56
  • Thank for the feedback. My issue is that in my App the User can have follow different paths of View hierarchy (with different depths) and so I'm not clear how to pop these views. I'm not looking for an exact solution but for a direction to investigate. You are probably right, I need to study in more details my view hierarchy to see what I need to do. – sebastien Jun 02 '12 at 14:33
  • One way to look at it, is to draw a workflow of views addition, and then trace back all your action that lead you to the point you are, what i did when i faced this problem, is i wrote on a paper what may happens in a workflow diagram, draw all or atleast most of the cases that may happen, then try to think of how you could do the easiest solution to cascade back to the original view, having said that, if you think this question helped you please consider to accept the answer and/or upvote so others could find it faster :) – Omar Abdelhafith Jun 02 '12 at 14:36