Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CGAffineTransformInvert: singular matrix Error

I created Universal App (single view) in Xcode. Because I want to have iAd banner on every view I added this code to AppDelegate file:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
    if var root = self.window?.rootViewController
    {
        let contentFrame = UIScreen.mainScreen().bounds
         var _banner = ADBannerView(adType: ADAdType.Banner)

        _banner.frame=CGRectMake(0, contentFrame.height - _banner.frame.height, _banner.frame.width, _banner.frame.height)
        _banner.delegate = self
        root.view.addSubview(_banner)
    }

    return true
}

On real iPhone (iOS 8) Everything works fine (banner appears on every view) but I'm getting this error:

<Error>: CGAffineTransformInvert: singular matrix.

If i try to run this app on Simulator (iOS 8) the behavior is the same. Everything works fine, i get the same error but moreover i get: *ADBannerView:

 Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:):
 Error Domain=ADErrorDomain Code=7 "The operation couldn’t be completed. Ad was unloaded from 
this banner" UserInfo=0x7b83bf30 {ADInternalErrorCode=7, ADInternalErrorDomain=ADErrorDomain, 
NSLocalizedFailureReason=Ad was unloaded from this banner}*

But I have delegate and I implemented didFailToReceiveAdWithError. On real iPhone it works...

My question is how could I solve these two particular errors?

like image 903
André Avatar asked Sep 14 '14 20:09

André


1 Answers

The most likely cause is that one of the rects here is zero. You can't invert a zero matrix (which is a technical detail, and you really shouldn't have to care about; I'm just trying to say why that's the error you get).

application(didFinishLaunchingWithOptions:) is called very early, and the frames probably aren't set yet. You probably want to be doing this work in the viewDidLoad (possibly fixing up the frames in viewWillAppear if necessary) of your root view controller (you probably will need to create a subclass for that if you don't already have one).

like image 84
Rob Napier Avatar answered Oct 07 '22 01:10

Rob Napier