Iphone 如何使uibutton与自定义uitableviewcell的宽度和高度完全相同

Iphone 如何使uibutton与自定义uitableviewcell的宽度和高度完全相同,iphone,uitableview,bounds,Iphone,Uitableview,Bounds,我正在尝试使我的按钮与自定义uitableviewcell的宽度和高度完全相同 以下是我试图做到这一点的方式 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) {

我正在尝试使我的按钮与自定义uitableviewcell的宽度和高度完全相同

以下是我试图做到这一点的方式

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            return cellCode;            
        }
        if (indexPath.row == 1) {
            cellManufacture.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            return cellManufacture;
        }
        if (indexPath.row == 2) {
            cellModel.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            return cellModel;
        }
        if (indexPath.row == 3) {
            cellYear.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            return cellYear;
        }
    }
    submitButton.frame = cellSubmit.bounds; //<<<<<<HERE IS WHERE I SET SIZING :)
    return cellSubmit;  
}
//自定义表视图单元格的外观。
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
if(indexPath.section==0){
if(indexPath.row==0){
返回手机代码;
}
if(indexath.row==1){
cellManufacture.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
退货制造;
}
if(indexPath.row==2){
cellModel.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
回归模型;
}
if(indexPath.row==3){
cellYear.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
回归年;
}
}

submitButton.frame=cellSubmit.bounds;//将表尾视图与UIButton一起使用如何

CGSize buttonSize = CGSizeMake(300, 45);
CGRect viewRect = CGRectMake(0, 0, self.view.frame.size.width, buttonSize.height);
CGRect buttonRect = CGRectMake((viewRect.size.width-buttonSize.width) / 2 , 
                               (viewRect.size.height-buttonSize.height) / 2 , 
                               buttonSize.width, 
                               buttonSize.height);

UIView *footerView = [[UIView alloc] initWithFrame: viewRect];
footerView.backgroundColor = [UIColor clearColor];

UIButton *submitButton = [UIButton buttonWithType: UIButtonTypeRoundedRect];
submitButton.frame = buttonRect;
[submitButton setTitle:@"SUBMIT" forState:UIControlStateNormal];
[footerView addSubview: submitButton];

[(UITableView *)self.view setTableFooterView: footerView];

[footerView release];
但是,如果您想要完全相同的外观,则应在下一节中使用默认的UITableCell(UITableViewCellStyleDefault),而不是UIButton

UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
cell.textLabel.text = @"SUBMIT";
cell.textLabel.textAlignment = UITextAlignmentCenter;

这是如何创建的?