Ios 键盘和UITextField之间的奇怪空格

Ios 键盘和UITextField之间的奇怪空格,ios,objective-c,ios7,Ios,Objective C,Ios7,在我的视图控制器中,我有一个tableview,这就是我创建单元格的方式 CGFloat cellFontSize; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { cellFontSize = 15.0f; } else { cellFontSize = 12.0f; }

在我的视图控制器中,我有一个tableview,这就是我创建单元格的方式

 CGFloat cellFontSize;

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {

            cellFontSize = 15.0f;
        }
        else
        {
            cellFontSize = 12.0f;
        }


        LvFormTextboxCell *cell = [tableView dequeueReusableCellWithIdentifier:FormTextCell];
        if (cell==nil)
        {
            cell = [[LvFormTextboxCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FormTextCell];
        }

        [cell setLabelValue:extended_item.item_description];

        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell setTag:1];
        return cell;
LvFormTextboxCell是

#import "LvFormTextboxCell.h"

@implementation LvFormTextboxCell


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        fromLabel = [[UILabel alloc]initWithFrame:CGRectMake(10,0,300,40)];
        fromLabel.text = @"sss";
        fromLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0f];
        fromLabel.numberOfLines = 1;
        fromLabel.adjustsFontSizeToFitWidth = YES;
        fromLabel.adjustsLetterSpacingToFitWidth = YES;
        fromLabel.minimumScaleFactor = 10.0f/12.0f;
        fromLabel.clipsToBounds = YES;
        fromLabel.backgroundColor = [UIColor clearColor];
        fromLabel.textColor = [UIColor blackColor];
        fromLabel.textAlignment = NSTextAlignmentLeft;


        inputTxt = [[UITextField alloc]initWithFrame:CGRectMake(10, 40, 300, 40)];
        inputTxt.borderStyle = UITextBorderStyleRoundedRect;
        inputTxt.clearButtonMode = UITextFieldViewModeWhileEditing;
        inputTxt.delegate = self;
        inputTxt.textColor = [UIColor blackColor];
        [inputTxt setUserInteractionEnabled:NO];
        [inputTxt setReturnKeyType:UIReturnKeyNext];
        inputTxt.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:inputTxt];
        [self.contentView addSubview:fromLabel];


        /*
        inputTxt = [[UITextField alloc] initWithFrame:CGRectMake(10, 200, 300, 40)];
        inputTxt.borderStyle = UITextBorderStyleLine;
        inputTxt.backgroundColor = [UIColor grayColor];
        inputTxt.textColor = [UIColor whiteColor];
        inputTxt.font = [UIFont systemFontOfSize:15];
        inputTxt.placeholder = @"enter text";
        inputTxt.autocorrectionType = UITextAutocorrectionTypeNo;
        inputTxt.keyboardType = UIKeyboardTypeDefault;
        inputTxt.returnKeyType = UIReturnKeyDone;
        inputTxt.clearButtonMode = UITextFieldViewModeWhileEditing;
        inputTxt.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        inputTxt.delegate = self;
        [self.contentView addSubview:inputTxt];
        */
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)startEditing
{
    [inputTxt setUserInteractionEnabled:YES];
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    [inputTxt resignFirstResponder];
    [inputTxt setUserInteractionEnabled:NO];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"TableNormal" object:nil];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{

    [inputTxt resignFirstResponder];
    [inputTxt setUserInteractionEnabled:NO];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"TableNormal" object:nil];

    return YES;
}

- (NSString*)getTextValue
{
    return inputTxt.text;
}

- (void)setTextValue:(NSString *)content
{
    inputTxt.text = content;
}

- (void)setLabelValue:(NSString *)content
{
    fromLabel.text = content;
}

@end
这就是结果

更新

在我的didSelectRowAtIndexPath中

if (extended_item.item_type == LvExtendedItemTypeTextbox)
{

        self.tableOptions.frame = CGRectMake(0, 0, tableOptionsWidth, 200);
        [self.tableOptions scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
        LvFormTextboxCell *cell = (LvFormTextboxCell*)[self.tableOptions cellForRowAtIndexPath:indexPath];
        [cell startEditing];

}

非常感谢

这只是一个提示,但这个空间的大小将与导航栏和状态栏的大小完全相同。你的观点在他们下面。希望这有帮助!该空间在具有控件的其他视图中具有不同的外观。