TabBar image size in landscape mode - ios

I am working on application which supports both Portrait and Landscape mode. I am using default TabBarController in Storyboard.
NOTE: I am adding custom offset on images
In Portrait mode the image size of tabbarItems are looking well nice.
But when i am rotating my device to landscape mode, the TabbarItems
images are looking too small
How can I resolve this so that i can have the bigger size for landscape mode.
Here are the screenshots for both portrait and landscape mode.
Any better approach for tab bar in landscape mode ?
Thanks!
#Edit 1
I added custom offset for landscape mode (all are having a negative value) and the size increased. but on tapping the size is increasing (on each tap)
#Edit 2
I removed left and right inset from landscape mode and the increasing image size is fixed but the size is again decreased.
Any Suggestion about what's happening ?

I just ran into this, you need to set the tabbarItem's landscapeImagePhoneInsets property as well.

Tried to add imageInsets
var item0: UITabBarItem? = tabBarController.tabBar.items[0]
item0?.imageInsets = UIEdgeInsetsMake(3, 0, -3, 0)

If you have set icons from storyboard try setting same image for landscape also.See the landscape property and set image like this

Related

Tab Bar titles aren't staying in position when you change orientation

Heres the problem
Portrait Mode :
Landscape Mode :
So as you can see the offset doesnt scale properly, because i put 0,-17 when its potrait it shows normally but when you switch to landscape its the opposite like 0,17 instead. Im not sure how to fix..

iPad Camera OverlayView Orientation issue

My application is always run in Landscape mode only. I have add four custom buttons on overlay view dynamically. I want to change the position of buttons when orientation change in landscape and portrait mode.How to position my Camera Overlay View buttons in a different location when my device orientation will changing?
Please help me to fix my problem. Thanks.
I have the same problem. It's not that we're not receiving the notifications. The problem is that the camera overlay view doesn't resize itself to fit the new orientation. For example, the view will rotate when going from landscape to portrait but the view still has a landscape aspect ratio, i.e., the view is wider than it is high.

Change origin in iPad landscape

In my iPad app I set the supported interface orientations only to both landscape modes.
I have a UIView with the background color set to red and I initialise it with frame x:0 y:706 w:1024 h:60.
The red UIView doesn't appear where I want. The origin will be in the TOP-RIGHT corner (as if the iPad is still in portrait orientation mode), even if the iPad simulator starts in landscape mode. I want the origin to change to the TOP-LEFT corner when in landscape mode.
How can I do this? I have to mention that I'm new to working with different landscape modes.
Line #iPhoneDeveloper has already said It starts in Portait mode and then rotate to Landscape.
you can set coordinates like it is portrait and set autoresizingMask of your view, so your view will be resized and placed for landscape
or
you can override the following method in your view controller
- (void)viewDidLayoutSubviews
and set the frames of your subviews.
The method get called after all rotations.
Whenever iOS app starts, it default orientation stays portrait if you have setup both landscape orientations. You can show your UIView in top-right corner by transforming it.
see here Rotate UIView iPhone
A good way to know the device orientation is to check the statusbar orientation:
if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))...
this way you can put your button in the right spot.

UIBarButtonItem support portrait and landscape sizes with a custom view?

I have a UIBarButtonItem which is just an image, I wanted to use this image as the background image of a bar item with an empty string title.
But the width didn't work out correct, in order to have the correct dimensions, I made a UIBarButtonItem with a custom view which was a UIButton with the image set.
The problem I have is that in landscape mode this custom view doesn't resize to fit correctly the smaller navigation bar.
I tried making my button autoresize by allowing flexible height, but it's preserving the top and bottom margins of the portrait and now my button is very squashed.
The reason I originally wanted to use a bar item with empty title was to use the appearance protocol to set the background image for bar metrics default and landscape to bypass this problem.
How can I make my UIBarButtonItem support portrait and landscape sizes with a custom view?
I have a dedicated landscape image so that it's just smaller, not distorted which I want to use.
Portrait:
Landscape:
Landscape with autoresizing, note the margins from portrait are causing an exaggerated squashing of the bar button.
The best answer is to provide two images one for portrait mode and the other is for the landscape mode and your code will be like
UIBarButtonItem *barBtnLeft= [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"yourImg.png"] landscapeImagePhone:[UIImage imageNamed:#"yourImg_Landscape.png"]style:UIBarButtonItemStyleBordered target:self action:#selector(yourSelector:)];
I know this post is old, but it luck the right answer, I hope newcomer, like me, will get the help with this solution.
I should mention here that landscape image should be smaller by 0.75f scale.
Is the image you're using resizable? Did you create it with - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets?
If you just want it to maintain it's aspect ratio, and the custom view you've used is a UIImageView (which I assume it is), you can set the contentMode property of the image view to make it scale while maintaining aspect ratio. You're probably gonna want to use UIViewContentModeScaleAspectFit.

Automatically detect image when orientation change

When I change mode of view then uiview don't show same image in portrait mode which is landscape mode. so how implement it? I required same image view in both mode. if image1.jpg is in portrait mode then same image will shown in landscape mode when orientation change.
Example;
NOte: here i have done with View but u have to do with UIImageview;
select ur UIImageview in IB then see autoresizing
then set like below in the autoresizing arrow marks.note dim arrow and dark arrow marks

Resources