I'm building an app using the UIImagePickerController and a custom Overlay. With the iPhone 5 screen size adding 88 points but the camera view port staying roughly the same size I was wondering how people have tackled this issue?
I'm really against hardcoding values or making assumptions based on screen height, especially with Apple rumoured to be releasing another device with another set of screen dimensions next week.
Unfortunately with this being a private View Controller, you really can't safely probe into it to see what's really going on. What I've determined is that the toolbar has gone from about 54 pixels to about 92, but hard-coding such things is probably going to end up biting you someday.
I ended up rolling my own camera using AVFoundation .... this gave complete control over the scale and location of the preview view, and also any overlay you want to put on top of it.
You can download Apple Samples like SquareCam which will give you much of what you need, and abandon UIImagePickerController altogether.
Related
I maintain an OpenGL app that's been running on iOS since 2010. It uses the full screen and hides the status bar. It launches without any .nib file and creates an OpenGL view & controller that, in turn, displays all app content.
What changes do I need to make so the app will work on iPhone X using the new 'safe area' layout design? Presumably the only real change is just creating my "EAGL" surface/view with the same dimensions and location as the safe area instead of the entire screen?
How you respect the safe area in a "fullscreen" app (like most GL, Metal, etc games) is really two questions: one of design, and one of implementation. (But it's easier to tackle them in the reverse of that order, so here goes...)
Making fullscreen OpenGL views
If you have a fullscreen view (e.g. the window's root view controller) and you just set its layerClass to CAEAGLLayer (as is par for the course in most OpenGL ES work), you get a view that covers the entire 1125 x 2436 rectangle of the iPhone X screen. (Be sure to set the scale, too, so you actually get all those pixels... 375 x 812 # 1x scale probably looks hideous on that screen.)
That's probably the user experience you want for your app/game (and it's the one Apple encourages)... your 3D content extends all the way to the edges of the screen, around the curves at the bottom and the 🤘 at the top. That makes a much nicer UX than leaving black borders around all your content.
Designing fullscreen content for iPhone X
On the other hand, the existing design of how your OpenGL content appears may or may not fit well with the curiously shaped screen of iPhone X. If you have anything along the very top that the user is expected to see, it'll be obscured behind the camera/sensor/speaker cutout. Similarly, if you have anything important at the bottom, its edges will be cut off behind the curved corners.
In that case, you'll want to leave the unimportant parts of your fullscreen content (like a game's view of a 3D gameplay world) fullscreen, but inset any important content like UI overlays or interactive 3D elements. As for how you might do that, there's a couple of feasible approaches, with tradeoffs:
Hard-code the iPhone X obstruction dimensions, detect when you're running on iPhone X, and fix your layout accordingly. This is straightforward, but not robust. If Apple decides to change the way software UI elements around screen edges (like the swipe-to-home indicator) work, or makes iPhone XI (or X2? or XX?) next year with a slightly different shape, you'll need to update again to adapt.
Use the Safe Area guides even though you're not using UIKit or Auto Layout to draw/position onscreen content. Ask the view for its safeAreaLayoutGuide and convert that guide's bounds to whatever coordinate system you use for positioning the content you draw with OpenGL. This is a little more work, but it ensures that your app is ready for any curveballs Apple throws in the future.
One more thing...
It uses the full screen and hides the status bar.
When designing for iPhone X, it's worth rethinking whether a "fullscreen" app should hide the status bar. On other iOS devices, showing the status bar means taking away useful space from your app's content. But on iPhone X, most apps don't have anything useful they can do with those "devil horn" corners anyway — your user might appreciate still being able to see the clock, battery, etc.
I downloaded the latest iOS package from vidyo.io and have successfully built my application integrated with the Vidyo libraries and using the VidyoConnector API.
When my app first comes up, I was very happy to see that a preview video appears on the screen just where I’d expect it to be! However, when moving the view to a different location, the video did not render quite how I intended.
The video did move to the x/y position on screen that I’d hoped but the size did not adjust to my new view dimensions. Then I found the VidyoConnectorShowViewAt API call and that did indeed resize my view but the positioning of the video then was off.
Is this the correct call to make when moving and resizing a view? Does anybody have any ideas what I could be doing wrong? Any help would be appreciated.
Sounds like you are pretty close. If you are just moving your view to different coordinates without resizing, then no API call is necessary. But if also resizing, then indeed use VidyoConnectorShowViewAt. My hunch is that your coordinates that you are passing are off, as x and y should be relative to the view itself and not to the main view. So try passing 0 and 0 as x and y and see if that helps.
I'm taking a few first steps in Xamarin for iOS and having a very hard time figuring out how to create a view that is resolution independent.
I have a single textbox in the view, aligned so that its edges meet the edge of a iPhone 6S. When I change the View to a Iphone 4S the edges of the textbox are outside of the view.
I have tried to drag the constrains to the edges, pretty much clicked every button and tried to find some example of how to make it so the view resizes to fit the viewport but I cannot make it work. Ive also fiddled with the different modes of the View (Aspect Fit, Scale to Fill, etc) but that makes no difference.
I would love to se a simple example of how to create a resolution independent or multi-resolution form or view that is displayed similarily no matter the screen resolution on the iPhone.
Having gone through very much the same pain as you, my recommendation is two-fold:
Have a look at the Cirrious FluentLayouts package, which you can
get from NuGet.
A tremendous help in simplifying various issues with auto-layout, especially if you decide (like I did) to just give up on the GUI layout tools and go with a full programmatic approach.
It will allow constructs like:
this.AddConstraints
(
_navBar.AtTopOf(this, UIApplication.SharedApplication.StatusBarFrame.Height),
_navBar.AtLeftOf(this),
_navBar.WithSameWidth(this),
_navBar.Height().EqualTo(Hamburger.HamburgerHeight),
_scrollView.Below(_navBar),
_scrollView.AtLeftOf(this),
_scrollView.WithSameWidth(this),
_scrollView.Bottom().EqualTo().TopOf(_pageControl),
_pageControl.Above(_toolBar),
_pageControl.AtLeftOf(this),
_pageControl.WithSameWidth(this),
_pageControl.Height().EqualTo(pageControlHeight),
_toolBar.Above(_button),
_toolBar.AtLeftOf(this),
_toolBar.WithSameWidth(this),
_toolBar.Height().EqualTo(toolHeight),
_button.AtRightOf(this),
_button.AtBottomOf(this),
_button.Height().EqualTo(buttonHeight)
);
Be aware that since... iOS 8 I believe? ... you now need to use a
LaunchScreen.xib to have your app correctly pick up device
resolution which will then be used by auto-layout.
This was the one area I still needed to use the graphical layout tool for - just once, happy to say.
TL:DR
What technique does Apple use to make Photo.app so fast, even with large images?
Long Version
I watched Apple's WWDC 2010 video about scroll views to learn how to replicate Photo.app pagination behavior and low memory utilization (PhotoScroller Demo). It works well, but since images are loaded only when they are needed, when I try to paginate to another image, the app locks while the JPEG is being decompressed.
The same video shows a tiling technique to get better performance, but since I'm using photos taken from the camera and stored in the app, that doesn't seem feasible (having multiple copies of each photo, in different resolutions, would consume too much space - 4MB vs 27MB). Also, using iExplorer I noticed Photo.apps has only a copy of each photo (it doesn't even have a small thumbnail copy for the gallery).
What technique did Apple use to make Photos.app so fast? How can I get that same performance in my app?
I'm a bit confused if this should be here or on Programmers,
since there's no code in the question, but F.A.Q. says that algorithm
questions are part of Stackoverflow, and the tags here match it
better.
So if you just show one image fullscreen you can do this:
In the WWDC11 Session 104 - Advanced Scroll View Techniques they talk about infinite scrolling and how to do it. The basic idea is to scroll the view and after scrolling reposition the (UIImage)view inside the scroll view so it appears centered or whatever you layout constraints are.You could then load the new UIImage into the UIImageView. Since you only have one UIImageView it should be pretty low memory consuming. I am not sure about how the loading times of the images will behave though.
Maybe preload the next UIImage to the left and right to the current image and then load it into the UIImageView after reposition the scrollView can help here.
For anyone who is still looking for simply implementation of scroll view that hold lot's of images.
https://github.com/sumofighter666/ReusableScrollView
It is as simply as implementing UITableView
iOS 6 SDK. Xcode 4.5.
Using storyboard and arc. I am making an application that consists of a number of calculators that compute various formulas. On one scene, I'm using 8 UIButtons that have a PNG file as a background image, and they are labelled as different formula categories to allow the user to navigate to 8 different formulas which are contained in 8 different scenes.
I'm using modal segues and am utilizing the [self.presenting dismissViewController] method to dismiss each scene. That all works fine.
On one calculator in particular, I've set up the scene to resemble an actual calculator. I used a UIImageView with a UILabel on top of it to act like a display. Even without code attached to it, when running on my device, I notice that the transition gets hung up when segueing to that scene. I'm not sure why. Also, whenever I hit a button I get a receives memory warning in the console. I'm also showing a leak in instruments.
This app works perfectly in the simulator but not on the actual phone. I'm not sure what's wrong. Could it be my compiler settings? Or is it the fact that I'm not programmatically setting up the button images? Even when there is just a UIImage with a blue picture PNG and a label on top of it, no buttons or a viewcontroller for this view, it still gets hung up.
I'd appreciate any tips or tutorials or just plain tell me what I'm doing wrong lol.
Thanks.
I found out what was wrong. I was using a very high resolution image on each of those buttons. When I replaced it with a low resolution image the memory issue went away