Subview is showing the main view underneath - iphone

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.

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.

UIView does not display subviews

We created a UIView in a ViewController as a grouping mechanism. Now it turns out for some reason that it does not work as the subviews within it are not drawn (and this is without setting any of the other settings hidden etc.).
I've looked through the documentation and stack but I can't find anything about it. Am I missing something basic in the draw cycle?
See the image below:
The stuff in blue does not display at all and is a subview of View. I moved the yellow out of its subview and normally within the ViewController and that does display now.

UIImage displaying incorrectly in a UIImageView

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

Strange black bars in UITableView

I'm really scratching my head over this one: When I make visible the Toolbar of the navcontroller in my view hierarchy, strange black bars appear at the top and bottom of the table view. http://grab.by/8pgz
The app is universal, and on the iPhone simulator (or device) this does not show up, although they use the same UITableViewController subclass.
I cannot even figure out what the extra bars are, which makes it even harder to come up with a solution.
They are, however, not navbar / toolbar. They are not section or table view header / footer. It does not merely seem to be a resizing of the table view either, since its background is not black.
The custom table view controller sits inside a UINavigationController, which in turn is inside a UISplitViewController. Pretty standard, as far as I understand.
Like said, they do not show up on the phone - nor do they appear in the popover in portrait orientation.
I'm really out of clues here. Any suggestions would be most welcome.
Cheers,
Gregor
Sweden
Update: Problem solved by moving the code for making toolbar visible to -(void)awakeFromNib method instead of -(void)viewDidLoad. Still don't know what went wrong, but now at least it works.
I believe there is a problem with the frame you're trying to use to initialize the tableView.
myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, height, width);
Try changing the height width variables in code, to reflect your height & width on the iPad.

iPhone UIScrollview: Button does not respond when located below 480 pixels on Scroll View's child UIView

I have built a view for an iPhone app in Interface Builder. It is a UIScrollview with a UIView and a UIButton on the UIView. The only code I have is setting the scroll view's contentSize to 320x550 in the viewDidLoad method of the xib's File Owner class. When the button is within the normal view area (320x480) the button responds as normal, but if is placed outside of those boundaries in Interface Builder the button will not respond when I scroll to it and click the button.
What am I missing? I figure it might be something I need to set on the UIView. But I am not sure what that is.
Your UIButton won't response even it's visible because it's not in the boundary of parent view. You can see object outside the boundary of its parent view because it's a default behavior of UIView to draw all subview (clipsToBounds = NO)
To see the truth, try this code.
UIView *yourUIView = ...
yourUIView.clipsToBounds = YES;
yourUIView.backgroundColor = [UIColor cyanColor];
You will no longer see your UIButton.
To fix this, enlarge your UIView.
I had the same problem as the person who posted the question. Thanks to the first answer, I had a hint as to what to do. I increased the height of the view by adjusting the frame. This, apparently must be done in code. Once this was done, however, the toolbar at the bottom was no longer visible. So before I adjust the height of the view, I grab the position of the tool bar. Then after adjusting the height of the view, I reset the position of the tool bar. Now all is good.