Ios 聚焦输入文本框上的布局溢出

Ios 聚焦输入文本框上的布局溢出,ios,uikit,Ios,Uikit,我一直在试图解决这个溢出问题,但似乎这不是因为我做得不对。是否有其他人遇到过此问题并能够解决 当我关注输入文本视图布局时,默认方向会向上滑动布局,但这与iPhone的顶部栏重叠。我该如何解决这个问题?我在下面附上了一个截图 非常感谢您的帮助 我的视图控制器: #import "Contribute_VC.h" #import "HomePage_VC.h" #import "ChatViewCell.h" @interface Contribute_VC () @end @implem

我一直在试图解决这个溢出问题,但似乎这不是因为我做得不对。是否有其他人遇到过此问题并能够解决

当我关注输入文本视图布局时,默认方向会向上滑动布局,但这与iPhone的顶部栏重叠。我该如何解决这个问题?我在下面附上了一个截图

非常感谢您的帮助

我的视图控制器:

#import "Contribute_VC.h"
#import "HomePage_VC.h"

#import "ChatViewCell.h"

@interface Contribute_VC ()

@end

@implementation Contribute_VC

(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

_AnswerView.layer.cornerRadius = 5;
_AnswerView.layer.borderColor = [UIColor whiteColor].CGColor;
_AnswerView.layer.masksToBounds = YES;

_btn_YES.layer.cornerRadius = 10;
_btn_YES.clipsToBounds = YES;

_btn_NO.layer.cornerRadius = 10;
_btn_NO.clipsToBounds = YES;
} 
 (IBAction)back_button:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}

(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

IBAction)buttonClicked:(id)sender {

 if ( ([sender tag] == 1))
 {
     [_btn_Contribute setBackgroundColor: [UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f]];
     [_btn_Contribute setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];


    _btn_Practice.backgroundColor = [UIColor whiteColor];
     [_btn_Practice setTitleColor:[UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f] forState: UIControlStateNormal];

     _btn_Chat.backgroundColor = [UIColor whiteColor];
    [_btn_Chat setTitleColor:[UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f] forState: UIControlStateNormal];

}
if ( ([sender tag] == 2))

{

    [_btn_Practice setBackgroundColor: [UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f]];
    [_btn_Practice setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

    _btn_Contribute.backgroundColor = [UIColor whiteColor];

    [_btn_Contribute setTitleColor:[UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f] forState:UIControlStateNormal];


    _btn_Chat.backgroundColor = [UIColor whiteColor];

    [_btn_Chat setTitleColor:[UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f] forState:UIControlStateNormal];


}

if ( ([sender tag] == 3))
{
    [_btn_Chat setBackgroundColor: [UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f]];


    [_btn_Chat setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];


    _btn_Contribute.backgroundColor = [UIColor whiteColor];

    [_btn_Contribute setTitleColor:[UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f] forState:UIControlStateNormal];

    _btn_Practice.backgroundColor = [UIColor whiteColor];

    [_btn_Practice setTitleColor:[UIColor colorWithRed:95/255.0f green:172/255.0f blue:47/255.0f alpha:1.0f] forState:UIControlStateNormal];


}
}


/////////     TABLE VIEW   ////////////

(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
  return 1;
}

(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   return 20;//getDetail.count;
}

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"ChatViewCell";

    ChatViewCell*Cell = (ChatViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (Cell == nil)
  {
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ChatViewCell" owner:self options:nil];
    Cell = [nib objectAtIndex:0];
  }

    Cell.selectionStyle = UITableViewCellAccessoryNone;


  return Cell;
}

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

 // Use this to separate cells

 (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
 {
    return 5;
 }

 (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
 {
   UIView *headerView = [[UIView alloc] init];
   headerView.backgroundColor = [UIColor clearColor];
   return headerView;
 }

@end

这不是通常的行为,而是应该“呆在原地”。您在视图控制器中添加了什么代码?@AlejandroIván我已经更新了问题中的代码。请检查。这是故事板标记XML。我说的是你添加的Objective-C和/或Swift代码?我没有看到任何与键盘相关的代码,可能是你在库中做的或类似的事情。如果您想滚动内容,而不是简单地更改内容视图的框架或边界,那么最好使用
UIScrollView
并简单地更改其
contentInset
。与这个答案大致相同:您要问的问题位于此处:,但是,对于这个问题仍然没有真正“好”的解决方案