logo
down
shadow

How to make UIImageView correct frame size?


How to make UIImageView correct frame size?

By : user2952328
Date : November 19 2020, 12:41 AM
Does that help just call this line under your second view controller in ViewDidLoad()
code :
self.imageView.contentMode = UIViewContentModeScaleAspectFit;


Share : facebook icon twitter icon
UIImageView Define Size without .frame

UIImageView Define Size without .frame


By : regnskygge
Date : March 29 2020, 07:55 AM
it should still fix some issue I have a UIScrollView with paging enabled. I want to full it with images and I have a UIImageView which needs to be made to fit without using .frame. This is because it doesn't work with Autolayout enabled. Not using Autolayout isn't an option. , Why don't you use autolayout to layout the images?
code :
//Prepare and load the view
[scrollView1 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), (kScrollObjHeight))];
scrollView1.pagingEnabled = YES;
[scrollView1 setShowsHorizontalScrollIndicator:NO];



UIImageView *firstImage = imageViews[0];
UIImageView *lastImageView = [imageViews lastObject];
UIImageView *previousImageView = nil;
NSMutableArray *constraints = [NSMutableArray new];
for (UIImageView *imageView in imageViews){
    [scrollView1 addSubview:imageView];
    //set the size of the images
    [constraints addObject:[NSLayoutConstraint constraintWithItem:imageView
                                                        attribute:NSLayoutAttributeWidth
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:nil
                                                        attribute:NSLayoutAttributeNotAnAttribute
                                                       multiplier:1.0f
                                                         constant:kScrollObjWidth]];
    [constraints addObject:[NSLayoutConstraint constraintWithItem:imageView
                                                        attribute:NSLayoutAttributeHeight
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:nil
                                                        attribute:NSLayoutAttributeNotAnAttribute
                                                       multiplier:1.0f
                                                         constant:kScrollObjHeight]];
    //remove autoresizing masks
    [imageView setTranslatesAutoresizingMaskIntoConstraints:NO];
    //pin the top of the imageview to the top of the superview
    [constraints addObjectsFromArray:[NSLayoutConstraint constraintWithVisualFormat:@"V:|[imageView]"
                                                                            options:0
                                                                            metrics:nil
                                                                              views:NSDictionaryOfVariableBindings(imageView)]];

    if ([firstImage isEqual:imageView]){ //pin the first image view to the left of the scrollview
        [constraints addObjectsFromArray:[NSLayoutConstraint constraintWithVisualFormat:@"|[firstImage]"
                                                                                options:0
                                                                                metrics:nil
                                                                                  views:NSDictionaryOfVariableBindings(firstImage)]];
    }

    if (previousImageView){ //pin any imageViews to the previous imageViews
        [constraints addObjectFromArray:[NSLayoutConstraint constraintWithVisualFormat:@"[previousImageView][imageView]"
                                                                               options:0
                                                                               metrics:nil
                                                                                 views:NSDictionaryOfVariableBindings(imageView, previousImageView)]];
    }
    previousImageView = imageView;
}

[scrollView1 addConstraints:constraints];
changing UIImageView frame size programmatically

changing UIImageView frame size programmatically


By : Christian Llerena
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I have a UImageView with initial dimensions set from the xib as: , You can do that in viewDidLayoutSubviews
code :
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    // Do your resizing
}
UIImageView initWithFrame not correct size when using self.view.frame

UIImageView initWithFrame not correct size when using self.view.frame


By : 虞天乐
Date : March 29 2020, 07:55 AM
Any of those help I am having an issue where when I create several UIImageViews programmatically and give them the frame of the main view they end up being half the size. I am building the app in the simulator on a 3.5in retina screen. I checked the frame of the main view and it is (in Landscape) 480pts wide, 320pts high and the origin is at (0,0). It should fill the same part of the screen as the main view (blue in the image below). I'm sure I'm missing something super simple but I just don't see it and searching around for a bit hasn't yielded an answers. , First : You need set contentMode for imageView
code :
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.frame = self.view.bounds;
How to get the frame size of a UIImageView in a UICollectionView cell

How to get the frame size of a UIImageView in a UICollectionView cell


By : Vallabh Naik
Date : March 29 2020, 07:55 AM
I wish this helpful for you I'm trying to get the frame size of a UIImageView inside a UICollectionViewCell. I have currently tried to achieve this using thumbnailImageView.frame.size but this returns (0.0, 0.0) no matter where I call this method from. , So the solution to the problem was to use this method:
code :
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
    }
UIImageView Frame size changing using AutoLayout

UIImageView Frame size changing using AutoLayout


By : Martin McFly
Date : March 29 2020, 07:55 AM
To fix the issue you can do If you are using AutoLayout.
Step 1: Select the UIImageView, click on pin in bottom right.
Related Posts Related Posts :
  • Unclear about releasing CFDictionaryRef
  • CordovaError: Promise rejected with non-error: Error code 65
  • How to append NSMutable strings into a UILabel
  • CustomCell label value does not change
  • Display ad in iAd Bannerview iAd Network
  • Warning: "Could not get traitsetID for iPhone11,6" (Assets.xcassets)
  • Changing root view controller after iOS app has loaded.
  • SocketRocket and iOS certificate pinning
  • Draggable UIButton Snap To a Circle Path
  • Running FireBase in the background
  • resizing UIPopoverController to fit UITableController
  • UICollectionView Exception Crash
  • targeting iOS5 - will it work on iOS6 also?
  • FBLoginView get email
  • Scale UIImages height to UIImageView height
  • Creating a custom progress indicator in ios
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org