むちゃんこわかりやすい動画だったのでメモ

splendidな動画なのでメモ。

スゥィートなアイコンを表示 スゥイートなね


  • 適当な画像をResourcesフォルダへコピー(ドラッグアンドドロップ
  • *-info.plistのIcon fileにコピーしたファイル名を記入(他の項目に$とかついてて気になるが付けない)

IBOutlet, IBActionを宣言

Viewに表示されたラベルなどの値を保持する変数を宣言する方法。

  • View-based Applicationで作ろうね
  • ViewController.hにViewのインスタンスを保存する変数を宣言

ViewController.h(一部)

@interface _ViewController : UIViewController {
	UILabel *labelsText;     // 追加
}
@property(nonatomic, retain) IBOutlet UILabel *labelsText // 追加
-(IBAction) clicked:(id)sender;  // 追加
@end

IBAction実装


ViewController.m

@implementation _ViewController
@synthesize labelsText;  // 追加

-(IBAction) clicked:(id)sender{  // 追加
	NSString *titleOfButton = [sender titleForState:UIControlStateNormal];
	NSString *newLabelText  = [[NSString alloc]initWithFormat:@"%@", titleOfButton];
	labelsText.text = newLabelText;
	[newLabelText release];
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
	self.labelsText=nil;   // 追加
}


- (void)dealloc {
    [super dealloc];
	[labelsText release];  // 追加
}

@end

IBOutletとIBActionをそれぞれ繋げる

どこからどこへ繋げるのかについて

  • つなげる前にInterface BuilderでViewにラベルをドラッグアンドドラッグ
  • つなげる前にInterface BuilderでViewにボタンをドラッグアンドドラッグ
  • ラベル(IBOutlet)はFile 's OwnerからViewのラベルに線を引く(File's Owner → ラベル)
  • ボタン(IBAction)は の部分からFile's Ownerに線を引く

UITextFieldとImage View

Viewに画像を貼付けるならImage View

  • Image Viewの大きさは画像選択後「Layout」→ 「Size to Fit」

キーボードを消す

キーボード消すなら resignFirstResponderメソッド

UISlider

スライドのイベントは Value Changedで取得

Segmented ControlとUISwitch

スイッチのイベントも Value Changedで取得


  • hiddenを使えば表示したり隠したりできる

ActionSheetとプロトコル

iPhoneを横向きにしたとき

シミュレータが動いてるときに「ハードウェア」→「反時計回りに回転」

Size Inspector

の挙動

  • Autosizingで、上からの距離左からの距離などで、iPhoneを横向きにしたときにオブジェクトを自動調整できる。
  • Size & Positionで大きさを調整できる。

willAnimateRotationToInterfaceOrientationをオーバーライド

  • オブジェクト.frame = CGRectMake( 座標 ); で左上の座標と、横幅、縦幅を管理できる。

Window-based Application

Classesフォルダ右クリックから新しいファイルを作成できる。





Tab Bar