Iphone UIButton并不总是启动

Iphone UIButton并不总是启动,iphone,objective-c,cocoa-touch,uibutton,Iphone,Objective C,Cocoa Touch,Uibutton,我正在扩展UITableViewController,并在表尾添加了一个uibutton程序,由于某些原因,uibutton只有在触摸顶部时才会启动。。。好像有什么东西掩盖了它的其余部分,我不明白它是什么 我在ViewForFooterInstruction函数中有以下代码: CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; UIView* footerView = [[UIView alloc] initWithFra

我正在扩展UITableViewController,并在表尾添加了一个uibutton程序,由于某些原因,uibutton只有在触摸顶部时才会启动。。。好像有什么东西掩盖了它的其余部分,我不明白它是什么 我在ViewForFooterInstruction函数中有以下代码:

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;
CGRect-screenRect=[[UIScreen mainScreen]applicationFrame];
UIView*footerView=[[UIView alloc]initWithFrame:CGRectMake(0,0,screenRect.size.width,44.0)];
footerView.autoresizesSubviews=是;
footerView.autoresizingMask=UIViewAutoresizingFlexibleWidth;
footerView.userInteractionEnabled=是;
goButton=[UIButton按钮类型:UIButtonTypeCustom];
[goButton addTarget:self action:@selector(getReport)for ControlEvents:UIControlEventTouchUpInside];
[goButton setTitle:@“开始!”状态:UIControlStateNormal];
[goButton setTitleColor:[UIColor whiteColor]用于状态:UIControlStateNormal];
goButton.frame=CGRectMake(50,20,220.0,50.0);
UIImage*bg=[UIImage ImageName:@“but_go.png”];
[goButton setBackgroundImage:bg forState:uicontrol状态正常];
[goButton setBackgroundColor:[UIColor clearColor]];
if(self.optimizations==nil | | self.optimizations.count<1){
goButton.enabled=否;
}
[footerView添加子视图:goButton];
返回页脚视图;

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

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