LoginSignup
7
2

More than 3 years have passed since last update.

【swift】google admobを実装した際に「[UIView setAdUnitID:]: unrecognized selector sent to instance」が出力した場合の対応

Posted at

swiftでgoogle admobを実装している際に下記エラーが出力した。

エラー内容

Thread 1: "-[UIView setAdUnitID:]: unrecognized selector sent to instance 0x7fce3a70abc0"

スクリーンショット 2020-11-28 21.34.03.png

対応方法

広告の枠としたいUIViewと「@IBOutlet weak var bannerView: GADBannerView!」をドラッグアンドドロップなどで紐付けるのだが、その際UIViewのCustom ClassのClass名に「GADBannerView」が記載されておらず実行時エラーとなっていた。

UIViewのCustom ClassのClass名に「GADBannerView」を記載することで、無事エラー回避できた。

修正前

スクリーンショット 2020-11-28 21.36.12.png

修正後

スクリーンショット 2020-11-28 21.40.09.png

最後に

コードを先に書いたあとに、UIViewにドラッグアンドドロップで紐付けると、UIViewのCustomClassは更新されないんですね。。。
ともあれ解消したのでよかったです。

7
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2