iOS 10 disable autorotation - uiviewcontroller

iOS 10 with Autolayout and Size classes is giving nightmares for trivial issues that were easy before. I launch my app in Landscape mode and want to disable autorotation till everything is configured, after which I manually trigger autorotation through API
UIViewController.attemptRotationToDeviceOrientation()
But no matter what I do, the interface autorotates to portrait mode if device is held vertical. Here is what I have tried:
a. In Storyboard, I select landscape orientation in each of the traits(not sure if this really sets to landscape mode),
b. Set initial orientation in info.plist to landscape,
c. Return false in shouldAutorotate { },
d. Return only .landscapeLeft in supportedInterfaceOrientations
But even then the bounds of view come out to be (origin = (x = 0, y = 0), size = (width = 375, height = 667)). I want bounds to reflect width = 667 and height = 375. How do I do that?

Related

How can I make it so Edit2D lines do not resize when viewer is zoomed in and out?

Long story short: I want to set Edit2D polyline tool's line width to 6" based on calibration sizing and have it stay that size in the viewer no matter the camera zoom.
I'm using the edit2d library to allow drawing. I need to be able to set the line width for the polyline tool and have it stay at that width similar to how markups stay a set size when drawn. The default functionality of the edit2d polyline tool is for the line to be resized on camera changes and so it grows and shrinks depending on zoom.
I tried setting edit2DTools.polylineTool.style.isScreenSpace = false; which works, however, trying to set the specific size is difficult as it ends up being a decimal less then 1 and I can't find a correlation from the calibration, page size, etc. to allow me to dynamically set the size the same on different models.
I also found this in the Edit2D Snapper's code, but I can't figure out what's happening here to replicate it on the polyline tool. It seems to be doing what I want to do.
Any help or ideas at all would be greatly appreciated!
This code seems to be working for me:
async function setLineWidth(viewer) {
let mt = await viewer.loadExtension("Autodesk.Measure");
if (!mt.sharedMeasureConfig.calibrationFactor) {
console.log("Has not been calibrated yet");
return;
}
let edit2d = viewer.getExtension('Autodesk.Edit2D');
let pt1 = {x:0, y:0, z:0}, pt2 = {x:6, y:0, z:0};
viewer.model.pageToModel(pt1, pt2, 0 /*viewport id*/, true /*reverse*/);
let style = edit2d.defaultTools.polylineTool.style;
style.lineWidth = (pt2.x - pt1.x) / mt.calibration.scaleFactor;
}
Here is a video showing it in action: https://youtu.be/DIaKugvQdm4
As you can see first the lineWidth of the polylineTool is not what you want, but after setting what 6" should be in the drawing, I can set it to the same width and all is fine.
Here is a zip file with the html including the JavaScript code and the test PDFs I used: https://github.com/adamenagy/Container/blob/master/Edit2dTest.zip

How to Scale my Sprites up/down depends on screen resolution in cocos2dx?

I'm having problem working with multi screen solution. I've done the search around but still couldn't find the solution since those answer were oudated / using deprecated method or unclear to me. After 3 hours of searching and tried many different advices, I still couldn't get it done and I got confused so I have to create this topic. Your attention and help is very much appreciated.
My situation: I'm working with designResolutionSize = cocos2d::Size(1280, 720);. It works fine on my PC monitor (with screen solution 1600x900) but when I install my app on a set-top box and run it on a 30 inch or 40 inch TV. My sprites don't scale up to fit the TV screen, they looks too tiny.
My question How should I make my App scale up/down depends on the device resolution to fit the screen?
My AppDelegate.cpp:
static cocos2d::Size designResolutionSize = cocos2d::Size(1280, 720);
bool AppDelegate::applicationDidFinishLaunching(){
// Get the Director instance
auto mDirector = Director::getInstance();
// Get the GL View Container
auto mGLView = mDirector->getOpenGLView();
//Set up View Container if there's no available one
if (!mGLView)
{
mGLView = GLViewImpl::create("NGTV Launcher");
/*mGLView->setFrameSize(1280, 720);*/
mGLView->setFrameSize(1600, 900);
/*mGLView->setFrameSize(1920, 1080);*/
mDirector->setOpenGLView(mGLView);
}
mGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::EXACT_FIT);
// Innitialize a Scene with createScene()
auto mScene = HelloWorld::createScene();
// Run the scenee
mDirector->runWithScene(mScene);
return true;
}
I guess what you need is GLView::setDesignResolutionSize() and Director::setContentScaleFactor().
http://www.cocos2d-x.org/wiki/Multi_resolution_support

Preffered viewPort to dealing with textButton libgdx

