UIImage displaying incorrectly in a UIImageView - iphone

I have an XIB file that looks like this:
As you can see I have a UIImageView at the bottom of the view, note its all contained within the view.
However, when I run the code which places a UIImage in the view, I get this:
Here is the image I am trying to display:
Image
Why does it go off the bottom of the screen? I've seen similar behaviour in some of my other projects, whats going on?
Thanks,
Jack

In IB, for the top-level view, for the Simulated User Interface Elements, set the Top Bar to be one of the Navigation Bar options. Understand, you will!

hi jack you also do that change view size from interface builder like 320 &460

Related

nested NavigationController causing uiview resize

I have nested a navigation controller inside another and now its causing the uiview inside the nested navigationcontroller to resized weirdly.
Here are a few screen shots to show you whats going on.
This is with both navigation bars showing, as you can see the bottom extends further than the physical screen can allow.
this one only shows the sub navbar with the main nav bar hidden.. as you can see there is this weird space above the subbar that looks like the height of a status bar. i'm not sure what it is.
Lastly this shows only the mainnavbar being shown and the subbar being hidden..
the last view is what I would like to use, However.. if you look at the bottom of the view its only got a portion of the A's displaying.. however if you look to the view in InterfaceBuilder on the left you will see that interface there should be more letters there but strangely the view is not resizing to fit in the bound of the physical view...
I am wondering hopefully with the detail supplied if you can tell me how to get the view to resize correctly and fit everything in properly.. any help would be greatly appreciated.
I think you set the autoresizeMask property = UIViewAutoresizingFlexibleBottomMargin for these UILabel objects, you'll get the last UILabel aligned to the bottom of your UIView.

Why do my UIImageviews get resized/dimmed when using UINavigation/UITabbar controller

I have an app with a primary view that has a UITabBarController with 5 tabs. Each tab is a UINavigationController.
In interface builder, I'm customizing the background of each page by dragging a UIImageView and setting it fullscreen. The image I'm setting to the view is 640x960. I am setting it to be Aspect Fill.
However, what I've noticed is that it is not where I would expect it to be. When navigating between by tabs, the image seems to be shifted down from where it should be.
Also, when pushing a new view to the navigation controller, the background of this new view isn't offset in the same way as the tabbar one, and it is also slightly dimmed.
How can I set my UIImageViews on each page to be aspect correct and fill the screen 1:1? Also, how does one disable the dimming when pushing a view to the navigation controller?
Thanks for any tips, and apologies if this is covered in another thread, I couldn't find an answer searching the site.
Assuming that you are using the IB to setup your views, you should select navbar/tabbar options to reflect what will be on the actual page. That should place your image correctly. I would also recommend that you make both a low res and hi res version of your background images -- 320x480 and 640x960. Of course, your size may need to be adjusted (reduced) for the navbar and/or tabbar which will leave less than 960 px of vertical height -- probably more like 920px if you are in portrait mode. Then you add #2x to the base name of the hi res version, this would account for older iPhone screens.
Once you have the image placed correctly, resizing should be unnecessary. You can have the image automatically resize width and height using the little arrows on the layout page -- that's a bit hard to describe. It can also be done in code -- if you still need that I can provide a sample.
Maybe you need to set all AutoresizingMask in order to resize the UIImageView properly on each view. And to main aspect ratio u should use either AspectFill or AspectFit on the contentMode.

how to make a custom viewController with transparent black background?

I'm trying to make a viewController appears like the small one in the middle of the picture :
I tried with the UiAlertView, but it semms not offering this feature.
I found some apps adding buttons and labels, photo in similar viewControllers.
Any idea ?
It's not a view controller - it looks like a view that is added as a subview.
The middle View in the image is not a viewcontroller. It is just a custom UIView made up using images and buttons. You can set the transparency of a UIView using property alpha.
Example
yourview.alpha = 0.5;

Subview is showing the main view underneath

I've got this strange bug in my app. I'm making a subview and drawing it over the top of my main view. To get rid of it I'd just hide it. Here's the problem: There I can see part of the view underneath peeking through the bottom in a line that seems to be the same size as the status bar. I've put how I'm adding my subview below, along with a screenshot to illustrate my problem.
theLaunch = [[firstLaunch alloc] init];
[window addSubview:theLaunch.view]; // it goes on top
[window makeKeyAndVisible];
Here's the screenshot...the view underneath is grey.
It looks like you don't have subview properly 'anchored'. If in IB, then you could try attaching subview to bottom edge of containing view. Your 'main view' seems to be stretching to accommodate available space (which is changed by presence of status bar), while you 'sub view' appears to be positioned (0,0). Something like this might help:
Programmatically, you could use UIView's autoresizingMask. Something like:
theLaunch.view.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
How confident am I that this is the actual problem? Not as confident as I would like to be.
Where are you defining your user interface for firstLaunch? If it's in a nib file, you need to have theLaunch = [[firstLaunch alloc] initWithNibName:#"firstLaunch" bundle:nil];. If you are manually adding your interface elements; where are you doing that? If you're adding them manually in ViewDidLoad, I think you should be seeing it.
Your image probably has alpha transparency in the places where the image below shows through. If you don't want that effect, you should recreate the image without alphas (fully-opaque).
If you aren't able to recreate the image for some reason, you could try either setting the opaque property of the image view to YES (I'm not sure if that will work), or adding another view below your image view that is opaque and has a solid background color that isn't transparent.

UIBarButtonItem in middle of navbar?

I have created a flexible navigation bar in my app that will show custom buttons on the left, right, and in the middle. So far I have got working:
Right/Left/Middle - Custom Image and/or Text
Right/Left - Normal looking button with custom Image in it
Right/Left - Normal looking button with custom Text in it
By 'normal looking' I mean the default UIBarButtonItemStyle- just a nice shiny button.
My question is, how can I achieve the same look in the MIDDLE of the nav bar? I can do custom/text images by just creating a custom UIButton, and on the right / left I create a UIBarButtonItem from it, but in the middle I just add the UIButton view as a subview of the navbar.
I can't add a UIBarButtonItem to the navbar as a subview, and any UIButton I create doesn't look like a UIBarButtonItem.
The only workaround I can think of is to use a stretchable custom image that I steal from a screenshot. I'd rather avoid doing it this way. Am I missing something?
*********** UPDATE **************
The open source library Three20 will allow you to create UIButtons that look like UIBarButtonItems. Then you can add them to the bar view either by placing manually as a subview or by setting the title view.
I never understood why they didn't make UIBarButtonItems derive from UIViews (or even better, UIButtons) so they could be used elsewhere.
Sounds like you're on the right track, but need better artwork :-) You can get a large number of iPhone UI components in a Photoshop .PSD file from here. They have pre-rendered bar buttons which you can use as a base for a standard UIButton image. If you have Photoshop (or a decent drawing program) you can stretch the buttons from the middle to fit your size without getting the corners distorted. Just add the label and you should be good to go.
Put a flexible region on the left and right, they will offset each other causing anything between them to be centered