2010-11-09 75 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背景色设置为蓝色或红色以查看实际的框架区域。