【问题标题】:UIButton does not always fireUIButton 并不总是触发
【发布时间】:2010-11-09 16:44:55
【问题描述】:

我正在扩展 UITableViewController 并在表格页脚中添加了一个 uibutton,由于某种原因,uibutton 仅在触摸顶部时触发......好像某些东西掩盖了它的其余部分,我无法理解这是什么 我在 viewForFooterInSection 函数中有以下代码:

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;

【问题讨论】:

    标签: iphone objective-c cocoa-touch uibutton


    【解决方案1】:

    这是因为按钮的框架从其父视图中掉了出来。您需要增加footerView 的框架大小,以便按钮的整个部分包含在footerView 中。您可以尝试将footerView的背景颜色设置为蓝色或红色,以查看实际的边框区域。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多