[selectorView setFrame:CGRectOffset([selectorView frame], 0, -selectorView.frame.size.height)]
In the above code I want to change the value of Y-axis for my subview, as it gets visible from the top of screen and hides my header and search bar. I want to set it just beneath to search bar.
How can I do that ?
Before visibility
After when subview gets visible
Try this:
[selectorView setFrame:CGRectMake(<CGFloat x> , <CGFloat y>, <CGFloat width>, <CGFloat height>)];
Hope it works for You
Related
I create a button using a storyboard, which is assigned the cornerRadius, borderWidth, textAlignment, and clipsToBounds properties. And by code I assigned the following text to fit the width of the button. But when executing it isn't vertical center and also it is visualized cut.
añadirOtrosCursos.titleLabel?.minimumScaleFactor = 0.5
añadirOtrosCursos.titleLabel?.numberOfLines = 1
añadirOtrosCursos.titleLabel?.adjustsFontSizeToFitWidth = true
añadirOtrosCursos.contentVerticalAlignment = .center
Try clicking on the UIButton in Main.storyboard, going to the attributes inspector, scrolling down to the "control" category, and making sure that the vertical alignment is set to center. This is what you should see.
It is very simple thing just open your storyboard, select your button and change the button property as below screenshot.
I have a UIView with a UINavigation controller and several other Imageviews and a text filed inside it. On the Nagivation bar there is a UIBarbutton item which pushes another ViewController.
When the text field in the Navigation Viewcontroller is tapped it brings up the keyboard causing the Navigation bar with UIBarbutton item to slide out of the screen and thus making the UIBarbutton item unaccessible until the done button is pressed on the keyboard.
A notification is sent to this method whenever the keyboard is invoked.
- (void)displayKeyboard {
self.view.transform = CGAffineTransformTranslate(self.view.transform, 0.0, -100.0);
}
I tried using the IB to add a scrollview onto the view but this causes the entire view to be blocked.
Is there any other way i can enable the scroll view whenever the keyboard appears so i can scoll the entire screen ?
maybe you could try setting the frame of the current view.. for example:
CGRect r = self.view.frame;
self.view.frame = CGRectMake(r.origin.x, r.origin.y, r.size.width, r.size.height-100);
and when the user done with the keyboard, add 100 to bring it back.... (instead of 100, you should get the value from the notification object that contains the height, position of the keyboard)...
my app uses a tab bar with 2 navigation based views in which I am adding a custom view (a title bar) between the nav bar and the table view .
- (void)viewDidLoad {
[super viewDidLoad];
// load title bar controller
TitleBarViewController *tbar = [[TitleBarViewController alloc] init];
[tbar setTitleImage:[UIImage imageNamed:#"v2-une.png"]];
[self setTitleBar:tbar];
[tbar release];
// show title bar
[self.navigationController.view addSubview:self.titleBar.view];
....
When the application is launched with a default selected nav view, I use (void)viewDidAppearBOOL)animated to set the table view to a lower Y value so that the title bar is visible.
Where Y = 20 : 20 is the height of my title bar.
self.tableView.frame = CGRectMake(0, 20, 320, 347);
The problem is that when I select a row and push a detail view and hide the bottom bar to display a toolbar, things are messed up.
my title bar's height increases and becomes > 20 which I can't explain why.
Now when I go back to the main table view, its Y is decreased by 20 and sticked to the nav bar. My title ben then appears above the first cell of the table view.
If hit the 2 tab and then go back to the 1st tab, everything is re arranged like expected.
here are some pics to illustrate all that :
link text
can anyone help me figure out why is this happening please ?
may be I am putting my positioning code in the wrong event ?
Is is possible that the background to everything is black and the tableview is moving down exposing the background, as opposed to the black titleBar actually increasing in size? This makes some sense given that the problem goes away when the tableView moves back up.
I have a scrollview that I had to the view of the view controller pushed to a UINavigationController.
My navigation bar is opaque.
However, the scrollview seems to keep size of the whole parent view. I would like the scrollview to have the size of the space between the toolbar and the navigationbar.
Is this possible or do I have to hardcode some size values?
Thanks in advance
When you initialize your scrollView you can set its contentSize parameter:
[scrollView setContentSize:CGSizeMake(320,392)];
The height of the screen (480) minus the toolbar (44) and navigation bar (44) = 392. Drop that to 372 if you're also displaying the carrier status bar.
or, use the frame geometry properties:
[scrollView setContentSize:CGSizeMake((scrollView.superview.frame.size.width),
(scrollView.superview.frame.size.height -
toolbar.frame.size.height -
navigationController.navigationBar.frame.height))];
When you use autosize, the correct frame size is not known on viewDidLoad.
You should pack this inside viewWillAppear and then everything works fine
scrollView.contentSize = CGSizeMake(scrollView.superview.frame.size.width, scrollView.superview.frame.size.height);
Here is an interesting problem. On the iPhone, I have a view set up that has a toolbar on the bottom of the screen. I am currently trying to make this a universal app so that it runs on iPad as well. I would like the toolbar to be at the top of the iPad screen, so in the viewDidLoad method of the specific viewController I have the following code.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//move the toolbar to the top of the page and move the webview down by the height of the toolbar
CGRect toolBarFrame = self.aToolBar.frame;
CGRect webFrame = self.aWebView.frame;
webFrame.origin.y = toolBarFrame.size.height;
[self.aWebView setFrame:webFrame];
toolBarFrame.origin.y = 0;
[self.aToolBar setFrame:toolBarFrame];
[Utils errorString:[NSString stringWithFormat:#"origen: x=%f y=%f", self.aToolBar.frame.origin.x, self.aToolBar.frame.origin.y]];
[Utils errorString:[NSString stringWithFormat:#"origen: x=%f y=%f", self.aWebView.frame.origin.x, self.aWebView.frame.origin.y]];
}
The problem I am having is that the webView moves down fine, but the toolbar only moves up to about what seems to be the height of a iPhone screen. The call to errorString tells me that the webView's origin is at 0,44 (where it should be) and that the toolbar's origin is at 0,0, but it is actually somewhere in the middle of the screen!
Anybody have a clue what is going on here?
I'd say this is because the frame is being set to the top of an iPhone frame (so 320px from the bottom), and then afterwards the view is being resized to fit the iPad screen. However UIToolbar by default is set to stick to the bottom of the window (fixed bottom margin, and flexible top margin) so it's staying 320px from the bottom.
To fix this try:
[self.aToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin];
before setting the toolbar's frame (if it doesn't work before setting the frame, try putting it after)