self.window addSubview not working properly - iphone

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.

Related

I want to load second view with given frame size

I try to load Second view in MainView with define frame size but don't need to see component of second view. I set size till it weel be appear.
-(IBAction)displayNewView:(id)sender {
[mrView setFrame:CGRectMake(0,150,320,50)];
[self.view addSubview:mrView];
}
i dont want to see second button.
Hey, I solved this issue by checking "Clip Subviews".
It will crop rest of the part of view which will not display.
Nice Question with basic issue.
Thanks.
If you have Button on Second View. Then It'll display on View when you are loading second view on Main View. Because it's part of Second View.

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.)

Make subview rotate too when device is rotated iPhone/iPad

Let me explain what I mean when I say that I want to rotate my subview too. I placed a lot of images to make my self clear. This may look like to much but it is not. Just wanted to be clear.
In the nib file that I am currently working on, I have a UIView and button.
The UIView that I created in interface builder is connected with the IBOutlet named ViewMain:
and the button executes the following method:
and what that method does is that it places the view from another nib file in the UIView controller that I created in interface builder. The nib file that I am actually placing is:
I just placed random controls to illustrate better my point.
so everything so far is great (the view from anotherViewController shows up on ViewMain when the user presses the button)
EVERYTHING LOOKS GREAT BUT NOTE WHAT HAPPENS WHEN I ROTATE MY DEVICE:
I would like my subview (anotherViewController.view) to ratate as well. I don't mind if it is bigger than ViewMain because I can have a transparent background. I just need to rotate it as well. How can I do that?
Define shouldAutorotateToInterfaceOrientation: in you UIViewController so that it always returns YES:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
Look here for more details.
You should also take care to correctly define the autoresizing behavior of your view and subviews, so that everything is fine when autorotating.
EDIT:
to set the autoresize property for a view in Interface Builder, select the view then go to the "View Size" pane in the Info window and set "Autosizing" as in the image below.

Problem autosizing second view

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

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. :-)