2010-11-09 73 views
0

我擴展了UITableViewController並且有一個uibutton被添加到了表格腳註中,出於某種原因,只有在頂部觸摸時纔會觸發uibutton ...就好像someting屏蔽了其餘的部分並且我不明白它是什麼 我在viewForFooterInSection功能下面的代碼:UIButton並不總是會觸發

CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; 

UIView* footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, 44.0)]; 
footerView.autoresizesSubviews = YES; 
footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 
footerView.userInteractionEnabled = YES; 


goButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[goButton addTarget:self action:@selector(getReport)forControlEvents:UIControlEventTouchUpInside]; 
[goButton setTitle:@"GO!" forState:UIControlStateNormal]; 
[goButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
goButton.frame = CGRectMake(50, 20, 220.0, 50.0); 

UIImage *bg = [UIImage imageNamed: @"but_go.png"]; 
[goButton setBackgroundImage:bg forState:UIControlStateNormal]; 
[goButton setBackgroundColor:[UIColor clearColor]]; 

if (self.optimizations == nil || self.optimizations.count < 1){ 
goButton.enabled = NO ; 
} 

[footerView addSubview: goButton]; 

return footerView; 

回答

3

這是因爲按鈕的框架跌出其父視圖。您需要增加footerView的框架大小,以便按鈕的整個部分包含在footerView中。您可以嘗試將footerView背景色設置爲藍色或紅色以查看實際的框架區域。