您好,

当我们与iphone打电话时,您离开了 call 视图以回到跳板时,我们可以使用状态栏返回到 call 视图。 (此图片可以更好地解释:http://what-when-how.com/wp-content/uploads/2011/08/tmpB178_thumb.jpg)

或者,在Facebook应用程序中,当您转到Messenger Messenger应用程序(不是同一应用程序)时,我们也可以触摸状态栏以返回Facebook应用程序。

我想知道是否可以在我的应用程序中制作它吗?如果可能,我将如何进行? (编辑:我希望合作伙伴从另一个应用程序(例如Youtube)返回我的应用程序。)

谢谢

最佳答案

一旦您熟悉了如何在当前应用程序表单中打开另一个应用程序,请执行以下链接:

http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

您可以简单地创建具有点击手势的视图并将其用作按钮

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.navigationController setNavigationBarHidden:YES];

    UIView *tapToReturnButton = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
    tapToReturnButton.backgroundColor = [UIColor blueColor];

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
                                                                      action:@selector(tapToReturnButtonClicked)];
    [tap setNumberOfTouchesRequired:1];
    [tapToReturnButton addGestureRecognizer:tap];

    UILabel *tapToReturnLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, 20)];
    tapToReturnLabel.text = @"Tap to return";
    tapToReturnLabel.textColor = [UIColor whiteColor];
    tapToReturnLabel.textAlignment = NSTextAlignmentCenter;
    tapToReturnLabel.font = [UIFont fontWithName:@"ArialMT"
                                        size:14];

    [tapToReturnButton addSubview:tapToReturnLabel];
    [self.view addSubview:tapToReturnButton];
}


- (void)tapToReturnButtonClicked
{
    NSLog(@"Now you add your code that opens another app(URL) here");
}

编辑:

在上面的代码发布后,我有点意识到即使tapToReturnButton的其他底部(20像素)具有点击手势,状态栏上也不会出现点击手势。经过研究,我认为以下链接在点击手势方面有更好的解决方案。我可能会使用tapToReturnButton作为占位符,以使用户知道要触摸的位置并删除UITapGestureRecognizer * tap。

How to detect touches in status bar

同样,我认为有多种方法可以满足您的需求,但以上那些链接将为您提供一个良好的起点。

关于ios - 从其他应用回到应用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23458248/

10-09 16:33
查看更多