gpt4 book ai didi

ios - 在 objective-c 中扩展 tableview 时按钮不起作用?

转载 作者:行者123 更新时间:2023-11-28 21:01:55 25 4
gpt4 key购买 nike

我是 iOS 编程的新手,我已经实现了 UITableviewController,下面是我的 Controller 的设计,

UITableViewController---          
UIView----- (1)
Label---Label (2)
label---Label (3)
label--- (4)
UItableview (5)
textfield (6)
textfield (7)
UIButton. (8)
UIButton. (9)

等等。

我的问题是当我展开 (5) 表格 View 高度时,底部按钮不起作用,我不知道如何解决这个问题,任何人都可以帮助提出一些解决这个问题的建议。下面是我的编码尝试过...

-(void)viewDidLoad
{
[super viewDidLoad];
// [ProgressHUD show:@"Please Wait..."];
array=[[NSMutableArray alloc]initWithObjects:@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",@"testing",nil];
[self adjusttableview];
}
-(void) adjusttableview{
_mytableview. translatesAutoresizingMaskIntoConstraints = YES;
CGFloat numberofrows=array.count;
CGFloat height = numberofrows*10;
_waterheight.constant = height; //Constraints of my tableview (5) height

_mytableview.frame =CGRectMake(_mytableview.frame.origin.x,_mytableview.frame.origin.y, _mytableview.frame.size.width,height);


}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}

(5) table view height 扩展完美,但是当它扩展时下面的按钮不起作用。

expanded tableview submit button

最佳答案

在上面的场景中,您的按钮位于表格 View 下方,因此一旦表格 View 增加,按钮就会超出 UIView 的范围。所以可访问性区域消失了。

对于这种设置,将添加动态字段。更好的方法是使用静态单元格表​​ View /动态单元格表​​ View 作为一个整体,而不是在 View 中使用 TableView 。您可以在其中添加任意数量的单元格并在 View 中修改它。在这种情况下,按钮将添加到单元格和可见性中,并且不会发生点击问题。

关于ios - 在 objective-c 中扩展 tableview 时按钮不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48144651/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com