0

I have been trying to fix this overflow issue but seems like it is not due to anything that I've not done right. Has anyone else experienced this issue and were able to fix it?

When I focus on an input textview layout, the default orientation slides the layout upwards but this overlaps with the top bar of the iPhone. How do I fix this? I've attached a screenshot below.

Any help is greatly appreciated.

iOS XCode layout text overflow issue

My view controller:

#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
Leo Natan
  • 55,734
  • 8
  • 140
  • 186
wibwaj
  • 143
  • 4
  • 16
  • That's not the usual behavior, is should "stay where it is". What code have you added to the view controller? – Alejandro Iván Dec 26 '16 at 21:07
  • @AlejandroIván I've updated the code in my question. Please check. – wibwaj Dec 26 '16 at 21:27
  • That's the storyboard markup XML. I was talking about Objective-C and/or Swift code you've added? – Alejandro Iván Dec 26 '16 at 21:30
  • @AlejandroIván sorry about that. I've edited as appropriate. Please review. – wibwaj Dec 26 '16 at 21:42
  • 1
    I don't see any keyboard related code, it's probably something you did in a library or something like that. If you want to scroll content, instead of simply changing the frame or bounds of your content view, you better use a `UIScrollView` and simply change the `contentInset` of it. Pretty much the same as this answer: http://stackoverflow.com/questions/13161666/how-do-i-scroll-the-uiscrollview-when-the-keyboard-appears – Alejandro Iván Dec 26 '16 at 21:56
  • @AlejandroIván thanks. I will go through this and post my result. – wibwaj Dec 26 '16 at 22:02
  • Do you use UITableViewController? – Fyodor Volchyok Dec 26 '16 at 22:10
  • @FyodorVolchyok yes that's what I have used. A UITableViewController – wibwaj Dec 26 '16 at 22:40
  • in this case solution suggested by @AlejandroIván doesn't fit since, as stated in doc, https://developer.apple.com/library/content/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html#//apple_ref/doc/uid/TP40009542-CH5-SW7, "Note: The UITableViewController class automatically resizes and repositions its table view when there is in-line editing of text fields. See View Controllers and Navigation-Based Apps in Table View Programming Guide for iOS." – Fyodor Volchyok Dec 26 '16 at 22:51
  • 1
    the question you're asking located here: http://stackoverflow.com/questions/18900428/ios-7-uitableview-shows-under-status-bar, however, there is still no truly "good" solution to that problem – Fyodor Volchyok Dec 26 '16 at 22:52
  • @FyodorVolchyok thanks for chipping in. I will check this out too. – wibwaj Dec 26 '16 at 23:11

0 Answers0