Urlmanager official comments

Source: Internet
Author: User

URL scheme is the basic navigationcontroller, which enables loose coupling between viewcontroller and independent

 

Use

Urlmanager provides two navigationcontrollers, one webviewcontroller and one basic viewcontroller, which can be used separately or in combination.

Umviewcontroller

The basic viewcontroller of urlmanager. To use urlmanager, you must use umviewcontroller instead of uiviewcontroller as the base class.

Umviewcontroller can use URL initialization (as follows ). But it is generally not used directly, but through the factory method of navigationcontroller.

- (id)initWithURL:(NSURL *)aUrl;- (id)initWithURL:(NSURL *)aUrl query:(NSDictionary *)query;

The following method is triggered when a new viewcontroller is opened through a URL:

-(Bool) shouldopenviewcontrollerwithurl :( nsurl *) aurl; // whether to enable-(void) openedfromviewcontrollerwithurl :( nsurl *) aurl; // Where
Umnavigator

Umnavigator is a singleton object. It can monitor the viewcontroller currently displayed and use the URL management mechanism to replace the push and pop mechanisms of uinavigationcontroller.

Relationship between registered URL and viewcontroller
    [[UMNavigator sharedNavigator] setViewControllersForKeysFromDictionary:@{@"nava":navA,                                                                             @"navb":navB}];

Or

    [[UMNavigator sharedNavigator] setViewControllerName:@"UMDemoViewController"                                                  forURL:@"demo"];

Or

    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewControllerURL:                                    [[NSURL URLWithString:@"um://demo"]                                     addParams:[NSDictionary dictionaryWithObjectsAndKeys:                                                @"Demo1", @"title", nil]]];    [[UMNavigator sharedNavigator] setViewController:navC forURL:@"navc"];
Initialize umnavigationcontroller
UMNavigationController * umNav = [[UMNavigationController alloc]            initWithRootViewControllerURL:[[NSURL URLWithString:@"um://demo"]                                    addParams:[NSDictionary dictionaryWithObjectsAndKeys:                                                @"Demo", @"title", nil]]];[self.window addSubView:umNav.view];
Open a new viewcontroller
// Replace [self. navigationcontroller pushviewcontroller: animated:]; [[umnavigator sharednavigator] Openurl: [nsurl urlwithstring: @ "um: // demo? Title = nextdemo & Param = value "];
Call Openurl: the following method is triggered.

The following method is triggered in the caller controller. If yes is returned, the push effect is executed.

- (BOOL)shouldOpenViewControllerWithURL:(NSURL *)aUrl;

In the called viewcontroller, the following method is triggered:

- (void)openedFromViewControllerWithURL:(NSURL *)aUrl;
Umslidenavigationcontroller

Navigation bar, similar to sliding the path bar.

    UINavigationController * navA = [[UINavigationController alloc]                                    initWithRootViewController:[[UIViewController alloc] init]];    UMNavigationController * navB = [[UMNavigationController alloc]                                    initWithRootViewControllerURL:[NSURL urlWithString:@"um://demo"]];    self.navigator = [[UMDemoSlideNavViewController alloc] initWithItems:@[@[navA, navB], @[navA]]];

Two notifications will be sent when the slide on the sidebar is about to appear and disappears.

- (void)viewWillAppear:(BOOL)animated{    [super viewWillAppear:animated];    [[NSNotificationCenter defaultCenter] postNotificationName:UMNotificationWillShow object:nil];}- (void)viewDidDisappear:(BOOL)animated{    [super viewDidDisappear:animated];    [[NSNotificationCenter defaultCenter] postNotificationName:UMNotificationHidden object:nil];}

Umwebviewcontroller

When viewcontroller is managed by URL, umwebviewcontroller is automatically called if an http url is generated, and webview is loaded.

 

Project Link: https://github.com/gaosboy/URLManager

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.