logo
down
shadow

How to calculate proper keyboard contentInset for UIScrollView inside of a modally presented form sheet UIViewController


How to calculate proper keyboard contentInset for UIScrollView inside of a modally presented form sheet UIViewController

By : luis
Date : October 19 2020, 08:10 AM
help you fix your problem Apple states in their documentation:
code :
// MARK: - Keyboard Notifications
@objc func keyboardVisibilityChanged(notification: Notification) {       
    if notification.name == UIResponder.keyboardWillHideNotification {
        scrollView.contentInset = .zero
        scrollView.scrollIndicatorInsets = .zero
    } else {
        guard let userInfo = notification.userInfo,
            let value = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue,
            let window = view.window else {
                assertionFailure()
                return
        }

        let keyboardEndFrameInWindowCoordinates = value.cgRectValue
        let viewFrameInWindowCoordinates = window.convert(scrollView.frame,
                                                          from: scrollView.superview)

        let contentInsetBottom: CGFloat

        // If the keyboard is below us, no need to do anything.
        // This can happen when a hardware keyboard is attached to a modal form sheet on iPad
        if keyboardEndFrameInWindowCoordinates.origin.y >= viewFrameInWindowCoordinates.maxY {
            contentInsetBottom = 0
        } else {
            let bottomEdgeOfViewInWindowBottomCoordinates = window.frame.maxY - viewFrameInWindowCoordinates.maxY
            contentInsetBottom = keyboardEndFrameInWindowCoordinates.height - bottomEdgeOfViewInWindowBottomCoordinates - view.safeAreaInsets.bottom
        }

        let insets = UIEdgeInsets(top: 0,
                             left: 0,
                             bottom: contentInsetBottom,
                             right: 0)

        scrollView.scrollIndicatorInsets = insets
    }
}


Share : facebook icon twitter icon
Determining if a UIViewController is being presented modally

Determining if a UIViewController is being presented modally


By : Jay
Date : March 29 2020, 07:55 AM
it should still fix some issue Got an answer on Twitter. I ended up subclassing UITabBarController and adding a BOOL isModal instance property which is set to YES when presenting modally. Then subviews can use self.tabBarController with a cast to the subclass to access the isModal property and render/behave accordingly.
How to set the background of a modally presented UIViewController?

How to set the background of a modally presented UIViewController?


By : trox
Date : March 29 2020, 07:55 AM
To fix the issue you can do Found the answer: self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
Assigning Delegate for Modally presented Form Sheet in iPad

Assigning Delegate for Modally presented Form Sheet in iPad


By : lynnepepplernyzk
Date : March 29 2020, 07:55 AM
should help you out I can see two ways to do this. You should be able to get a reference to that left most controller in your post with [self.navigationController presentingViewController] -- you'll need to cast self.navigationController to whatever class that is. Then in your NewAftpViewController, you can set the delegate like this:
code :
self.delegate = [(cast here)self.navigationController presentingViewController];
Why isn't the rootViewController of my modally presented (form sheet) navController aware of it's smaller size when pres

Why isn't the rootViewController of my modally presented (form sheet) navController aware of it's smaller size when pres


By : Andrea Dyck
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Not sure why you're having the issue you're having. I'm using the following code:
code :
- (void)presentNewView {
    NewViewController *newVC = [[NewViewController alloc] initWithNibName:nil bundle:nil];
    newVC.view.backgroundColor = [UIColor redColor];

    UINavigationController *newNC = [[UINavigationController alloc] initWithRootViewController:newVC];
    newNC.modalPresentationStyle = UIModalPresentationFormSheet;

    [self.navigationController presentViewController:newNC animated:YES completion:NULL];
}
Moving a modally presented UIViewController up when keyboard appears on iPad with iOS8

Moving a modally presented UIViewController up when keyboard appears on iPad with iOS8


By : Mike
Date : March 29 2020, 07:55 AM
With these it helps We'll, I'm pretty stoked now. I've figured this out. This can be solved using the new, iOS8 UIPresentationController. I'll give some sample code below. And try to link in a working project zip file later.
The first view controller is the root view controller of the example app. Code for the ChangeFrameTransitioningDelegate follows below. "Dialog" is just an empty view controller class.
Related Posts Related Posts :
  • Inserting into Array and comparing Dates Swift iOS Code
  • IBDesignable UI is not showing in Xcode 9 with Swift
  • Ask for only Request Always Authorization, and not When-In-Use Authorization
  • "Google/Analytics.h file not found" after updating pod to GoogleAnalytics
  • Post request with HTTP header parameters
  • Managing cookies for a domain in Associated Domains
  • Array items showing error in IOS
  • Saving asynchronously downloaded files' contents to SQLITE
  • Swift 4 - animating both alpha and constraint affects other components alpha value
  • UIView animation in completion block starts with displacement
  • List all Apps and Track Internet Usage
  • Handling Back To Back HTTP Posts SWIFT 4.0
  • Azure App Service Push - registration endpoint
  • Select multiple item in a tableView
  • Apartment number / Unit number returned from google places api
  • How to align UICollectionViewCells from left to right?
  • How can I add search option on UIPickerview in ios?
  • Scenekit - physicsWorld setup to prevent kinematic nodes to intersect
  • Carthage Build Failed
  • swift 3, ios 10 - push notification firebase is not received
  • App Xcode 8 to Xcode 9 - Prevent Auto Hide Status Bar
  • How to pop back to a TableViewController?
  • Is UserDefaults thread safe in Swift? How to check it?
  • UISwitch in a table selects multiple cells when switch state on
  • iOS App with no story board (Size classes and Device type limitations)
  • AudioKit issue, mic not sensitive enough
  • send indexpath to Firebase (like button)
  • UIColor saturation brightness values different from the regular saturation luminosity values of a color
  • JSON: Extracting Data Using Alamofire and Swift 3
  • invalid_grant on OAuth2 request when obtaining access_token from SSO in App
  • ABNewPersonViewController using contact framework
  • Design iOS button scalable
  • Subclassing NSLayoutConstraint constant based on screen height
  • Migrate Realm 2.x List of Object to Realm 3.x List of String (or other primary type)
  • Using BLE RSSI value for connect-by-proximity
  • Backgroundcolor of NSTextfield
  • Firebase modifying uid in every view
  • How to rotate orientation?
  • Upload a new version of ios app to app store?
  • UIScrollView do not scroll down to its original position when keyboard disappear
  • What is the most effective way of tracking time/dates in an iOS/Swift application?
  • WatchKit get user's preferred handedness
  • Location permission dialog is shown and immediately disappears
  • Combine these regex expressions
  • How to save an array of HKQuantitySamples (heart rate) to a workout
  • RestKit mapping with parent key as attribute and key contains parenthesis
  • How to add UITextField programmatically to UIScrollView without breaking constraints?
  • How to make a view height grow depending on its child views contents
  • Some users experiencing NSInternalInconsistencyException crash
  • Mark successful siesta response as error
  • Using a modified PDFTron Tools Framework
  • How can I use universal links when I call openURL inside my own app?
  • NSArray of doubles iOS (Objective c)
  • Passing data from embedded PageViewController to parent View Controller
  • Reuse item inside a row when scrolling
  • Realm Relation how to implement
  • error: generic parameter 'T' could not be inferred in swift
  • Adding shadow to UITextView makes text expand out of UITextViewFrame
  • How to change the string in seconds to minutes in Swift3?
  • Search bar is refreshing the index of my table view cell
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org