Printer options only offer portrait, no option to switch - cocoa

I'm using [[NSPrintOperation printOperationWithView:drawingView] runOperation]; and I get this view:
There is no option to choose between Landscape or Portrait
I found that I can have [[NSPrintOperation printOperationWithView:drawingView printInfo:info] runOperation];
and set info.orientation = NSPaperOrientationLandscape . In that case I would get the preview in landscape but the user does not have the option.
How can I offer the option? (note: I don't see it under 'show Details' either)

Portrait and landscape buttons are in the page layout panel (Page Setup… in the File menu). See NSPageLayout and -[NSApplication runPageLayout:]. It is possible to add the portrait and landscape buttons to the print panel:
NSPrintPanel *printPanel = printOperation.printPanel;
printPanel.options |= NSPrintPanelShowsOrientation;
and/or
printPanel.options |= NSPrintPanelShowsPageSetupAccessory;

Related

Changing the background color of the unified NSToolbar (in Yosemite)

I want to have a unified toolbar and therefore I found this post:
How can I create Yosemite-style unified toolbar in Interface Builder?
self.window.titleVisibility = NSWindowTitleVisibility.Hidden
works perfect.
But is there a way to change the background color for the toolbar? I tried with self.window.appearance = NSAppearance(named: NSAppearanceNameVibrantDark), but this only brings a complete black toolbar (that's too dark). I want to have a custom color.
This one works:
https://stackoverflow.com/a/28692893/2062613
Set the window to textured in IB (I don't see a possibility to do it at runtime)
Use this code:
self.window.titleVisibility = NSWindowTitleVisibility.Hidden
self.window.backgroundColor = NSColor.whiteColor()
UPDATE:
To prevent, that the toolbar becomes transparent in Yosemite (if you have a scrollview below the Toolbar), use this code:
self.window.appearance = NSAppearance(named: NSAppearanceNameAqua)
I have used this solution to customize the title bar. However, since 10.15.4 and apparently on Big Sur, the toolbar is broken. If you have a toolbar with the window, the toolbar will placed on the top edge of the window, as if there is no title bar.

XCode Interface Builder Background color

I'm a newby in XCode/iOS development, and I want to change bakckground color of my label (XCode 5.0):
Opened my storyboard
Chose my label on the left side
Opened attributes inspector on the right side
But this tab has got settings of font, alignment, but no background color options! There is "View" section at the bottom, but it is empty. Please, tell me where can I find settings of background color? Thanks
At the top select the attributes inspector. Under the section "View" there should be a spot that says "Background". click that and choose your colour.
(refer to image for help)
Select the Label click on "Attribute Inspector" and scroll down you will see background option under View Section.
Select label before you go to Attribute Inspector
mylabel.backgroundColor = [UIColor redColor] ; is the code to change the background color. You get the color name before "Color" from the names of colors in the Apple color palette.

UIScrollView not displaying

I have a very simple application.
There is a toolbar on the top, and the bottom.
The bottom toolbar needs to be in a UIScrollView because it's buttons goes off the screen.
But when I test my application on a iPhone 4G, the scrollbar, and it's content, doesn't display.
When I test it on a iPod 5G, everything is where it should be.
I'm not using any coding currently, this is all being done in the storyboard.
Since there is a difference in the screen size of iPhone4G and iPod 5 the UI will resize resulting in the shrinking of all added subviews.
There are two solutions to fix your problem.
1) Add both toolbars. Select the toolbar at the bottom of the screen and in the Editor menu
Editor > Embed In > Scroll View
This will make sure that the UI works out of the box.
2) This is the second way (I am guessing you've created your UI this way)
-> Drag a scroll view
-> Add Tool bar as its sub view.
-> Now we need to set the springs (In our case autolayout attributes.)
The image below will help you understand better
The first constraint "Height Equals" can be added as follows
Editor > Pin > Height
Now Select and edit the leading space to: attribute
and in the drop down menu select "Less than or Equal"
This is similar to setting "UIViewAutoresizingFlexibleTopMargin" as the auto resizing mask.

Scrolling is disabled/limited when keyboard is popped up in Windows Phone 7.5

Based on the link scrollviewer to scroll to textbox position
I tried to resolve scrolling issue when keyboard is launched but there is a problem in landscape mode.
Problem in using (App.Current as App).RootFrame.RenderTransform = new CompositeTransform(); in landscape mode.
Above solution helped me to generate a behaviour similar to New Appointment page as in the default calendar app for windows phone 7.5.
But this (App.Current as App).RootFrame.RenderTransform = new CompositeTransform();does not work for landscape orientation of a page.
It works as expected in potrait mode, but on changing orientation(turning device), page does not automatically convert for landscape view, instead the page appears similar to portrait view with its width and height changed.
Initially i had placed this in App class (App.Current as App).RootFrame.RenderTransform = new CompositeTransform();
it is Working fine in portrait mode. But in landscape mode, it did not work as expected. So i reverted to original value for (App.Current as App).RootFrame.RenderTransform which i had stored in a static variable in App class, before assigning the composite transform in orientation changed method. This made page to alter correctly for landscape mode.
Now placed(App.Current as App).RootFrame.RenderTransform = new CompositeTransform(); in textbox focus method, on click of the textbox, landscape page turns portrait automatically with its width and height changed and doesn't even look similar to the correct portrait view. I don't know what exactly is happening. Any help could be appreciated.
Any idea to fix this issue, Awaiting your valuable response.
In landscape mode, based on Landscape Left or Landscape Right, use the following code
if(orientation == PageOrientation.LandscapeLeft)
(App.Current as App).RootFrame.RenderTransform = new CompositeTransform() { Rotation = 90, TranslateX = 480 };
else
(App.Current as App).RootFrame.RenderTransform = new CompositeTransform() { Rotation = -90, TranslateY = 800 };
This will alter your page correctly for Landscape mode also. This will prevent page header from disappearing on launch of keyboard. Scrolling to specific textboxes inside scrollviewer needs to be handeled by ScrollToVerticaloffset() in the GotFocus() events of specific textboxes.

Autoresize the root view when device is rotated

I am developing PDF reader. I am facing problem while rotating the simulator. What I am doing is, when view is loaded by the ViewController(i.e. in the loadView), I am creating the UIScrollView which contains UIImageView and UIView of the same size(i.e. size of the PDF page). It is working perfectly in the portrait mode. But when I rotate the simulator in the landscape mode, the view is not autoresized according to device. I have tried
self.view.autoresizesSubviews = YES;
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
in the viewDidLoad() of the ViewController
But it's not working. I am confused how the above two properties work. I guess these properties will autoresize the UIScrollView to the size of root view in which I am loading UIScrollView. But what should be done to autoresize the main view in which UIScrollView is loaded??
I've experienced the same problem when trying to utilise the auto resizing methods. So, I hope this will help. (P.S. I'm assuming you're creating the UI programmatically and not via IB)
So have you tried this?
Inside your viewcontroller add the following:
// Set the View Controller to fit the whole screen.
-(BOOL)wantsFullScreenLayout{
return YES;
}
Inside the loadView method amend your scrollView to:
// set the initial size of your scrollView object.
[scrollView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
// Set the auto resizing attributes.
[scrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
In addition to this you might need to set the autoresizingmask margins for either the UIView or UIImageView depending on the type of layout you require when the device is rotated.
This is late reply... It may help if you didn't Fix it yet.
When you create any app in portraid mode and if you want it to rotate (resize) to landscape mode, you should do it in User Interface Builder or .xib (or in Storyboard iPad or iPhone)file.
So to check or to check rotate in the Simulator:
Go to "USER INTERFACE BUILDER", or ".XIB" (or "Storyboard iPad or iPhone") file.
Then select "UIImageView" and go to "SHOW THE ATTRIBUES INSPECTOR".
In the fourth tab (Attributes Inspector) set the mode to “Aspect Fit”, and in the third tab (Size Inspector) and in the fifth tab (Size Inspector) set the autosizing attributes to the following:
Set the arrows to all directions. Sorry can't load image.
Do the same for "UIView" (3).
Before you move on, you can double check that you’ve gotten all of the autosizing attributes right by selecting the Detail View Controller, and changing the orientation from Portrait to Landscape: Sorry can't load image for now...
You can Check or Change to "Landscape or Portrait" on the top right side "Simulated Metrics" select under "Size" the "Orientation".
If something isn’t right, don't worry: Just change it back to Portrait and double check the settings.

Resources