app页面跳转和框架

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

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

<key>LSApplicationQueriesSchemes</key>
<array>
<!-- 微信 URL Scheme 白名单-->
<string>wechat</string>
<string>weixin</string>

<!-- 新浪微博 URL Scheme 白名单-->
<string>sinaweibohd</string>
<string>sinaweibo</string>

 <!-- 你自己定义的 URL Scheme 白名单-->
 <string>myAppScheme </string>

</array>

页面跳转

//页面跳转和传值
   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 <NSObject>
-(void)passValue:(NSString *)value;
@end

2:主页面实现委托和方法
委托:
@interface MainViewController : UIViewController  <passDataDelegate>
方法:
-(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<passDataDelegate> *delegate;

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


)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 172,967评论 25 708
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,196评论 4 61
  • 介绍 : JLRoutes是一个调用极少代码 , 可以很方便的处理不同URL schemes以及解析它们的参数,并...
    CoderLF阅读 1,652评论 0 3
  • ​ --20171012 题外话 断断续续接触过markd...
    Leng__阅读 436评论 0 0
  • 1993年左右,学校开设了计算机课。然而课堂内外都没有计算机。只有“0”“1”二进制的电路板,扳过来关过去。对一颗...
    自在兰舍阅读 296评论 2 3