【问题标题】:How to call AppDelegate when I push UIButton in View base当我在视图库中推送 UIButton 时如何调用 AppDelegate
【发布时间】:2013-01-21 07:33:51
【问题描述】:

当我推送 UIBotton 时,我想从另一个视图库调用 FrameMarkersAppdelegate。我该怎么办?

FrameMarkersAppdelegate.mm

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    window = [[UIWindow alloc] initWithFrame: screenBounds];
    [self setupSplashContinuation];
    [QCARutils getInstance].targetType = TYPE_FRAMEMARKERS;

    // Add the EAGLView and the overlay view to the window
    arParentViewController = [[ARParentViewController alloc] init];
    arParentViewController.arViewRect = screenBounds;
    [window insertSubview:arParentViewController.view atIndex:0];
    [window makeKeyAndVisible];
    return YES;
}

ViewController.m

-(IBAction)displaySelection:(id)sender 
{
       // How can I start FrameMarkersAppDelegate here?
}

【问题讨论】:

    标签: ios xcode methods call appdelegate


    【解决方案1】:
    FrameMarkersAppdelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    

    【讨论】:

    • 别忘了#import "FrameMarkersAppdelegate.h"
    • 以及如何使用appDelegate调用Delegate
    • 呼叫代表是什么意思?我假设您想在文件 FrameMarkersAppdelegate.m 中调用某些方法,对吗?如果是这种情况,上述答案(以及我建议的内容)几乎可以满足您的需求。
    【解决方案2】:

    虽然 sunkehappy 的回答几乎可以满足您的需求,但您可以通过将 appDelegate 设置为您的班级成员来节省一些处理时间。

    也就是说,app Delegate 是一个非常重要的类,可以让您的应用有许多共享实现。为了进一步节省您的执行时间,您可能还想尝试here

    【讨论】:

      猜你喜欢
      • 2015-05-23
      • 2017-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-08
      • 2014-05-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多