Disabling Automatic Scrolling of Uitableview When Editing Uitextfield Inside Uitableviewcell

Disabling automatic scrolling of UITableView when editing UITextField inside UITableViewCell

The autoscroll-behavior is located in the UITableViewController functionality.

To disable the automatic scrolling I found two ways:

  1. Use instead of the UITableViewController simply a UIViewController - set the datasource and delegate on your own.
  2. Override the viewWillAppear method and don't call [super viewWillAppear: animated]

With both solution you disable not only the Autoscroll, but also some other nice but not essential features, that are described in the overview of Apple´s class reference:

https://developer.apple.com/documentation/uikit/uitableviewcontroller

Stop UITableView from scrolling when textfield begin editing

You can stop the scroll by force set the contentOffset

- (void)textFiledTextDidBegin:(UITextField *)textField {
[your_tableView setContentOffset:your_tableView.contentOffset animated:NO];
}

How do I stop a tableView from scrolling when the keyboard appears?

The autoscroll-behavior is located in the UITableViewCONTROLLER functionality. To disable the automatic scrolling I found two ways:

1) use instead of the UITableViewController simply a UIViewController - set the datasource and delegate on your own

2) Override the viewWillAppear-Routine - and DON´T call [super viewWillAppear: animated]
With both solution you disable not only the Autoscroll, but also some other nice but not

essential features, that are described in the overview of Apple´s class reference: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewController_Class/Reference/
Reference.html

Disable Table View Scrolling

When you present P, set:

yourTableView.isScrollEnabled = false

And when you close your popover:

yourTableView.isScrollEnabled = true

Note: Maybe you will want to use a Protocol to enable the scroll again when you close your popover.

For that, I would add in your popover View Controller:

protocol ProtocolPopOver{
func enableScrollAgain();
}

Then, in that view controller:

var delegatePopOver:ProtoclPopOver?

And when you close your viewController:

self.dismiss(animated: true, completion: { delegatePopOver.enableScrollAgain() })

In your main view controller, when you present the popover, add:

popoverViewController.delegatePopOver = self

Implement the protocol near UIViewController:

class yourclass: UIViewController, ProtocolPopOver{...

And add the function:

func enableScrollAgain(){
yourTableView.isScrollEnable = true
}

Override automatic scrolling in UITextView?

I believe most of the UITableView's automatic scrolling code resides in the UITableViewController. For example, if you have a UITextField in one of the table rows that is towards the bottom of the screen, the table automatically scrolls upwards to make way for the keyboard when the user taps on the UITextField. As you want to minimize auto-scrolling, I would suggest not using the UITableViewController. Instead, just subclass UIViewController & make it implement UITableViewDelegate & UITableViewDataSource. That being said, you would also miss out on some of the good things that UITableViewController provides.

HTH,

Akshay

iOS: Disable UITableView animation when keyboard shows up

The automatic scrolling code resides in tableViewController, so auto-scrolling can't be disabled. Instead of subclassing from UITableViewController you can subclass from UIViewController and use a tableView inside it.
If you are willing to use UITableViewController itself, you can override viewWillAppear and don't call [super viewWillAppear].

Prevent keyboard from scrolling UITextField underneath headerview in UITableView?

I just needed to split up the UITableViewCell containing two UITextFields to two UITableViewCells (each containing a UITextField).



Related Topics



Leave a reply



Submit