Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 表页脚视图按钮_Ios_Objective C_Iphone_Button_Footer - Fatal编程技术网

Ios 表页脚视图按钮

Ios 表页脚视图按钮,ios,objective-c,iphone,button,footer,Ios,Objective C,Iphone,Button,Footer,我有一些注册表单,其中电子邮件和登录文本字段作为表格单元格,注册按钮作为页脚视图中的按钮。 所有功能都非常出色,下面是代码 frame = CGRectMake(boundsX+85, 100, 150, 60); UIButton *signInButton = [[UIButton alloc] initWithFrame:frame]; [signInButton setImage:[UIImage imageNamed:@"button_signin.png"] forS

我有一些注册表单,其中电子邮件和登录文本字段作为表格单元格,注册按钮作为页脚视图中的按钮。 所有功能都非常出色,下面是代码

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,我看到了按钮,但无法按下它们


我希望这不会太让人困惑,希望你能理解我的问题。

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

看看这个问题:

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

首先是你

... 
self.tableView.tableFooterView = signInButton;
...
后来

... 
[self.tableView.tableFooterView addSubview:...]
...
但tableFooterView是登录按钮。所以这就是为什么这不起作用

您的第二次尝试是正确的,而Yondarson指出的答案是您应该解决的,并且是正确的解决方法,您只需要:

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

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

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

这是我的代码:UIView*footerView=[[UIView alloc]init];[footerView添加子视图:登录按钮];[footerView addSubview:signUpFreeButton];footerView.userInteractionEnabled=是;self.navigationItem.hidesBackButton=TRUE;//[self.tableView.tableFooterView添加子视图:登录按钮];self.tableView.tableFooterView=footerView;self.tableView.tableFooterView.userInteractionEnabled=是;但按钮仍然不可点击:(