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:
- Use instead of the
UITableViewController
simply aUIViewController
- set the datasource and delegate on your own. - 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
How to Switch to Different Storyboard for iPhone 5
Custom Font Sizing in Xcode 6 Size Classes Not Working Properly with Custom Fonts
Programmatically Dial a Phone Number and Pass Dtmf Using the iPhone Sdk
Best Way to Parse Url String to Get Values for Keys
Uitableviewcell Buttons with Action
Refresh Devices in Team Provisioning Profile Managed by Xcode 7
Swift - How to Hide Back Button in Navigation Item
How Does Cellforrowatindexpath Work
Enterprise In-House App Distribution
Swift Performselector:Withobject:Afterdelay: Is Unavailable
When How to Activate/Deactivate Layout Constraints
Why Push Notifications Is Not Working on Testflight
How to Change the Tint Color of the Clear Button on a Uitextfield
Why Does My Programmatically Created Screenshot Look So Bad on iOS 7
Uitableviewcell Checkmark to Be Toggled on and Off When Tapped
Find the Tangent of a Point on a Cubic Bezier Curve
Distancefromlocation - Calculate Distance Between Two Points