Skip to content

Does not work on iOS 8 App Extension - 2 Errors #101

@Supertecnoboff

Description

@Supertecnoboff

Hi @dogo

I have two errors with this awesome app. One of them I managed to resolve, but the other I have not be able to solve. I am trying to implement SCLAlertView in an iOS 8 Extension (Widget).

The first error I got is in the SCLAlertView.m file in the viewWillLayoutSubviews method. There is a bit of code which determines if the app is in landscape, it doesn't work on an iOS 8 Extension, because UIApplication sharedApplication is not available.

So this is what I did to fix it:

if (SYSTEM_VERSION_LESS_THAN(@"8.0"))
    {
        if (self.view.frame.size.width > self.view.frame.size.height) {
            NSLog(@"Landscape");

            CGSize ssz = sz;
            sz = CGSizeMake(ssz.height, ssz.width);
        }

        else {
            NSLog(@"Portrait");
        }

        /*
        // iOS versions before 7.0 did not switch the width and height on device roration
        if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
        {
            CGSize ssz = sz;
            sz = CGSizeMake(ssz.height, ssz.width);
        }*/
    }

The second issue I am having which I don't know how to fix is in the UIImage+ImageEffects.m file. There is a method at the very bottom of the source file called convertViewToImage - the first line of this method uses UIApplication sharedApplication so it won't work on iOS 8 Extensions. Do you know how to fix it?

+ (UIImage *)convertViewToImage
{
    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];

    UIView *keyView = [self.view];
    CGRect rect = [keyWindow bounds];
    UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [keyWindow.layer renderInContext:context];
    UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return capturedScreen;
}

I have made a stack overflow post for here: http://stackoverflow.com/questions/29620093/uiapplication-sharedapplication-keywindow-ios-app-widget

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions