Jopolaz
Jopolaz

Reputation: 412

Come back to app from an other app

Hello,

When we are phoning with us iphone and you left the call view to come back at springboard, we can come back to the call view with the status bar. (This picture can better explain : http://what-when-how.com/wp-content/uploads/2011/08/tmpB178_thumb.jpg)

Or, in the Facebook app when you go to the messenger Facebook app (not same app) we can touch status bar to comme back Facebook App too.

I would like to know if it's possible to make it in my app ? And if it's possible, how I will proceed ? (Edit: I want co come back in my app from another app such Youtube.)

Thanks

Upvotes: 2

Views: 1644

Answers (2)

HMHero
HMHero

Reputation: 2343

Once you become familiar with how to open another app within your current app form following link:

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

You can simply create a view that has tap gesture and use it as a button

- (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");
}

Edited:

After I posted the code above I kind of realized that there will be no tap gesture on the status bar even though other bottom part (20 pixel) of tapToReturnButton has a click gesture. After I did some research, I think following link has the better solution on click gesture. I will probably use tapToReturnButton as placeholder to let users know where to touch though and remove UITapGestureRecognizer *tap.

How to detect touches in status bar

Again, I think there is multiple way to achieve your need but those links above will give you good starting point.

Upvotes: 1

Related Questions