UIImageView showing content with severe delay - objective-c

This is really a mystery for me (iOS 8, Xcode 6.x, Storyboard):
I'm presenting one view controller (VC) modally, overlaying on the VC presenting it.
On the VC being presented, there's a static image with pdf assets. When the VC is loaded, the image doesn't show up, then after like 20 seconds, it shows up.
What could have gone wrong? I have image cache setup inside this VC's code, so I removed that, result the same. I also tried to switch the asset to a png image, still the same. I'm really confused now, any comments?

Sounds like your not setting the image on the main thread.
Wrap this around your line of code where you set your image.
dispatch_async(dispatch_get_main_queue(), ^{
// set your image here
});

Related

UIImagePickerController and UIButton background images

I can successfully take a photo and set it to the background image for a button. The problem is that the image gets smushed. Should I be setting a crop on it or what am I missing for this to render the image correctly. Thanks.
After properly using constraints in the IB, the image then set to the button in a normal format. I found out that having dotted lines on the view controller due to constraints is a bad thing. After doing constraints the right way, the image showed perfectly. Thanks all for the help.

iOS 7 + Auto Layout: Strange UIImageView behaviour

I've got a strange UIImageView behaviour:
I've got a UIViewController with an embedded UIImageView and a close button. Very basic stuff, done a thousand times. I didn't use Auto Layout that much in the past, but another view controller in the same Storyboard has nearly the same config and doesn't appear as strange as this specific one.
In my Storyboard the Controller looks like that:
...and on the device it looks like that:
That image is 1024x768, so it should be filled to the bounds. Content mode in the image view is Aspect fill. When i dismiss the view, i can see that the upper part of the image view must be hidden at the top with some negative Y or something.
I need Auto Layout in this storyboard, because it's an iPhone + iPad App with both orientations.
Has someone hat a behaviour like that before?
Thank you!
Edit:
Here is the layout panel:
First, get rid of the alignment constraints, they are not needed if you're already anchoring your view to every side with a set distance.
Second, check the mode property of your UIImageView in the interface builder. If the image was not big enough and you had it set for "TOP" instead of, say, "aspect fill", you'd see something like this even though the view is actually covering the whole screen.
I'm sorry that I have to say this, but it was, as you certainly thought, my own fault.
The problem was that I made a photo with the iPad, and the iPad can be used in both orientations in this app. The photo was taken and was then used for an own view that allows the user to put annotations on the image.
The image gets then saved, and that was were the problem occured: I call
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0);
The landscape image was now taken into a portrait frame. After adjusting this and only allowing portrait mode, everything worked well.
Thanks anyways for your answers. And sorry for asking a question when the problem was another one and my own fault.

Can a UIViewImage draw its image outside its frame?

When making a photo viewer app found that our UIImageView controller is drawing its image outside its frame when the content mode is different neither ScaleToFill nor Aspect Fit.
Trying to understand why; I isolated the problem making a new project which only has a UIImageView with the following frame (50,50,100,100). The image size contained in it is (4592,3056).
After running the app, with the content mode set to ScaleToFill and AspectFit it all worked as expected:
But after setting the contentMode of the UIImageView to TopLeft, the image is drawn outside its frame, the odd thing is that the log from the frame after all has been drawn is still the original {50,50,100,100}.
I've try to understand the issue by moving the Autoresize, the clips and the content mode of the UIViewController but the result is the same.
set clipToBounds = YES on the view.
its NO by default because that makes drawing way cheaper

UITextView not showing text until I rotate it

I'm using a UISplitViewController, with a view that has a UITextView as the master view, but the text does not load until I rotate the ipad twice.
Logging when the app starts shows that the text view is available and the text inside it (which is defined in the nib file) is also loaded properly.
What am I doing wrong?
It seems like I've found the limit to how many characters can be initially loaded into UITextView in a UIPopoverController (for portrait mode in UISplitViewController). The maximum number of characters is 621.
I thought it weird that if I override the text view in viewDidLoad with
self.textView.text = #"hello";
it would work, but loading the text from the nib as is didn't. Through some trial and error, it seems like 621 is the maximum number characters before the text view doesn't show upon initial load.
Using a UIWebView and loading the content in code fixes this.

IKImageView resize is blocky

I am putting an image into an IKImageView, and immediately sizing it to fit. Whenever I do this, the image originally appears at 1-1 size (huge) and then resizes down, which would be fine if the animation was smooth. However, the animation looks ... fluttery? There are big blocks, like 2 inches square, of the image that appear and shrink independently of each other. The effect is a little annoying, and almost to the level where it might give an epileptic a seizure... (I'm exaggerating a little).
Is this a bug in IKImageView? Is it a bug in the animation? Will it go away if I turn off the animation (How do I do that? setAnimates: NO doesn't seem to do anything, nor does overloading animates to return NO in my subclass...
EDIT: addedcode:
NSImage* image = [doc currentImage];
[imageView setImage: image];
[imageView zoomImageToFit: self];
This is in the app controller, so self is the application (or plugin, depending on which version I'm looking at)
If you tell the IKImageView to autoresize, then it won't animate the new image to the new size and the artefacts will not be a problem. The image will be sized to fit in the image view immediately.
imageView.autoresizes = YES;