2011-08-31 13 views
5

私はこれをやろうとしているが、ボタンは表示されません。右上にプログラムボタンで情報ボタンを作成するにはどうすればよいですか?

// Create a Button to get Help   
UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoDark ] ; 
CGRect buttonRect = helpButton.frame; 

// Calculate the top right corner 
buttonRect.origin.x = self.tableView.frame.size.width - buttonRect.size.width - 8; 
buttonRect.origin.y = self.tableView.frame.size.height - buttonRect.size.height - 8; 
[helpButton setFrame:buttonRect]; 

[helpButton addTarget:self action:@selector(doHelp:) 
forControlEvents:UIControlEventTouchUpInside]; 
[helpButton setEnabled:TRUE]; 
[self.tableView addSubview:helpButton]; 

私が間違って何をやっていますか?

// Create a Button to get Help   
UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoDark ] ; 
CGRect buttonRect = helpButton.frame; 

// CALCulate the bottom right corner 
buttonRect.origin.x = self.view.frame.size.width - buttonRect.size.width - 8; 
buttonRect.origin.y = buttonRect.size.height - 8; 
[helpButton setFrame:buttonRect]; 

[helpButton addTarget:self action:@selector(doHelp:) forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:helpButton]; 
+3

はないself.viewに追加しようself.tableviewない:

UPDATE 修正コードが興味を持っている人のためにここにありますself.tableview – TommyG

+0

それはトリックをしてくれてありがとう! –

+0

問題ありません! – TommyG

答えて

4

試みがself.viewに追加し

関連する問題