なんとかするから、なんとかなる

エンジニア関係のことを書きます

iOS Carthageでモジュールを導入してXCTestで Module "なにかしらのモジュール" was not compiled for testing が出たときの対処方法

English version below https://hopita.hatenablog.com/entry/2018/08/29/202132 はじめに XCTestでユニットテストを実行し用としたときにぶつかった問題です。 Carthageでモジュールを導入し、ユニットテストでそのモジュールを使用するときに少しつまづき…

iOS ForEach構文でArrayのIndexを取得する

English version below https://hopita.hatenablog.com/entry/2018/08/27/210911 はじめに ForEach文でIndex番号が欲しいことはよくあるので、備忘録です。 解決方法 enumerated()メソッドを利用する for (index, value) in someArray.enumarated() { // な…

iOS How to get an index of array in for each sentence.

Introduction This article shows how to get an index in for each sentence. Solution Using enumarated method. You can get the index of array for (index, value) in someArray.enumarated() { // do something }

iOS How to edit a View in debug mode by LLDB Console

Introduction This article shows how to edit a view in debug mode by LLDB Console. Preparation First of all, Build an app on a simulator or device and open the [Debug View Hierarchy] In this article, I'll show you how to change an informati…

iOS UIViewControllerでバックグラウンドへの遷移を検知する

English version below. https://hopita.hatenablog.com/entry/2018/08/25/201940 はじめに UIViewControllerにおいて、アプリがバックグラウンドなったときやバックグラウンドに戻ってきたときに処理を行いことはよくあります。 今回はそのやり方を紹介した…

iOS How to detect the background transition in UIViewController

Introduction This article shows hot to detect an entering background and activating from background in UIViewController. Solution As you know, UIViewController doesn't have a delegate which is called when it will go background and come bac…

iOS LLDBでViewを操作するTips

English version below https://hopita.hatenablog.com/entry/2018/08/25/203726 はじめに 今回はデバッグ中にLLDBでViewを操作するために役立つTipsを紹介します。 準備 デバッグを開始して、[Debug View Hierarchy]を開いておきます。 今回はUILabelの情報…

iOS How to solve the black screen when a modal view was dismissed with custom animation.

Introduction This article shows how to solve the black screen when a modal view was dismissed with custom animation. When I tried to set an present and modal animation when a modal view was appeared and disappeared. Though the present anim…

iOS UIViewControllerのPresentに対してカスタムアニメーションをつけたらブラックアウトしたときの対処法

English Version below https://hopita.hatenablog.com/entry/2018/08/23/212747 はじめに UIViewControllerのモーダル表示presentメソッドに独自アニメーションをつけたら、dismiss時に画面が黒くなった(ブラックアウトした)ときの対処方法です。 UIViewC…

iOS How to scale an image in UIButton.

Introduction This article shows how to scale an image in UIButton. When UIButton will be a large scale or small scale by Autolayout engine, an image it was contained in the UIButton is not correspond to the scale normally. This article wil…

iOS How to get a monospace font for digits in UIFont.

Intoduction This article shows how to set a monospace font for digits. A monospace font has same width in each character. Sometimes, a font which isn't monospace make the design baddly. Solution To get the monospace font for digits, Apple …

iOS UITextField How to dismiss the keyboard when user tap a retrun key.

Introduction This article show you that how to dismiss the keyboard when user tap a return key on UITextField of iOS. In fact, this way shows on the iOS SDK document. I've never knew it. Solution Adapt the UITextFieldDelegate on your ViewC…

iOS UITableView deleteRows(at:with:) was crashed

Introdution UITableView is one of the most popular UI system in iOS developer. But, sometimes this UI system make us annoying. In this time, when I try to delete the UITableViewCell from swipe or delete button, it would be crashed. So, thi…

iOS It’s difficult to animate UIView by themselves when it appeared.

Introduction This article explains its difficult to animate an UIView by themselves when it appeared. Conclusion There two solution for the problem. • Call some animation start method by UIViewController • Observe the didBecomeActive event…

iOS How to detect the instance is inheritance of some class or not.

Intoroduction This are article shows how to detect the instance is inheritance of some class or not. Solution if someInstane is SomeClass { // The Instance is inheritance of some class. } else { // Instance is not inheritance of some class.…

iOS How to detect an user interacion while animating

Introduction This article shows how to detect an user interaction while animating on UIView or UIbutton or etc. Solution Set the ".allowUserIntercation" properties in option at UIView.animate method. UIView.animate(withDuration: 1.0, delay…

iOS UITableViewCellで選択されたCellをもとに戻す

English version below. https://hopita.hatenablog.com/entry/2018/08/22/225145 はじめに 選択されたCellをもとに戻す。よくやることですが、恥ずかしながら勘違いして覚えていたので備忘録。 解決方法 override func tableView(_ tableView: UITableView,…

iOS How to deselect a cell which was tapped by user.

Introduction This article shows how to deselect an cell when user tapped it. Solution It's a easy way to do it. override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { //Change the selected background view …

自ら調べて、感じて、考える大切さ

エビングハウスの忘却曲線をご存知ですか? 勉強したこと記憶したことは20分後には7割しか覚えていない。翌日には3割しか覚えていない。なのでこまめに復習するんだ。一週間後には復習するんだ。と。 受験生の頃よく、この話を聞いたことがあると思います…

iOS How to rotate a UIView in 360 degrees.

Introduction This article shows how to rotate360 degrees for UIView. First I thought of using UiView.animate method and AffineTransform the UIView. It was figured out that if I set a transform property as below view.transform = CGAffineTra…

iOS UIViewを360度回し続ける

English version below https://hopita.hatenablog.com/entry/2018/08/20/225027 はじめに UIViewは360度回し続けるのは意外と面倒だったので紹介 すぐ思いつく方法 すぐに思いつく方法はUIView.animateで、transformを設定する方法だと思います。 しかしや…

iOS LLDBでの基本的なデバッグの方法

はじめに LLDBを使っていますか? LLDBを使うと効率的なデバッグが簡単にできるようになります。 今まで再コンパイルで使っていた時間が嘘のように短くなります。 今回はそんなLLDBの使い方の基礎をまとめたいと思います。 基本的にはWWDC2018 Advanced Debu…

iOS UIView transform doesn't scale propery while transition animetion.

Sorry for my poor English skill. Introduction This article shows how to solve the problem that UIView transform doesn't scale correctly while transition animation. Transition animation make an app interactively. But, sometimes it meka deve…

iOS 画面遷移アニメーションにてUIViewで拡大して縮小したら戻らなかったときの解決方法

English version below URL https://hopita.hatenablog.com/entry/2018/08/18/160658 はじめに 画面遷移時にカスタムアニメーションを使うことはよくあります。 カスタムアニメーションを使うことで、アプリの表現の幅はかなり広げられます。 しかし、このア…

iOS UIButtonやUIViewでアニメーション中にタップイベントを検知する

English version below https://hopita.hatenablog.com/entry/2018/08/22/225953 はじめに UIViewやUIButtonでアニメーション中にタップイベントを受け取る方法です。 解決方法 UIView.animate関数のオプションに".allowUserIntercation"を追加するだけです…

iOS 特定のクラスインスタンスであるかを確認する。

English version is below https://hopita.hatenablog.com/entry/2018/08/22/230146 はじめに とあるインスタンスがあるクラスのインスタンスであるかを確認する方法です。 意外と使いたい機会が多いですが、すぐ忘れてしまいます。 解決方法 とても単純です…

iOS UIView自身で画面表示時にアニメーションすることは難しい

English version below https://hopita.hatenablog.com/entry/2018/08/22/230421 はじめに UIView自身で画面に表示されるたびにアニメーションを実行したかったのですが、方法が思いつかなくて挫折した話です。 結論 UIViewControllerからメソッド呼ぶか 画…

iOS UIButtonの画像の比率を固定して拡縮する

English Version below https://hopita.hatenablog.com/entry/2018/08/22/231143 はじめに UIButtonのサイズ変更に追随して、内部の画像サイズを変更したい場合の対処方法です。 解決方法 以下の3つのプロパティをセットすればOKです。 button.imageView?.c…

iOS UIFontで数字の等幅フォントを取得する

English version below. https://hopita.hatenablog.com/entry/2018/08/22/230929 UIFontで等幅フォントを取得する 等幅フォントとは、すべての文字で幅が等しいフォントです。 等幅でないフォントでは1 と8 の幅が全く異なります。その結果、文字が変わるご…

iOS UITextField でRetrunを押したときにキーボードを閉じる。

English version below. https://hopita.hatenablog.com/entry/2018/08/22/230826 はじめに 意外と忘れてしまうことの方法。 実はきちんとAppleの公式ドキュメントにも書かれています。 やり方 UITextFieldDelegate に適合する 対象のUITextFieldインスタン…