app页面跳转和框架

第三方框架:JLRoutes
该框架写得很详细,跳转、跳转传参数、跳到对应的界面等等,使用很方便!(如果你是刚入门iOS的话,建议不要使用,还是多写点代码!对你有好处,不要做拿来主义!)

-- 注意:有些朋友跟着复制进去都不能正常跳转,那是因为你还没额外添加“白名单”:

LSApplicationQueriesSchemes


wechat
weixin


sinaweibohd
sinaweibo

 
 myAppScheme 


页面跳转

//页面跳转和传值
   self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
    NSLog(@"%@",[[UIScreen mainScreen] bounds]);
    self.window.backgroundColor = [UIColor redColor];
    self.vc = [[BaseTableViewController alloc] initWithNibName:@"BaseTableViewController" bundle:nil];
    self.window.rootViewController = self.vc;
    [self.window makeKeyAndVisible];


//故事板跳转
UIStoryboard *story = [UIStoryboard storyboardWithName:@"填写故事板名称" bundle:nil];
UIViewController *vc = [story instantiateViewControllerWithIdentifier:@"填写ViewController在故事板中设置的identifier"];
[self.navigationController pushViewController:vc animated:YES]; 
//UINavigationController使用
 ViewController1 *rootVC = [[ViewController1 alloc]initWithNibName:@"ViewController1" bundle:nil];
 UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:rootVC];
 self.window.rootViewController = navigationController;

通知传值


 //modal视图跳转 --附带数据传输
 //jump 
 ------------------------------------------------------------------------------------------------------------------------------
UIViewController *vc = [UIViewController alloc]init];
UINavigationController *navc = [[UINavigationController alloc]initWithRootViewController:vc];
[self.navigationController presentViewController:navc animated:YES completion:^{
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(backValue:) name:@"postback" object:nil];
    
}];


- (void)backValue:(NSNotification *)notif {
    NSLog(@"%@",notif.userInfo);
    NSLog(@"%@",notif.object);
}

//jump back!
- (IBAction)goback:(id)sender {
    
    [self dismissViewControllerAnimated:(YES) completion:^(void){
        //NSLog(@"dismiss");
        //回传值
        NSDictionary *dict = [NSDictionary dictionaryWithObject:@"liuyanwei" forKey:@"name"];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"postback" object:nil userInfo:dict];
    }];
}

委托传值


1:先定义委托
//绑定数据回叫委托
@protocol passDataDelegate 
-(void)passValue:(NSString *)value;
@end

2:主页面实现委托和方法
委托:
@interface MainViewController : UIViewController  
方法:
-(void)passValue:(NSString *)value{
    NSLog(@"%@",value);
}  

3:主页面跳转到获取值的页面
//页面跳转
FetchValueViewController *vc =  [[FetchValueViewController alloc]init];
vc.passDataDelegate = self;
[self.navigationController presentViewController:vc animated:YES completion:nil];


4:FetchValueViewController.h添加一个委托的属性
@property (nonatomic,assign) NSObject *delegate;

5:FetchValueViewController.m将值回传
[delegate passValue:@"回传的值"];
 调用过这个方法后,会进入到MainViewController委托的实现方法passValue里。


)

你可能感兴趣的:(app页面跳转和框架)