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.
Related
This is my first post on here and I'm very new to iPhone developing, so please bear with me.
I have an app which has a few view controllers and each view controller has a few nib files that it controls and some of the nibs have more than one view. There is a toolbar throughout the app, controlled by the root view controller.
After lot's of searching, I have got rotation working on every screen, except one. I haven't got them to load in the correct orientation, but I guess that's a different question.
In my nibs that have more than one view, I can select the autosizing options only on the original main view. On the views that I have added, which I load using insertSubview, I can select the fixed margin options, but not the width and height resizing options. I am using Xcode 4.
My 1st Question, is why I am unable to select the resizing options on the additional views?
Sorry, I had to delete the images I put in here, showing what I mean, to be able to post.
Anyway, that is not my main problem, I just want to know, out of curiosity, why I can't select the resize options. I have found a way around it in the code. In the function where I load the subview, I add [viewName setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
E.g to load the view that I have named shiftStart, I use:
- (IBAction)loadShiftStart:(id)sender {
[self clearView];
[self.view insertSubview:shiftStart atIndex:0];
[shiftStart setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
}
Now here is my problem. I have a nib file that has 3 views, view which is the main view that loads first, rotaStart, which loads as a subview when a button on the first view is pressed and shiftStart, which loads as a subview when a button on the first view is pressed. rotaStart and shiftStart are almost identical, with a title, a text block, a Yes button and a No button. The only difference is the text in the box, and which view is loaded if you click on the Yes or No buttons.
I have all the same resize and margin options selected, in Xcode, for the title, text block and buttons and as far as I can tell, the code that loads them is identical (see code below), but shiftStart rotates correctly and rotaStart does not.
- (IBAction)loadRotaStart:(id)sender {
[self clearView];
[self.view insertSubview:rotaStart atIndex:0];
[rotaStart setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
}
- (IBAction)loadShiftStart:(id)sender {
[self clearView];
[self.view insertSubview:shiftStart atIndex:0];
[shiftStart setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
}
Can anyone tell me why rotaStart is not rotating, when the phone is changed to landscape please?
Sorry this explanation has got a bit long winded. I'm not sure how else to explain it.
Thanks
For anyone else looking at this, with a similar problem, #longball solved it for me. Somehow I had managed to add a second view over the top of the base view, complete with Labels & Buttons. Deleting the extra view fixed the problem.
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.
Ok, let's say we have an UIView (let's call it mainView) with the size of 480*320 (landscape), and I want to create 2 other views, one to display the first half of the mainView and the second will display the second half of the mainView and both of them will be 240*320, how can I do this?
It all depends on what is in the view at the first place.
If you have dynamic content like changing pictures you can just create two images from that with no problem but if you have UIButtons and other subviews then it's a lot of trouble. For instance what to do if a button or any other object lies in the middle of the main view. If you know your object will be position in either of two half's of the main view then you would go about splitting like this. Check all the subviews of the main view, depending on their position assign them to your new left or right view. The tricky part will be with the right view b/c you will have to adjust the x coordinate.
use the code and split it and replace the name by using the field name which present in the IB
..use picker view method
This is probably simple but I do not seem to get it to work. I have a view and inside it I have a scroll view and inside it I have a view with some labels and a button. the height of the text inside the labels changes according to some condition so I need to scroll down to see it. But whenever I try to scroll down it bounce back up without giving me a chance to view the rest of the view.
Basically, I want when I scroll down, the view to remain down as it normally should. Besides I do not see the scroll bar at all when I'm scrolling.
I know I probably do not understand how scroll views work, so I'd appreciate any help to explain to me the behavior of scroll views.
P.S. I built my whole view in a nib file and this specific setup That I mentioned at the beginning is based on a suggestion from one question I read here.
Thanks, Mohsen
you need to set content size of your scroll view
[scrollView setContentSize:CGSizeMake(360,1000)];
you can make the content size dynamic as per your calculation.
hi i am a new iphone programmer
i am creating a imagedisplay type application where i have to display images on a view and by presssing a next button a new image should appear on same view (i am using database)...
therefore i need to reload my current view again and again...each time when i click that button....
i tried some suggesion which are given on this website but not satisfied because many of them are based on timer...
please help.....
May be I have missed something in your question. But why you need to reload the entire view? You are using an UIImageView to display your image, right? And you are not showing any kind of scroll, but only a next button, right? Then why don't you just set the image property of UIImageView when the button is tapped.
// in button handler
myImageView.image = [UIImage imageNamed:#"new_image.png"];
Perhaps you could use a paged UIScrollView with three uIImageViews and always have the previous, current and next image loaded. This way when the user hits next, it scrolls animated to the next image. When page 3 is loaded, it programmatically sets the second image view as the desired next image, sets the image you came from on the first image view, and sets the scroll view non-animated to page two and loads the next image in the third image view.
Sounds complicated but basically you are giving the appearance of an infinite scroller but only pulling one image at a time except for initial load of three.
You could try looking at the "PageControl" Example Project in the XCode Documentation. It should give you a good starting point.