Application not switches to Safari and not responding

88 views Asked by At

WorkGround

iPad - Landscap application.

OS Version - iOS 7.0.1

I have a UIButton which is added in UITableViewCell. On its tap it's suppose to open a URL in Safari.

NSURL *openURL = [NSURL URLWithString:@"http://google.com"];
    if ([[UIApplication sharedApplication] canOpenURL:openURL]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [[UIApplication sharedApplication] openURL:openURL];
        });
    }

Problem

It's not opening safari, it shows a black window with animation and returns to my application, than the application hangs. If I go in background and then open application, the application behaves like normal.

I do not understand the behavior. Why is it not switching to Safari app?

1

There are 1 answers

3
Rashad On BEST ANSWER

Just try this:

if ([[UIApplication sharedApplication] canOpenURL:openURL]) {
        [[UIApplication sharedApplication] openURL:openURL]
}

Hope this helps.. :)