resizableSnapshotViewFromRect does not resize views within the hierarchy? - ios

I am making an application that displays a bunch of items in a scrollview with different sections having their own items. One feature is to expand each item so it will appear fullscreen, for this effect I use resizableSnapshotViewFromRect to create a snapshot of the view in it's fullscreen dimensions and then scale it down inside the scrollview.
The problem is that for the first displayed section, these views do not get a snapshot of their fullscreen dimensions but rather their downscaled dimensions. For the other sections that do not have their views in the hierarchy the snapshots look fine once you change section so you can view them. I had initially solved this by making a snapshot and then adding the views to the hierarchy in a dispatch_async call, which postponed the view being added after the snapshot finished.
Now I have a case where an image inside the original view for the snapshot might get updated, and thus I'd like to regenerate the snapshot but this fails of course and I have no idea what I should do. In my searchings I haven't found anyone with the same problems so maybe the problem is something else, I don't know, but my findings so far point to the view hierarchy.

Turn off Auto Layout.
Or
Use Constraints as IBOutlets

Related

iOS: Programmatically capture screenshot of view larger than screen

I would like to take a screenshot of an entire UICollectionView (or at least the "top 10" cells). The view doesn't fit on screen.
How do I programmatically capture a snapshot of a view larger than the iPhone's screen?
The problem of capturing a scroll view's content including the offscreen part has been tackled here many times before, so please, search before asking. (See for example: Getting a screenshot of a UIScrollView, including offscreen parts)
But even that won't help you here, because in particular, a collection view's cells that are not shown on the screen do not even exist; that is what cell reuse is about. So there is in fact nothing in existence to take a screen shot of. The cells you can see are the only cells there are.
To put it another way; the collection view does fit on the screen. What's on the screen is the collection view. There isn't any more of it.
You could perhaps construct in code a drawing that looks somewhat like your collection view, but it could be quite a bit of work.

IOS/Storyboard: View of element and selection on screen out of whack

I have been working in storyboard and something strange has happened. When I select an image, instead of the image actually highlighting an area above it is highlighted. This is true of all the elements in the View Controller. They are off vertically.
It's possible that in adding and subtracting elements I did something to the top layout but I can't tell what. All the elements are within a scrollview that, in turn, is within a view and the dimensions for both are set to 0,0,320,1000. I am not using auto layout.
The app still builds and runs normally but this makes it difficult to work on this screen in storyboard.
Here is a screenshot of the image and selection showing above it:
Anyone seen this or can suggest what could be causing it?

UITableView not appearing in UIScrollView

I am combining what was previously two separate views into one unified view inside a UIScrollView. One of the subviews I am dealing with is a UITableView that is used to display user data in a visually appealing manner.
Here is how I would like the UI to look:
but when I build the app with this view the table disappears. When I move the table further up on the screen though it displays, but with weird dimensions:
.
I do not know what is going on here or how to debug it. Has anyone encountered this behavior before and know of a possible resolution?
Never mind, looks like I solved it. I embedded the UITableView in a UI view and set the layout rules for the UITableView to fill the parent view, and I then applied the layout rules to UIView to position it where I wanted.

slideshow of a collection of images managed with uicollectionview

I'm using a UICollectionView (with horizontal layout) to manage a collection of images. The view controller that manages the collection view has the bottom toolbar visible with a play button to start a slideshow of the images in the collection. My question is what is the best way to implement a slideshow that involves a collection view? My initial thought was to try to make the collection view changing the visible cells with a UIView transition (transitionFromView or transitionWithView) with a cross dissolve option but I didn't get the effect I was expecting (maybe something wrong in my code). The other idea I had was to simply add a subview to the collection view to handle slideshow. This subview would have access to the data source and be able to iterate through the images. Don't know if this last option is a good way to approach the problem. Anyone has ever tried this and/or what would the recommendation be to solve this problem?
My idea is no need of collection view. In scrollview place imageview which display images. In timer Change the offset of scrollview. so it looks like automatically images are changing as like slide show.

Add a ScrollView Manually or Programmatically

I have an existing view with several elements, I was thinking of how to include a scrollview to contain all the existing elements without having to go through redesigning one by one the elements,
My objective is, that when my orientation changes to landscape, the elements behind can be scrollable specially when a keyboard is currently displayed.
Can this be done manually or programmatically, and how? Or is there any best approach for this type of scenario's?
*Edit (for clarity)
My apologies for the lack of clarity with the initial question;
I have a view with 3 Textfield, A button and 2 switch, Initially my app only supported the "Portrait" orientation, however, recently I have decided to add "Landscape" orientation support, I already did this. Now my problem is when I'm on landscape the view elements gets covered by the keyboard (specifically). So I was thinking if I could include a scrollview and put the views existing elements(objects) without having to re-design the nib, what I have done already;
I drag a scrollview into the view then making all the existing elements as children of the scrollview so the hierarchy looks like;
--view
--scrollview
--textfield
--button
The end product I get with this approach is that all the elements stacks on top of the other, so I've lost my original design.
So this is what Im asking, is there anyway, to add a scrollview without having to go through the design phase again.
TIA
If your view is designed in a nib, from IB you can select all the elements of the view and then go to Editor->Embed in->Scroll View from the menu.
Following are the steps-
1.Add the scrollview to the main view as subview.
2.create a new view which contains all your elements for the scrollview.
3.add the new view to the scrollview as subview.
4.set the content size of the scrollview as the size of the new view.
Change the frame of the newView accordingly on orientation and repeat step 4.
Thats all you need to do..

Resources