iOS 8.0.2 and iPhone plus when I set UIButton backgroundImage in XIB,UIButton become bigger though this button have autolayout with height and weight - uibutton

iOS 8.0.2 and iPhone plus when I set UIButton backgroundImage in XIB,UIButton become bigger though this button have layout with height and weight after running
UIButton in xcode:
and layout :
but running in iPhone plus iOS8.0.2:
but in other iPhone like 5s,6 this button is ok!!!
the backgroundimage like this :

i have setup (https://github.com/usamaiqbal83/TestingProject) a repo for your case, it is not happening for me you can compare your setup with mine . i checked it on simulator
or if i am not able to understand your scenario clearly, kindly setup a repo i will gladly take a look.

when I set the Image like this:
it is working .
I do not what has happen, but just it is.
any body know why it is?

Related

Setting content mode of UIButton not working in XCode6

I have previously had no issue setting the content mode of a UIButton from the storyboard, I would just set the background image of the button and then under the view section I would set the mode to AspectFit or which ever mode was relevant.
When I try the above steps now in XCode 6 it makes no difference, the image remains scale to fill always.
I've also tried setting the default image instead of the background image and setting the content mode in code like this:
self.myButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
But it does not make a difference either, it remains scale to fill always.
Have apple changed the way this is done in XCode 6 or is this just a red herring and I'm missing something else?

UIImageView off screen in landscape mode

I am using iOS7 and I have a UIViewController with a UIImageView that fill the screen in Aspect Fit mode.
In portrait mode the image looks good but in landscape mode the image is off screen.
Can anyone help me?
Thanks ;-)
As you can see the image is in the same position in both orientations. It's the same distance away from the top panel and pushed up against the left side of the screen. iOS doesn't automatically change the frame of the image for you when you change orientations. You have to either do it programmatically or use auto layouts to achieve the display you want.
AutoLayout Guide
Autolayout is a pain to learn at first but stick with it. It's a great solution when you get the hang of constraints and start modifying them programatically. In fact it's recommended you never set the frame explicitly, you should always use constraints to position and size frames.
As Literphor mentioned above. it is layout issue. Either use autolayout or do the trial and error (because you are not familiar with Autosizing) with settings shown in below image. That should fix the issue.
self.imageView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
You must "play" with autoresizingMask

iOS 7 + Auto Layout: Strange UIImageView behaviour

I've got a strange UIImageView behaviour:
I've got a UIViewController with an embedded UIImageView and a close button. Very basic stuff, done a thousand times. I didn't use Auto Layout that much in the past, but another view controller in the same Storyboard has nearly the same config and doesn't appear as strange as this specific one.
In my Storyboard the Controller looks like that:
...and on the device it looks like that:
That image is 1024x768, so it should be filled to the bounds. Content mode in the image view is Aspect fill. When i dismiss the view, i can see that the upper part of the image view must be hidden at the top with some negative Y or something.
I need Auto Layout in this storyboard, because it's an iPhone + iPad App with both orientations.
Has someone hat a behaviour like that before?
Thank you!
Edit:
Here is the layout panel:
First, get rid of the alignment constraints, they are not needed if you're already anchoring your view to every side with a set distance.
Second, check the mode property of your UIImageView in the interface builder. If the image was not big enough and you had it set for "TOP" instead of, say, "aspect fill", you'd see something like this even though the view is actually covering the whole screen.
I'm sorry that I have to say this, but it was, as you certainly thought, my own fault.
The problem was that I made a photo with the iPad, and the iPad can be used in both orientations in this app. The photo was taken and was then used for an own view that allows the user to put annotations on the image.
The image gets then saved, and that was were the problem occured: I call
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);
The landscape image was now taken into a portrait frame. After adjusting this and only allowing portrait mode, everything worked well.
Thanks anyways for your answers. And sorry for asking a question when the problem was another one and my own fault.

How to prevent UISegmentedControl from scaling segment images on iOS 7

I have an UISegmentedControl with 100x42 bounds. I've set up three segments with 26x26 images and 4x42 divider images. The three segment images should fit in the segments, but they are scaled and for the worse they seem to fit vertically and are only scaled down horizontally, thus loosing proportions.
This problem appeared after i changed to Xcode 5 and iOS 7 SDK. Before that the segment images were displayed with correct proportions and in original size.
I'm not using interface builder. I've tried to set the segment sizes manually and setting the segmented control's contentMode to UIViewContentModeScaleAspectFill without help.
Is there any way to force the UISegmentedControl to simply render the images as they are?
You may set auto layout constraints to correctly define UISegmentedControl frame. Like this
I know this is a late answer but I have the same issue testing an app for IOS 7.1.
If you set the image in the code it's working properly. Example:
- (void)viewDidLoad {
[super viewDidLoad];
[_segmentedControl setImage:[UIImage imageNamed:#"779-users-toolbar"] forSegmentAtIndex:0];
}
In my project I have the normal image, and the #2x & #3x versions of the image.
I tested the code in 7.1, xcode 6.1.
When I run it in 8.1 the image set via IB works properly as well, so this may be a bug in 7.1 that has been fixed in 8.

UISlider background disappears

I use UISlider for video player to track and change the location of the playback.
It seems that when ever I change the slider.value from code, the background line of the slider disappears.
It changes from this:
to this:
(I added the gray background color)
What can cause this issue?
Solved.
As trojanfoe suggested, I looked at this question:
iOS - iPhone : UISlider track image disappearing randomly
In simple words: I used [UISlider setValue:animated:] and made sure I don't get NaN, which was the real problem.