【问题标题】:Table footer view buttons表格页脚视图按钮
【发布时间】:2010-12-24 09:37:10
【问题描述】:

我有一些注册表单,其中电子邮件和登录文本字段作为表格单元格,注册按钮作为页脚视图中的按钮。 一切都很好,这是代码

frame = CGRectMake(boundsX+85, 100, 150, 60);
    UIButton *signInButton = [[UIButton alloc] initWithFrame:frame];
    [signInButton setImage:[UIImage imageNamed:@"button_signin.png"] forState:UIControlStateNormal];
    [signInButton addTarget:self action:@selector(LoginAction) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.hidesBackButton = TRUE;
    self.tableView.tableFooterView.userInteractionEnabled = YES;
    self.tableView.tableFooterView = signInButton;
    self.view.backgroundColor = [UIColor blackColor];

我的问题是如何在这个按钮旁边添加另一个按钮。

通过使用 [self.tableView.tableFooterView addSubview:...] 按钮未显示,如果我使用其他 UIView,将按钮放在那里,然后说 footerView 是 UIView,我看到按钮,但我无法按下它们。

我希望这不会太令人困惑,并且您理解我的问题。

【问题讨论】:

    标签: ios objective-c iphone button footer


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      您的第一次尝试是错误的,如果您按照您所说的那样尝试将按钮添加到按钮的子视图:

      首先是你

      ... 
      self.tableView.tableFooterView = signInButton;
      ...
      

      后来

      ... 
      [self.tableView.tableFooterView addSubview:...]
      ...
      

      但是 tableFooterView 是 signInButton。所以这就是为什么它不起作用。

      您的第二次尝试是正确的,而 yonanderson 指出您应该锻炼的答案是正确的方法,您只需要:

      [yourButtonsView addSubView:button1];
      [yourButtonsView addSubView:button2];
      yourButtonsView.userInteractionEnabled = YES;
      self.tableView.tableFooterView = yourButtonsView;
      self.tableView.tableFooterView.userInteractionEnabled = YES;
      

      【讨论】:

      • 这是我的代码: UIView *footerView = [[UIView alloc ] init]; [footerView addSubview:signInButton]; [footerView addSubview:signUpFreeButton]; footerView.userInteractionEnabled = YES; self.navigationItem.hidesBackButton = TRUE; //[self.tableView.tableFooterView addSubview:signInButton]; self.tableView.tableFooterView = 页脚视图; self.tableView.tableFooterView.userInteractionEnabled = YES;但是按钮仍然无法点击:(
      【解决方案3】:

      嗯,我在回答之前没有仔细阅读此内容。我认为您需要设置容器 UIView 的 userInteractionEnabled 属性,然后在尝试时将 footerView 设置为带有子视图的容器。

      【讨论】:

        【解决方案4】:

        我花了很长时间才弄清楚为什么我的页脚按钮没有调用指定的操作。最后我发现我需要调整页脚的高度。这为我解决了问题:

        -(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
            return footerView.bounds.size.height;
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-01-27
          • 1970-01-01
          • 2011-09-01
          • 2012-08-30
          • 1970-01-01
          相关资源
          最近更新 更多