2011-06-22 2 views
0

私は私のloadViewメソッド方法でTTButtonを追加するには、次のコードを使用して示されていない:TTButtonは

TTButton* button2 = [TTButton buttonWithStyle:@"forwardActionButton:" title:@"Login"]; 
[button2 setFrame:CGRectMake(245, 160, 65, 33)]; 
[self.view addSubview:button2]; 

しかし、ボタンは表示されません。

私はここで何が欠けているか知っていますか?

おかげで、

答えて

2

このコードスニペットは正常に見えるが(私は私のヘッダファイルに#IMPORTんでした)。あなたは "forwardActionButton"スタイルをどこで宣言していますか?私が知っている限り、それは既存のTTStyleの3 20ではありません。任意のカスタムスタイルは、スタイルシートクラスである必要があり、そのように、アプリデリゲートにロードする必要があります:「toolbarForwardButton:」

[TTStyleSheet setGlobalStyleSheet:[[[StyleSheet alloc] init] autorelease]]; 

あなたはまたのような、既存のTTStyleでそれを試すことができますし、それが作品をだかどうかを確認します。

ここTTButtonを使用して、ボタンのターゲットとして機能セレクターの設定に関する作業例を示します。

TTButton* storyButton = [TTButton buttonWithStyle:@"toolbarRoundButton:" title:@"Open Full Story"]; 

storyButton.font = [UIFont boldSystemFontOfSize:18]; 
storyButton.frame = CGRectMake(100, 100, 200, 50); 

[storyButton addTarget:self action:@selector(presentFullStory) forControlEvents:UIControlEventTouchUpInside]; 
[storyButton sizeToFit]; 
[self.view addSubview:storyButton]; 
+0

ありがとうaporat。できます! –