在表格页脚视图中放置一个按钮

Abh*_*nav 3 iphone cocoa-touch uibutton uitableview ios

我正在创建一个自定义按钮并将其放在我的表格的页脚视图中,但按钮正在从右上角开始.

这里有什么问题!?!

这是我的代码和输出图像:

UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [aButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [aButton setTitleColor:[UIColor colorWithWhite:0.0 alpha:0.56] forState:UIControlStateDisabled];
    [aButton setBackgroundImage:[[UIImage imageNamed:@"test.png"] stretchableImageWithLeftCapWidth:kButtonSliceWidth topCapHeight:0] forState:UIControlStateNormal];
    [aButton setTitle:@"Click me" forState:UIControlStateNormal];
    [aButton.titleLabel setFont:[UIFont boldSystemFontOfSize:kFontSize14]];
    [aButton setFrame:CGRectMake(10.0, 15.0, 300.0, 44.0)];
    [self.tableView setTableFooterView:aButton];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Abh*_*nav 15

我在UIView中添加了按钮,然后将tableFooterView设置为此UIView对象并且它工作正常.我们不能直接将UIButton作为tableFooterView.