xml地图|网站地图|网站标签 [设为首页] [加入收藏]

IOS -获取当前视图的Controller

收获当前视图的TopViewController

 AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    UIViewController* topViewController = appdelegate.baseTabBarController.navigationController.topViewController;
    NSLog(@"%@",topViewController);
     if ([topViewController isKindOfClass:[ HomeViewController class]]) {
     }

modalTransitionStyle

赢妥帖前视图的RootViewController(Nav等第)

-(UIViewController *)getCurrentRootViewController {


    UIViewController *result;


    // Try to find the root view controller programmically


    // Find the top window (that is not an alert view or other window)


    UIWindow *topWindow = [[UIApplication sharedApplication] keyWindow];


    if (topWindow.windowLevel != UIWindowLevelNormal)


    {


        NSArray *windows = [[UIApplication sharedApplication] windows];


        for(topWindow in windows)


        {


            if (topWindow.windowLevel == UIWindowLevelNormal)


                break;


        }


    }


    UIView *rootView = [[topWindow subviews] objectAtIndex:0];


    id nextResponder = [rootView nextResponder];


    if ([nextResponder isKindOfClass:[UIViewController class]])


        result = nextResponder;


    else if ([topWindow respondsToSelector:@selector(rootViewController)] && topWindow.rootViewController != nil)


        result = topWindow.rootViewController;


    else


        NSAssert(NO, @"ShareKit: Could not find a root view controller.  You can assign one manually by calling [[SHK currentHelper] setRootViewController:YOURROOTVIEWCONTROLLER].");


    return result;


}

-获取当前视图的Controller 获取当前视图的TopViewController AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; UIViewController*...

那篇知识很要紧,最棒全明白:

IOS -获取当前视图的Controller

     例子:UIViewController便是二个相框,而UIView正是一个相片

      - (void)dismissViewControllerAnimated:(BOOL)flag 

   4.UIViewController和UIView的关系  

  1: newCtl.deliverStr = label.text;

 

   1.分割效能到不相同的Controller页面上

传值一方:坚决守住左券

 

VA <— VB

NewViewController *newCtl = [NewViewController new];

2:@property (nonatomic,copy)blockType block;

    UILabel *label = (UILabel *)[self.view viewWithTag:100];

=========================

if ([_delegate respondsToSelector:@selector(showInfo:)]) {

        [_delegate showInfo:label.text];
    }  

    //代理:能成就这一个职务的对象

    //左券代理

 

 

传值一方

VA —> VB

例如RootViewController.m里传值

传值一方:

UIViewController的生命周期

协商代理传值方法

 

+ (UIApplication *)sharedApplication 传值一方

UILabel *label = (UILabel *)[self.view viewWithTag:100];



    //先给AppDelgate的中转变量进行赋值



    //1.获取UIAplication对象

    //2.获取AppDelgate对象

    //3.赋值

    UIApplication *app = [UIApplication sharedApplication];

    AppDelegate *del = app.delegate;

    del.middleStr = label.text;

     从数据库或然互联网加载模型数据装配到子视图中

    //设置调控器自带View的背景观(私下认可无背景象)

 

    ctl.view.alpha = 0.5;

@property (nonatomic,weak)id<Myprotocol> delegate;//指向代理对象

    //设置根视图调整器

 

    /*

 

MVC设计格局:Model模型 View视图 Controller调整器

     参数2:是或不是要求动漫

    

 

     1)UIViewController是视图调节器,而UIView是视图,也正是说UIViewController调节UIView 

.m文件里:

   3.UIViewController对象默许都会有三个自带的view

UIModalTransitionStyleCrossDissolve      渐变

 

     1.正向传值

    

     日常大家会在这里边做界面上的做一些额外操作,譬如往view中增多一些子视图、

知识点:

 

   1.MVC设计形式

   4.viewDidLoad作用

       而照片却不能调控相框 

 

    

=========================

//设置切换的动漫片效果

#import <Foundation/Foundation.h>

@protocol Myprotocol <NSObject>

//代理需要完成的任务

-(void)showInfo:(NSString *)info;

@end

 

 

=========================

   7.viewDidAppear函数

 

3.UIViewController生命周期

 

收获值一方:

 

 

NewViewController *newCtl = [NewViewController new];

   8.viewWillDisappear函数

UIViewController之间的切换

 

@property (nonatomic,copy)NSString *middleStr;

 

        label.text = text;      

       2)获取当前选择的AppDelegate对象:

     */

   9.viewDidDisappear函数

 

        completion:(void (^)(void))completion

    

   5.viewDidLoad曾几何时被调用

 

   

    //每三个调整器上,都自带了三个UIView

 

       @property(nonatomic,assign) id<UIApplicationDelegate> delegate;

//切换成新的调控器

     2)关闭当前视图调节器

   6.viewWillAppear函数

    //设置代理:找到能何况获得到代办和被代理对象的任务

    self.window.rootViewController = rootCtl;

本文由永利澳门平台发布于计算机资讯,转载请注明出处:IOS -获取当前视图的Controller

您可能还会对下面的文章感兴趣: