How do I insert a photo - either landscape or portrait - into a view.

I've been struggling with what must be a simple issue for days, and are now extremely frustrated. I'd like to integrate a photo into a view with other UI elements and have the other elements adapt around the photo's intrinsic shape - landscape, portrait, square or whatever the original dimensions are. While this is my specific problem of the hour, I'd like to ask a broader question about how to solve these problems from the available documentation.


I'm fairly new to developing in Swift - I've been trying to learn it for about 18 months now, mostly through tutorials. It's not my first language. 've done the Stanford CS193p course online, and have Ray Wenderlich's books and tutorials behind me. As I try to do my own thing for the first time, I keep hitting things I want to do, but that weren't covered exactly the same way in any of the examples - which is to be expected. Other people rave about the documentation from Apple, but I'm finding it inaccessible in three main ways. Firstly, I don't know where to start! From my perspective, I have a requirement; while the documentation's perspective is 'I have a method', which meets the requirement. This makes it really hard to search or browse because while I know my requirement, I've no idea what methods or class of methods to look in. Secondly, it feels like there is a massive gap between learning and doing, or between examples and creating. The methods in the Apple documentation very rarely contain example code to understand exactly how they are implemented, or worse, contain Obj-c code, which I can understand a bit - just enough to get it wrong and add to the confusion. Finally, there is so much information out there, on Stack Exchange, for example, that it becomes overwhelming sometimes. Instead of solving issues, it sometimes adds to the confusion.


My question is basically, can you show me how to solve this problem by teaching me how to use the Apple documentation.

Have a look at one of these documents, depending on which platform you're trying to use:


Start Developing Mac Apps Today

https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/chapters/01_Introduction.html


Start Developing iOS Apps Today

https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/index.html#//apple_ref/doc/uid/TP40011343


If you know most of this already, just let me know and I'll steer you toward documentation more specific to your problem.

When you are looking at the developer library (this link, then click "View now" under the appropriate heading), on the left side you can limit the search results to just "Getting Started" or "Guides" by clicking the appropriate link under "Resource Type". Or just leave all the results showing, and look for "Getting Started" or "Guides" in the "Resource Type" column. For example, if you go to the iOS 9 (prerelease) documents and type "layout" in the search box at the top of the Documents list (not in the upper right corner of the web page), part of the way down the list of results will be "Auto Layout Guide" with a "Resource Type" of "Guides".


In terms of Apple Documentation, if I'm trying to find out how to do or use some feature I haven't used in my app before, I tend to look at a Guide first (if there is one), then look for a related WWDC video and/or sample code. Then, if I still haven't found exactly what I want, I'll start looking through the appropriate Class Reference to see if there is something available that wasn't metioned in the guide / video / sample code. However, often I will also do searches of the Apple Developer forums, Stack Overflow site, etc. at any point in that progression of looking at the Apple docs, which may help me skip directly to a specific method or property reference.

Thanks Bob133, I've been through these documents thoroughly, but still find them very helpful. I'm going to try the guywithmazda's approach, but if you've anything to add, please let me know.

Thanks guywithmazda! It seems I had it backwards, I was trying to work directly with the class references because I didn't understand the significance of nor how to search the developer library. What you write seems obvious - I have looked at guides and videos before without a specific purpose - but I never understood where to go after getting started. I'm very keen to try this approach, and will write another reply after using this process - or simply tick correct answer!

>The methods in the Apple documentation very rarely contain example code


Some devs look at the docs as something they're not - they approach them as **tutorials**, when in fact they are **reference** material.


Remember - you have the docs, guides and sample apps.


Study sample code for implementation examples of iOS features. Each sample code project is a build-able and executable source example of how to accomplish a task for a specific technology. They show the correct sequence of calls and parameter data types to provide a generalized method for API use that developers can modify for their specific needs. Sample code is typically intended to show programming techniques and illustrate use of technology rather than suggest user interface designs (that's what the iOS HIG is for). Scan the readme with each sample and don't forget to check the comments in each file.


If there are samples you would like to see to illustrate particular technologies or techniques that are not covered by existing samples, feel free to file a bug report...link is below right, every page here.


If you want an understanding of how everything fits together, as noted, you should read one of the associated Guides.


As for Swift, it is still early, so don't let an evolving landscape trip you up. You'll need to be eyes-open and able to discern on your own, at least for the next year or so, I think.

How do I insert a photo - either landscape or portrait - into a view.
 
 
Q