SSブログ

iPhoneSDKを理解する~Storyboradを使わない開発:Viewクラス追加~ [iOSプログラミング]

今回は、iPhoneSDKを理解する~Storyboradを使わない開発:Viewクラス追加~について。

概要としては、以下の通り。

XcodeのSample0005-1Groupを右クリックし、

「New File…」をクリックする。

 

iOSのCocoa Touchの項目一覧から

Objective-C classを選択し、

「Next」ボタンをクリックする。
 

 

下記条件でファイルを作成し、保存する。

Class:MainView

Subclass of:UIView

 

MainView.hを下記の通り修正する。
@interface MainView : UIView {
   
}

- (id)initWithFrame:(CGRect)frame;
- (void)dealloc;
@end


MainView.mを下記の通り修正する。
@implementation MainView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end


 

詳細手順は、以下の通り。

1.XcodeのSample0005-1Groupを右クリックし、

「New File…」をクリックする。

Sample0005-2.jpg

 

2.iOSのCocoa Touchの項目一覧から

Objective-C classを選択し、

「Next」ボタンをクリックする。

Sample0005-3.jpg

 

3.下記条件でファイルを作成し、保存する。

Class:MainView

Subclass of:UIView

Sample0005-4.jpg

MainView.hとMainView.mが追加される。

Sample0005-5.jpg

 

4.MainView.hを下記の通り修正する。
@interface MainView : UIView {
   
}

- (id)initWithFrame:(CGRect)frame;
- (void)dealloc;
@end

5.MainView.mを下記の通り修正する。
@implementation MainView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end

 

iPhone SDK アプリケーション開発ガイド

iPhone SDK アプリケーション開発ガイド

  • 作者: Jonathan Zdziarski
  • 出版社/メーカー: オライリージャパン
  • 発売日: 2009/09/07
  • メディア: 大型本

 


nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:パソコン・インターネット

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

白いきつねのスキル

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。