learnswiftorxamarin
learnswiftorxamarin
LearnSwiftOrXamarin
22 posts
Don't wanna be here? Send us removal request.
learnswiftorxamarin · 8 years ago
Text
UIWindow
UIViewの1つ。アプリのRootView
0 notes
learnswiftorxamarin · 8 years ago
Text
StatusBarにViewが被らないようにする(コードでなんとかする)
NavigtationControllerを使わない場合、ViewがStatus Barにかぶる。 この対策の1つにStatus Bar分の高さを考慮してViewを作る方法がある。
var offset = UIApplication.SharedApplication.StatusBarFrame.Height; var rect = View.Bounds; rect.Y = rect.Y + offset; rect.Height = rect.Height - offset; var stack = new UIStackView(); stack.Frame = frame;
0 notes
learnswiftorxamarin · 8 years ago
Link
Bridging_Header.h を設定するときに参考になる
0 notes
learnswiftorxamarin · 8 years ago
Text
UITableViewCell をxibで作る時
storyboardに UITableViewCell を配置
UITableViewCell を選択
Custom Class 項の Class にHoge.swiftで定義した Hoge を設定
Identity に独自の 名前を入れる
Tumblr media
0 notes
learnswiftorxamarin · 8 years ago
Link
0 notes
learnswiftorxamarin · 8 years ago
Text
データ置き場
/Documents ** アプリがファイルを作成して保存できる領域
/Library/Caches ** アプリが一時的に使用する領域
/tmp ** 一時ファイルの保存先に使用する領域
0 notes
learnswiftorxamarin · 8 years ago
Text
NavigationBarがStatus Barと重なる
下記のどれかで回避
Under Top Bars と Under Bottom Bars を外す
コード上で self.edgesForExtendedLayout = UIRectEdgeNone;を設定
NavigationController の Navigation Bar の Translucent のチェックを外す
Tumblr media Tumblr media
0 notes
learnswiftorxamarin · 8 years ago
Text
UIScrollViewの高さ
AutoLayout でUIScrollVIewを設定するとcontent heightを設定しろと警告が出る
回避方法
UIView をScrollViewの中に追加
contentViewなど名前を適当につけておく
contentView の上下左右に0マージンを追加
contentView のサイズを指定する
0 notes
learnswiftorxamarin · 8 years ago
Quote
swiftでoptional methodを使わなければいけない時の注意
https://tech.recruit-mp.co.jp/mobile/swift-optional-method/
0 notes
learnswiftorxamarin · 8 years ago
Text
引数の “_” と “#”
Swiftでは第二引数以降はラベルを付けて呼び出す必要があるが、省略する方法が用意されている
アンダースコア ( _ )
funcを呼び出す時にラベルを省略できる func hoge (_ a: String, _ b:Int) { } の場合、 hoge(”hello”, 1)
イニシャライザ init() では省略できない
シャープ ( # )
外部から見えるラベルと、内部で使うパラメータが同じ名前の場合に簡略化できる
0 notes
learnswiftorxamarin · 8 years ago
Text
ゴミさんのハンズオン
http://qiita.com/gomi_ningen/private/4e0e5bd98f08c4bcf93d#2-%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%81%AE%E4%BD%9C%E6%88%90-hello-world-%E3%81%A8%E3%81%9D%E3%81%AE%E5%91%A8%E8%BE%BA
0 notes
learnswiftorxamarin · 8 years ago
Text
.description
0 notes
learnswiftorxamarin · 8 years ago
Text
Dictionary
他言語でいう連想配列の事 letで宣言 イミュータブルオブジェクト NSDictionary varで宣言 ミュータブルオブジェクトNSMutableDictionaly let a [string:string]= ["a":"B"] let a dictionary= ["a":"B"] //AnyObject として処理される let a = ["a":"B"]
0 notes
learnswiftorxamarin · 8 years ago
Text
Method & Function
Method クラスに属する Function クラスに属さない 第一級関数 引数、戻り値、変数代入でオブジェクトとして扱われる関数
func メソッド名(引数名:引数の型)->戻り値の型 func メソッド名(ラベル名 引数名:引数の型)->戻り値の型
0 notes
learnswiftorxamarin · 8 years ago
Text
fall through
break文がない場合に直下に向かって処理が流れる
0 notes
learnswiftorxamarin · 8 years ago
Text
Switch
case   - 評価式を複数設定でき、条件A or 条件 B になる   - 上から順に評価される   - switchで指定される型以外の値は評価できずエラーになる any,anyobject は使えない switch “some value to consider” { case value 1:    respond to value 1 case value 2, value 3:    respond to value 2 or 3 default:    otherwise, do something else } label?
0 notes
learnswiftorxamarin · 8 years ago
Text
if
// target は評価対象のInt if target % 15 == 0 {   print("fizz buzz") } else if target % 3 == 0 {   print("fizz") } else if target % 5 == 0{   print("buzz") } else {   print(target) }
0 notes