i work with a new game , i have create 2 camera one camera for real world and another (GUI) camera for a static resolution (800 x 480)
private void init () {
camera = new OrthographicCamera(16,9);
camera.position.set(0, 0, 0);
camera.update();
cameraGUI = new OrthographicCamera(800,480);
cameraGUI.position.set(0, 0, 0);
cameraGUI.update();
And i want to use a textButton in my game , so i've create a new stage using a new fitViewPort
fitViewPort=new FitViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
gameController.stage=new Stage(fitViewPort);
then i create my textButtons using my bitmap font and i try it on the Desktop , and it's great
desktop
but when i try another device , the position is not the same
Tablet
then i think for using the cameraGui Width and height for my view port , the font is very bad stretched
any help please :(
Don't create a special camera for GUI, because viewport already has a camera.
Make your viewport width and height fixed, in your case:
fitViewPort = new FitViewport(800, 480);
gameController.stage = new Stage(fitViewPort);
And then just add actors to stage and draw it just by calling method
gameController.stage.draw();
Note: Remember to add gameController.stage.getViewport().update(width, height); in your resize method.
Edit: Using small fixed viewport (800x480 is small) will cause scaling, that is why the font is stretched. For example if you run a 800x480 layout on 1920x1080 display it will be scaled by 225%.
What you can do is generate a font with big size and the set scale to its data fe. bitmapFont20.getData().setScale(0.5F); (in this case font is generated by FreeTypeFontGenerator with size 40). Using this trick you will be able to get a great results. The proof is below. It is viewport of 640x360F * (float) Gdx.graphics.getHeight() / (float) Gdx.graphics.getWidth() scaled to 1920x1080. Font is generated with size 72 and then data scale is set to 0.5F
Here is the same text, but without modified data scale.

Chrome Developer Tools - Browser Size?

I'm using Chrome Developer Tools and trying to get the browser width in px
Google recently rolled out updates for their Developer Tools, before these updates the screen height & width used to appear in the top right of the website preview when scaling the developer tools, but now there's no way to find out the screen size (example below)?
How can I find out the browser size via Chrome dev tools now?
I came across this trying to figure this out and couldn't find device mode as per Danamorah's answer. So I thought I would help save some time for a newbie and screen shot the icon to click so you can get measurements.
First, open dev tools, and then the top left corner you should see an icon shaped as a small tablet and phone. Click that and you can adjust measurements with the pixel count:
They change the way to show this tool, you can find it pressing in device mode
It's a bug: https://bugs.chromium.org/p/chromium/issues/detail?id=582421
Google Chrome beta branch has this bug fixed already and the fix is expected to be added to the next stable release (version 50).
As a temporary workaround, you can use this bookmarklet:
javascript: (function() {
var v = window,
d = document;
v.onresize = function() {
var w = v.innerWidth ? v.innerWidth : d.documentElement.clientWidth,
h = v.innerHeight ? v.innerHeight : d.documentElement.clientHeight,
s = d.getElementById('WSzPlgIn'),
ss;
if (!s) {
s = d.createElement('div');
s.id = 'WSzPlgIn';
d.body.appendChild(s);
s.onclick = function() {
s.parentNode.removeChild(s)
};
ss = s.style;
ss.position = 'fixed';
ss.top = 0;
ss.right = 0;
ss.backgroundColor = 'black';
ss.opacity = '1';
ss.color = 'white';
ss.fontFamily = 'monospace';
ss.fontSize = '10pt';
ss.padding = '5px';
ss.textAlign = 'right';
ss.zIndex = '999999';
}
s.innerHTML = 'w ' + w + '<br />h ' + h;
};
})();
It's not the same, and not as convenient as it used to be. But you can turn on a ruler under developer tools settings (General tab, Elements section, check "show rulers").
Then when you select an element (body or html) you can get the size of the element with a ruler on the x and y of the browser. This will not be the same as your browser window though if your content is wider than the browser.
It's inconvenient because it doesn't show you the size of the browser as you are resizing like it used to. Hopefully the original feature comes back.
*Also found that if you Toggle Device Mode on, and select Responsive in the drop down, you can resize the browser area and see real-time screen sizes.

scaling object to match field of view

I am overlaying some clickable hotspots on top of a proprietary panorama viewer application in flash (as3), and I need to make sure that the hotspots scale according to the changing field of view as the user zooms in / zooms out, but I'm not sure what formula to use.
I set a maximum and minimum field of view of 90 and 25, respectively. I've been given some suggestions of how to calculate the scale of the icons:
from the maker of the panorama software:
Scale => 1/tan(FoV)
This doesn't seem to work for me. And:
scalar += (ZOOM_SCALE_UPPER - ZOOM_SCALE_LOWER) * ( ZOOM_LIMIT_OUT - tempFOV )/( ZOOM_LIMIT_OUT-ZOOM_LIMIT_IN) ;
hotspot.scaleX = hotspot.scaleY = scalar;
Gets me close, but at some point the hotspot stops scaling even though the panorama continues to scale. I thought I could just do something like:
diffFOV = previousFOV - currentFOV.
hotspot.scale = currentScale*(1-diffFov)
But that's not quite right either. Everything gets way too big or too small.
Any ideas?
You may be over thinking it.
//assume we change the scale
var NEW_SCALE:Number = currentScale*(1-(previousFOV-currentFOV));
//1. change the scale of the parent containing both the view and the hotspots
viewSprite.scale = NEW_SCALE;
//this way the hotspot and the panorama will scale together
//2. if they are not in the same parent... then set them both to the same view
hotspot.scale = panorama.scale;
Only thing you may have to do after is reposition if they are not registered on their center point.