logo
down
shadow

Programmatically set size of UIView from Storyboard


Programmatically set size of UIView from Storyboard

Content Index :

Programmatically set size of UIView from Storyboard
Tag : ios , By : Brianna
Date : November 23 2020, 01:01 AM

I wish this help you I have placed UIView in UIScrollView in Storyboard. The UIView is pinned to the all the sides of the UIScrollView. I am trying to set the size of UIView programatically because it is needed for scrolling to work properly. How can I programmatically set the width and height of the UIView? for any help as I am trying to solve the problem already for a week... , You'll need to change the frame of your view as below:
yourView.frame = CGRectMake(x,y,calculatedWidth,calculatedHeight);

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Duplicate existing UIView in a ScrollView programmatically? (Storyboard)


Tag : objective-c , By : techthumb
Date : March 29 2020, 07:55 AM
around this issue i use Storyboard and i want to duplicate and add an existing UIView (with all "childs" like UILabels) progammatically to a ScrollView. So first i created a custom UIView-Class for that View (EventView) in which i initialize the new text for the UILabels by identifying them with their Tags. Now i want to add these EventViews to a Scrollview like this: , to duplicate a view or ui object there is a method i learned here
 NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject: viewToBeDuplicated];

 UIView * newView = [NSKeyedUnarchiver unarchiveObjectWithData: archivedData];

UIView respect uinavigationbar size storyboard


Tag : ios , By : Ansari
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Make sure the top constraint for the view you added is pinned to the top layout guide, not the superView.

Programatically change size of UIView that is on Storyboard


Tag : ios , By : dexteryy
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Acording to this answer
The methods viewWillAppear: and viewDidLoad: have no layout information. Any layout changes made here will be lost when viewDidLayoutSubviews: is called later on.

Storyboard Constraints Don't Affect Custom UiView Size


Tag : swift , By : beng
Date : March 29 2020, 07:55 AM
will help you I found the solution i use view.frame = self.bounds in init and the size automatically adjusts based on the constraints in the storyboard.

How to size a popup programmatically in Swift without storyboard?


Tag : swift , By : KingGuppy
Date : March 29 2020, 07:55 AM
To fix this issue I found out a better way to achieve my goal. Instead of sizing the popup in main view I moved the sizing logic to the popUpView itself. Here is the final code.
func presentPopup() {
        let popupVC = MyPopupViewController()
        popupVC.modalPresentationStyle = .overCurrentContext
        popupVC.modalTransitionStyle = .crossDissolve
        present(popupVC, animated: true, completion: nil)
}
class MyPopupViewController: UIViewController {
    // UI elements for popup will be added to popupBox view
    let popupBox: UIView = {
       let view = UIView()
        view.translatesAutoresizingMaskIntoConstraints = false
        view.backgroundColor = .green
        return view
    }()

override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .clear

        self.definesPresentationContext = true

        setupViews()

    }


func setupViews() { 
     view.addSubview(popupBox)

     // autolayout constraint for popupBox
        popupBox.heightAnchor.constraint(equalToConstant: 200).isActive = true
        popupBox.widthAnchor.constraint(equalToConstant: 300).isActive = true
        popupBox.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
        popupBox.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
}

}
Related Posts Related QUESTIONS :
  • How to write if condition with using label text (Int) values
  • Swift Cannot use instance member within property initializer
  • Issue while getting the frame of the keyboard
  • dynamicMemberLoookup ExpressibleByStringLiteral parameter swift
  • iOS Unity Firebase Messenger Xcode Compile Error: FIRDynamicLinks
  • Firebase Storage Image Cache not updating SWIFT
  • unhandled js exception: application main has not been registered expo TestFlight
  • App freezes on IOS when navigate to another screen - React Navigation
  • How to create haptic feedback for a Button in SwiftUI?
  • How can I achieve automatic scrolling in my text view when text comes down to the keyboard level in Swift?
  • how to get the location with the CLLocationManager every 10 secondes?
  • Calling completion handler of a function from Timer selector function Swift
  • How to make SwiftUI view fullscreen?
  • RAM, JSC, Views, UI and JS usage table appearing whenever I launch my react native app. How to remove this table?
  • Change status bar background color using UIStatusBarManager
  • Should we make tapGesture component an IBAction or IBOutlet to capture the tap event?
  • Iframe automatically goes full screen using Ionic 3.9.2 on iOS
  • How to calculate score out of 1000 given some seconds (In Double)
  • How to calculate time (minutes) between two dates in swift?
  • There was problem loading requested app.it looks like you may be using LAN URL
  • Swift circular corners doesn't work properly on different screen sizes
  • How change .navigationBarTitle font in SwiftUI?
  • What happens if `MPSCNNConvolutionDataSource` protocol's `load` method return false?
  • Why does the UIBarButtonItem not show up when I create it with code?
  • How to prevent following view controller inheriting navigation view controller bar?
  • What does it mean when .xcodeproj files are shown in red in Xcode?
  • Xcode SwiftUI how to scroll the Preview Canvas?
  • Expand tableview and increase scrollview content size by an appropriate difference on clicking a button inside a table c
  • xcodebuild failed with return code: 65 - using CLI/Appcenter but no error messages
  • "'isDeveloperModeEnabled' is deprecated: This no longer needs to be set during development. " What is isDevelo
  • Right click in UIKit for Mac
  • How we Support Dark Mode in Current iOS App with iOS 13?
  • Security vulnerablility issue in ios mobile app
  • How to set a background color for the viewController in swiftUI?
  • SwiftUI : Segue navigation
  • iOS 13 Custom UISearchBar _searchField crash
  • USDZ models have holes in SceneKit but not QuickLook
  • Why does iOS Password Autofill not prompt to save password on keychain?
  • Pushing information to firebase after event is created(Firebase-Realtime-Database)
  • Xcode 11 Beta and Carthage bootstrap
  • How to change the status bar background color and text color on iOS 13?
  • Using Core Data with SwiftUI
  • How should I do to wait all the data downloaded completely and show on TableView?
  • Can we specify the number of rows that can be shown in each section of a collection view
  • Why sometimes completion handler not called?
  • Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements
  • In UIKit we can set label.numberOfLines = 0 when we do not know how many lines the text will take? What is the alternati
  • Swift ISO8601 format to Date returning fatal error
  • SwiftUI Login Page Layout
  • Xcode: Could not locate installed application. Install claimed to have succeeded, but application could not be found on
  • See the TestFlight crash log in the Xcode
  • Why does zero UIView's CALayer.speed stops UIAlertController's buttons from working?
  • Firestore collectionGroup query returns empty result
  • Modify text in SwiftUI
  • CNCopyCurrentNetworkInfo with iOS 13
  • WWDC 2019 - iOS13 April 2020 requirement
  • Nativescript IPhone X - How to "hide" home indicator behind two swipes to go to home screen
  • Should I use a singleton location manager in Swift?
  • Accessibility problem in reusable TableViewCell
  • Remove top line containing Done button from Keyboard Using Storyboard or in Swift
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com