iOS
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…
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…
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.…
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…
English version below. https://hopita.hatenablog.com/entry/2018/08/22/225145 はじめに 選択されたCellをもとに戻す。よくやることですが、恥ずかしながら勘違いして覚えていたので備忘録。 解決方法 override func tableView(_ tableView: UITableView,…
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 …
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…
English version below https://hopita.hatenablog.com/entry/2018/08/20/225027 はじめに UIViewは360度回し続けるのは意外と面倒だったので紹介 すぐ思いつく方法 すぐに思いつく方法はUIView.animateで、transformを設定する方法だと思います。 しかしや…
はじめに LLDBを使っていますか? LLDBを使うと効率的なデバッグが簡単にできるようになります。 今まで再コンパイルで使っていた時間が嘘のように短くなります。 今回はそんなLLDBの使い方の基礎をまとめたいと思います。 基本的にはWWDC2018 Advanced Debu…
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…
English version below URL https://hopita.hatenablog.com/entry/2018/08/18/160658 はじめに 画面遷移時にカスタムアニメーションを使うことはよくあります。 カスタムアニメーションを使うことで、アプリの表現の幅はかなり広げられます。 しかし、このア…
English version below https://hopita.hatenablog.com/entry/2018/08/22/225953 はじめに UIViewやUIButtonでアニメーション中にタップイベントを受け取る方法です。 解決方法 UIView.animate関数のオプションに".allowUserIntercation"を追加するだけです…
English version is below https://hopita.hatenablog.com/entry/2018/08/22/230146 はじめに とあるインスタンスがあるクラスのインスタンスであるかを確認する方法です。 意外と使いたい機会が多いですが、すぐ忘れてしまいます。 解決方法 とても単純です…
English version below https://hopita.hatenablog.com/entry/2018/08/22/230421 はじめに UIView自身で画面に表示されるたびにアニメーションを実行したかったのですが、方法が思いつかなくて挫折した話です。 結論 UIViewControllerからメソッド呼ぶか 画…
English Version below https://hopita.hatenablog.com/entry/2018/08/22/231143 はじめに UIButtonのサイズ変更に追随して、内部の画像サイズを変更したい場合の対処方法です。 解決方法 以下の3つのプロパティをセットすればOKです。 button.imageView?.c…
English version below. https://hopita.hatenablog.com/entry/2018/08/22/230929 UIFontで等幅フォントを取得する 等幅フォントとは、すべての文字で幅が等しいフォントです。 等幅でないフォントでは1 と8 の幅が全く異なります。その結果、文字が変わるご…
English version below. https://hopita.hatenablog.com/entry/2018/08/22/230826 はじめに 意外と忘れてしまうことの方法。 実はきちんとAppleの公式ドキュメントにも書かれています。 やり方 UITextFieldDelegate に適合する 対象のUITextFieldインスタン…
はじめに 今さらながらRxSwiftを試して見ました。 Disposable Observerしている情報を保持しているオブジェクト Disposable.dispose()を呼び出すことで通知の解除が可能 複数のDiposableを一度に処理するためにDisposableBagがある ObserverとPublishObject …
背景 Carthageで Cartfileに記述 例ではGitHub上の"YOUR_LIBRARY"というフレームワークを導入。 github "YOUR_LIBRARY" ~> 1.0 コマンドラインでコードを実行 $ carthage update --platform iOS ビルドしてみると次のエラー発生。 dyld: Library not loaded:…
English version is below. https://hopita.hatenablog.com/entry/2018/08/22/230653 はじめに UITableViewを使っていて、deleteRow(at:with:) を読んだときにクラッシュする問題にぶつかりました。 その解決方法について紹介します。 問題 次のようなコード…
背景 Decodableで構造体を初期化した際、値が代入されていなかったので、備忘録。 起きたこと 次のようなコードを書いたときに初期化時に値が入りませんでした。 json形式の値を受け取り、初期化したときに失敗しました。 struct SomeStruct: Decodable { le…
はじめに iOSのStatusBarの色を変更したいことはよくあります。 でも、やりかたをよく忘れてしまいます。 なので、まとめます。 アプリ全体での色の設定 info.plistで "View controller-based status bar appearance"にNOを設定 appDelegate.swift のdidFini…
背景 iOSの開発をしていると必ず必要となるViewController。 ViewControllerにはライフサイクルがあります。 ここまでは、普通の話ですがライフサイクル中のメソッドviewDidLoadなどで 親クラスのメソッドsuperを呼び忘れることがあります。その場合大丈夫な…
背景 Gitでマージがコンフリクトすることはよくあります。 今回は xcodeproj/project.pbxproj がコンフリクトしたときに少し詰まったのでその解決方法を紹介。 起こったこと Gitで xcodeproj/project.pbxprojに手作業で修正したとき次のようなエラーがでまし…
背景 xibファイルを利用してCustomViewを作成して、ViewControllerと接続したときに遭遇した問題です。 解決方法 File's OwnerのCustomClassを設定する OutletsのViewとviewを接続する Interface Builderへ行き、~~ViewController.xibのFile's Ownerの上でCo…
概要 JenkinsでiOSアプリをテスト後にレポートを生成する方法 少し前に試した内容なので少し情報が古いことがあると思います。 背景 iOSアプリをテストする場合、xcodebuildをコマンドラインで実行することでテストができる。 ただし、xcodebuildで実行した…
UIColorをカラーコードで指定したいときって多いですよね。どうして公式対応してもらえないのだろう。 私はいつの以下のようなExtensionで拡張しています。 extension UIColor { /// Hex表記でカラーを生成 /// /// - Parameters: /// - hex: カラーコード /…
Carthage updateをしたときに次のようなエラーが発生した際の対処法 A shell task ("YOUR_PRODUCT_PATH" CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -list) failed with exit code 72: xcrun: error: unable to find utility "xcodebuild",…
UINavigationControllerを利用した、画面遷移にメソッドのまとめです。 画面を閉じる/戻る dismissViewController Modalダイアログで表示された場合に画面を閉じる popViewController UINavigationControllerで管理されている場合に画面遷移を戻る popToRooV…
UITableViewCellはよく使うクラスの1つだと思います。 少しiOS開発に慣れてくるとUITableViewCellをカスタマイズしたくなります。 その際の手順を簡単に紹介 UITableViewCell を継承する init(style: UITableViewCellStyle, reuseIdentifier: String?)をオ…