CGAffineTransformInvert: Singular Matrix Error

I created a universal application (one view) in Xcode. Since I want to have an iAd banner for each view, I added this code to the 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 a real iPhone (iOS 8) Everything works fine (a banner appears on each view), but I get this error:

 <Error>: CGAffineTransformInvert: singular matrix. 

If I try to run this application on Simulator (iOS 8), then the behavior will be 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 a delegate, and I implemented didFailToReceiveAdWithError . On a real iPhone, it works ...

My question is: how can I solve these two specific errors?

+8
ios swift swift2 iad
source share
2 answers

The most likely reason is that one of the lines here is zero. You cannot invert the null matrix (which is a technical detail, and you really don't need to care about it, I'm just trying to say why this is a mistake).

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

+9
source share

Add this to your Controller class .. replace adBanner with the name of your banner name

 -(void)viewDidDisappear:(BOOL)animated{ [adBanner removeFromSuperview]; adBanner.delegate = nil; adBanner = nil; } 
0
source share

All Articles