Problem autosizing second view - iphone

Once a view is called from appdelegate, it is properly loaded but not autosized correctly, on the bottom you see last lines from previous view! On xib file, view mode property is set to scale to fill but I tried others and still happening the same... Thanks for any idea to solve it!

Maybe check Interface Builder, is the view using any of the Simulated User Interface Elements? That isn't directly answering your question but it might be worth a look, e.g. the status bar is normally simulated by default.

The standart way to control autosizing is by
self.View.autoresizingMask = UIViewAutoresizingFlexibleHeight(or st. else)
self.View.autoresizesSubviews = YES;
You might also try to just set the size manually

Related

UIView code vs interface builder

I have defined a UIView in the header file named rectangle0
I got a question in regards to IB vs coding a view. Please see the following code example:
rectangle0.frame = CGRectMake(0.0, 70.0, 320.0, 190.0);
Now I can re-create the look of the view easy enough in IB except for the coordinates which are greyed out.
So by calling this code in an IBAction after designing the UIView in IB I can display in the app.
[self.view addSubview:rectangle0];
Now the last line of code will call this view to appear at the set coordinates if I code it - but if I build in interface builder I can make it look exactly the same, but it appears from Y coordinate 20 (just under the status bar) and I can't set the coordinate upon calling it - is there a way to do this??
The UIView is being build outside of the ViewController and then linked to it in the connections inspector.
cheers Jeff
I have added an image to show what screen I am using - as you can see the x and y coordinates are greyed out, it would be great if I can set those to something else.
A view inside the NIB is just an object like any other. It is made to be reusable and I believe that is the key point that resulted in the coordinates being greyed out.
Greying out the position makes the developer worry about where is the view going to be placed. I say that because the position is pretty dependent on the container that your view object is going to be added to.
Although it is just my personal opinion and I am looking forward to hearing if there is indeed a way to do that.
You (effectively) said the view is managed by a view controller. Before you can resize the view, you need to change the Size setting in the view controller's Simulated Metrics to "Freeform". (It is probably set to "None" by default.)

self.window addSubview not working properly

I am trying to call a new view to come on top of the current one. The code in the appDelegate.h is:
-(void)switchToTransferFundsView {
if(!objTransferFunds) {
objTransferFunds = [[TransferFunds alloc]initWithNibName:#"TransferFunds" bundle:nil];
[self.window addSubview:objTransferFunds.view];
}
}
The view does appear except it doesnt fully cover the view underneath it; theres a slight transformation. Can someone tell me why?
It seems to be an "autoResizingMask issue".
To be sure your frame won't change, set UIViewAutoresizingNone as value for your view property autoresizingMask.
One drawback, with this setting, is your view will not be adjusted automatically when rotation occurred for example.
For more information, see the documentation:
http://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW6
Have you set the frame properly in the xib editer?
In the attribute inspector set the x, y, width and height which you would like to set for your view. If this does not solve, give some more details of the issue.
As Krishna mentioned, you should check the frame settings in the inspector.
If that doesn't work, you might want to just use a work-around: account for the transformation. If your "transfer funds" view is shifted to the right from where you set it in the xib file, shift it to compensate.

Oritentation issue in landscape (iphone)

Good day!
I have a view which i forcefully landscape. but the problem which i am facing is that the navigation bar buttons are somewhere else but i have to click few steps (inches) back to let it act. e.g.
if button is at frame
0,0 then i have to click at 50,0 to go back. i am attaching screenshot, if some one could help me in this. Please help
Thanks & Regards
Without providing the code (or the entire project), it is unlikely for anyone to tell you exactly what is wrong.
...Unless this is just a frame/bounds issue. Make sure they are set to the proper values. The frame is the area where your view is displayed, and the bounds is the area where your view will accept interaction.
How did you force the screen in landscape? The usual way is something like the following (in any UIViewController subclass):
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
If you forced it any other way, that might be the cause of your issue.
This may cause due to no Auto resizing You will only have to do is goto Layout in Interface Builder then Live Auto resizing.
OR
By selecting all the components one by one hit cmd+3 Then there is a panel named autoresizing only select lines in inner square and deselect outer one if any
Only then your missing block will be shown and no button problem will be there
Cheers

UISegmentedControl not expanding size for navigation bar/very squished

Running through an iPhone SDK book and one of the examples has me creating a table and then later adding a UISegmentedControl to the table for sorting.
I dutifully did this in IB, and it looks great:
IB Screenshot http://img.skitch.com/20100529-83sefni21q4nj51rw1mghh2yj1.jpg
When I run it in the simulator or my phone, it's totally squished:
Squished http://img.skitch.com/20100529-x3pmr7gkb6xpm766bupi7quy55.jpg
The buttons work perfectly, it's just they are not sizing according to their content. Any ideas what's going wrong?
Here's the attributes I have set:
Attributes http://img.skitch.com/20100529-tp4d69bk8x98c6sjpmcne92etb.jpg
You could try explicitly setting the width of each of the segmented control's components. Click the Size tab at the top of the inspector and set the width for each component.
I experienced the same issue once. The problem was that the UINavigationController's view was not the top-level view in the hierarchy (it was not added to UIWindow directly), but it was added as a subview to another view controller's view instead. It's just a guess, maybe that's your problem, too (or that there are more than one visible view controllers).
OK, so in attempting to implement #Chris Gummer's answer, I seem to have learned more about how the Size->View Size property panel works. The default is:
Default Sizing http://img.skitch.com/20100529-gg9dwq5em3557yb1d6d721hpn4.jpg
and this is not a good default, it would seem. My book didn't mention needing to adjust this, so I didn't look at it. Setting the inner horizontal arrow of the box (which I guess means "fit width to available space") did the trick:
The Answer http://img.skitch.com/20100529-xt1bqghb4kbm2pbcqf1i1uygab.jpg

Broken cell with an odd strikethrough?

I'm having a weird issue with a particular UITableView in my iPhone devel experience here. If you look at the following screenshot:
alt text http://dl-client.getdropbox.com/u/57676/brokencell.png
you'll notice a strike through going through the middle of the 'Jane Aba' cell.
Any idea what might be causing this odd graphic display? It's true for both the simulator and for the actual device running 2.2 SDK.
As requested, here's my -tableView:cellForRowIndexPath: method:
* EDIT *
I've located the problem. I'm not entirely sure why this is the problem, but it is. In my RootViewController, I have the following line of code in my -initWithCoder: method:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
When I comment that out, the cell (which is not in the RootViewController, but a secondary controller) it's resolved. Any idea why this might be the case?
I've had a similar problem. For me, the single line was caused by a superfluous view that was created but never sized or placed correctly and so was 1 pixel high, floating over everything else. You can also cause this by confusing a UINavigationController about its set of subviews (by adding views directly to its layout container).
Look through your UI (xib files and programmatically created views) for a view that shouldn't be there or is otherwise not being used. It might be helpful to write some code to dump a UI Hierarchy, so you can see what views are where.
Are you doing anything special in your -tableView:heightForRowAtIndexPath: method?
It looks to me like the height of the row is being set incorrectly, so the contents of the cell are expanding outside of its bounds.
The problem disappears when you set the cell height for the table view to 1 pixel in IB. It seems that before you populate the table, an empty table is drawn with the outlines of the cell height set in IB.
Don't set the cell height to 0. IB doesn't like that. :-)