UIImageView UIScrollView HighRes Image memory warning - uiscrollview

I'm populating a UIScrollView on iPad with above 10 photos fullscreen in landscape mode (1024x768). I'm facing out a very big problem: I load all the UIImageView asynchronously using GDC, and the add all the view to the ScrollView as subview.
When I load a different gallery, first I remove all the View in the UIScrollVIew, and then reload asynchronously all the thing.
If I don't switch between the gallery fast, there's no problem; instead, if I switch between a gallery and other, I receive different memory warning and the application crash. I look with instruments, but there's no leak and the memory consumpion is intensive when I add all the view to subview, but it's not raising.
What can be the problem? Maybe I can use NSAutoreleasePool to force the purging of objects?

When you use max resolution photos inside scrollView you can face memory problems
If you have a small scrollView and you want to show thumbnails you can't use the full size photo for the thumbnail you should create in pixelmator, Photoshop etc. a small photo of your photos with this approach you won't face memory problems
If you have a full screen scrollView with full screen imageViews you can remove fromSuperView the images that aren't visible in the scrollView with this approach all your memory problems will disappear
I hope this help
Good luck

Related

Autolayout just not working for every screen size

My app is a game and the menus have many labels and buttons and I cannot get all of the different screen sizes(iPhone 4/5/6/6+) to look acceptable from the same set of constraints.
Is there a way that you use to synchronize all the views together to look the same on all different screen sizes?
The project is locked to only portrait so I don't need to consider rotation.
For Autolayout, you
Consider the screen sizes you want to support.
Which view/buttons/labels/imageview etc you want to remain fixed while in
different screen size.
Which view/buttons/labels/imageview etc can be scaled to fit the screen.
Now if by scaling the things you can fit on the screen then you are good to go. But if you still can't find way then you would probably need to you use scrollview and and add a UIView (let's call it content view) to it put your all stuff in it and constraint them vertically all the way from top to bottom.This video can help you if you want to use scrollview
https://www.youtube.com/watch?v=UnQsFlMGDsI

Xcode 6.0/6.1 Interface Builder resizes views to fit whole content when clicked on the corner grip to resize

I think this is an obvious bug on Xcode 6.0.1 but I'm searching for at least a workaround. In interface builder, I have an image view that is smaller in dimensions than the image that it contains. Here is my newly created, fresh nib with just an image view, the heart image is a larger PNG file than the containing image view:
So far so good. However, when I click on the any of the grips at the corners/edges of the view to resize the image view, it immediately changes to this the very moment I click on the grip:
This happens whenever I try to resize by hand (I can resize using width/height values at inspector though) and I have hard time trying to fit my design into the nib. The problem happens both on nibs and the storyboards. Does anyone know a workaround?
UPDATE: I've updated to Xcode 6.1 but I'm still having the same problem.
The same result I've noticed when close and reopen the project. The view continues to grow up every time. I have created a simple project to search the cause of the wrong behavior of the autoresizing mask (flexible width AND align to right).
So, try to disable "flexible width/height" and "align to right". Keep the "align to left" only.
This answer is for autolayout-enabled views/nibs. For autoresizing mask solution, see Nicolai Nita's answer: Xcode 6.0/6.1 Interface Builder resizes views to fit whole content when clicked on the corner grip to resize
I've solved the problem by setting the content compression resistance priority (both vertical and horizontal) to 250 from 750. I don't know why it wasn't the case before Xcode 5 though.

How to pan a zoomed out UIImageView inside an UIScrollView?

I have an UIScrollView which contains one UIImageView. Everything is working correctly, I can zoom in and out, when zoomed in I can pan around, etc.
The problem that I am unable to solve is how to pan a zoomed out image around the screen. The user needs to be able to zoom the image out until it's small, and then move that small image to any point on the screen. Sadly, it's stuck in the center of the screen (usually, it would be stuck in the top left corner but I did fix that problem).
There are a couple of things you need to do here. I suggest doing them in viewWillAppear rather than viewDidLoad because if you're using storyboards, it doesn't work quite right in viewDidLoad.
First, you need to set the content size property of your scroll view to be the size of the photo itself because you want the entire area of your photo to be scrollable.
self.scrollView.contentSize=self.photoShown.size;
photoShown is UIImage. scrollView is a UIScrollView
Second, you need to set the frame of your UIImageView that houses your image to be the size of your image:
self.imageView.frame=CGRectMake(0,0, self.photoShown.size.width, self.photoShown.size.height);
if you haven't done this, then the frame of the UIImageView is the size of the screen itself and there is simply nowhere to pan. That's why it needs to be bigger, so you can pan to the regions not currently shown on screen.

UITableView won't scroll on iPad, but does on iPhone

If I turn my iPad to landscape a couple of row of table view (and the footer) are just off the bottom of the screen although it fits in portrait.
My problem is that when I use my finger to "pull" view port up to see the material off the bottom I can see it while I keep my finger in place, but when I remove the finger, the viewport drops down again and the material at the bottom disappears.
Same code scrolls fine on iPhone (fonts are too big and so on but that is a different issue)
What am I doing wrong?
Peter
As for what exactly your doing wrong... we can't see your code so we can't tell you. But shed some light on what is happening.
A UITableView is a UIScrollView and how far you can scroll is based on the size view (think frame) compared to the size(CGSize) of the content(contentSize) of the UIScrollView. If the 'frame' is bigger than the contentSize then no scrolling is needed, but if the content is larger, then you can scroll by the difference between the two.
In short, the contentSize of your UITableView is incorrect. This can be caused numerous ways, including auto-resizing on device rotations, dynamically changing table/footer heights without updating the table, etc.

Will reusing a UIImage in the thumbnail version of the image be faster?

I have a huge amount of images of size 768 by 1024.
I want to make a scroll view with their thumbnailed versions as programmatically generated buttons.
Now my question is:
Should I make a thumbnail for each image and add these as a resource and create my buttons using these small (100x100 pixel) versions or should I use the same big images but just make the button of size 100x100?
Will the second one try to load the whole big image first and then resize it?
Thanks
You probably want to see this stack post re lazy loading of images in UIScrollView:
UIScrollView lazy loading of images to reduce memory usage and avoid crash
Also see the UIScrollView sample apps and discussion. They cover this issue

Resources