iOS 9 CollectionView slowing down - ios

I have been developing my app for iOS8, and haven't really had any issues regarding the scrolling speed. The moment I have upgraded to iOS9 the collectionView became very jumpy and staggering. I cant point out to any specific reason why. In my collection view, I have items with images that uses 3rd party library (SDWebImage) and I also use a custom layout library to achieve double column layout. Is there any obvious reason why this could be happening?

We were experiencing the same issues with collection views with iOS 9. The cells also contained images from SDWebImage including animated GIFs. It turned out not to be an issue with SDWebImage but with auto layout. If you have layout constraints with <= or >= inside your UICollectionViewCells (particularly on UITextViews, but still visible on UILabels, iOS 9 just chugs. Hope this helps someone.

In this case the problem was about handling fallback images on the imageView.
Briefly, each item in the CollectionView has an UIImageView. Each UIImageView has a fallback image in case the actual image doesnt resolve (the url is broken for example). So, the way these fallback images set was wrong in my app! I have set images every time a collectionview item is rendered in the viewport.
UIImageView * fallback = [UIImage imageNamed:#"imageName"];
was called everytime, which makes the scroll staggered. Interestingly it wasnt an issue on iOS8 but only in iOS9.
So when I started reading from a precreated dictionary of images instead of creating a new one every time, the scroll view started become smooth again.
Hope this helps to those having the same issue.

Related

Weird padding at top UINavigationController while animating to detail in iOS11

I'm posting here because I'm completely lost on this one.
I've searched all over the web, tried a lot of things myself, and searched weeks on this bug, but I can't find it.
So ever since iOS 11 (doesn't happen on iOS 10), everytime I press a button that activates the "show" segue in a UINavigationController the animation shows some weird padding at the top.
This padding disappears when the animation is finished.
I've changed the backgroundcolor of the superview to a red color, and the space you can see is indeed from the superview itself, so my guess is the whole UITableView is being moved down for some reason, although I'm not sure what exactly is the cause here.
(I'm using storyboard and AutoLayout constraints)
Another thing I noticed is that the spacing/padding you see is different on the iPhone X compared to the other devices (my guess is that it's the same height as the (non)safe area at the top? Again, not sure.
I don't think code is necessary to be provided here, as I wouldn't really know which part causes this behaviour (and there's a lot of code that I can't share for reasons..).
Any suggestions/help on how to fix this would be deeply appreciated!
Here are some examples:
iPhone X running iOS 11.1 (also happened on 11.0)
iPhone 8 gif
EDIT: I should add, some things I already tried:
tableView.contentInsetAdjustmentBehavior = .never
Setting headerviews to 0
tableView.setContentOffset(0, animated: false)
Playing with the translucency settings of the UINavigationBar
AutomaticallyAdjustContentInsets is set to false
So, as suggested by Spenser-Arn, I played around with the constraints and the Safe Areas, turns out, the safe areas where the cause of the issue.
Hope this helps other people as much as it helped me, and a big thankyou to Spenser-Arn!

ios 9, white splash screen instead of launch image, working fine previously, seemingly nothing changed to cause it

When my app launches, I see a white screen, instead of my launch image. I am using a storyboard, as required, and everything was working fine for about 2 months before this. I didn't change anything related to the image or storyboard either, it just started happening. I should mention that this started happening sometime after my first time uploading to TestFlight...but I doubt that is relevant. I have tried changing the constraints of the image to make it smaller than the bounds, and it still doesn't show up, so it isn't the size of the image. Again, I seemingly did nothing to have this start happening. Most of the questions related to my problem on stackoverflow have to do with the user not using a storyboard as required with iOS 9. Please help. Thanks.
UPDATE
I launched it on the simulator (iPad2) and the launch image for that was too small...there was white exposed above and to the right, I'm guessing I need to fix something in the storyboard but I'm not sure what.
UPDATE
I made a new storyboard and assigned the launch-screen config to it, and there is still a white screen.
I deleted the UIImageView and then inserted a new one with dimensions 200 x 200.
I added the image to the UIImageView.
I adjusted the constraints to the same values that I was using before.
Adding the image to the 200 x 200 UIImageView, before adding the constraints, seemed to be the key.
Make sure that one of the view controllers has the Is Initial View Controller checkbox checked in the Attributes Inspector in the right sidebar, that got me.
In project by default you LauchScreen.xib. Put your launch image there and set it’s top, bottom, leading, trailing constraints. Tap your project file and scroll down. There you will see: LauchScreen option and MainStoryboard. Set LauchScreen to your LauchScreen.xib. That’s it))

UIWebView with dynamic height leads to memory crash

I've a native iOS screen with UITableView inside that displays some article. Some cells in this table display article image, title, author, comments, etc. But there is a single cell with UIWebView inside that displays article content. This cell has dynamic height depending on the content size. Article content goes from the server as html string in JSON response and may contain images, videos and other things that supports HTML format. I can edit this string using regular expressions depending on some requirements (for example increase font size depending on app settings). Here is an image representing my UI structure:
The problem is that once the article content is very large, UITableView cell with UIWebView inside becomes also very large in height and this leads to memory crash. In my case this crash happens only on iPhone 6 Plus. On all of the other devices including iPhone (5, 5S, 6), iPad (2, 3, 4) (and probably other devices that supports iOS 7) app works correctly. As I suspect the reason is that iPhone 6 Plus has a high resolution screen and only 1 Gb of memory. So rendering the same content with the same amount of memory as in other devices, but in larger resolution, leads to memory crash.
I've created two test applications with UI as in the image below:
Both apps load the same HTML content in a single UIWebView. There is no other ui or logic in both apps.
In case a) all works correctly, scroll indicator appears and only visible content are rendered. When I'm scrolling fast, I can see white space that after a moment replaces with rendered content.
In case b) UIWebView stretches to fit content size. Test app is crashes (as my real app). As I suspect in this case even invisible content rendered and that leads to memory crash.
So my question is:
How can I fix this bug without scrolling inside UIWebView? Only UITableView should be scrollable
Make your UITableViewCell reusable. i-e(UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell"];).
one thing very important don't use [UIimage imagenamed:#"Imagename.jpg"] which leads you to a memory crash, you can use [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:#"Imagename" ofType:#"png"]];.
I hope it might help.
You can give webview constant height. it has scrollviewer inside. otherwise it is really hard to render large content at once. if you give webview constant size(max value) white spaces will be removed too.
edit: webviews own scrollview should work fine with tableviews scrollview bu i am not sure

Strange bug in iOS 7 UIImage (not showing or showing after delay)

Every time when we add UIImageView or simple UIView with some custom CALayer objects added to "layer" property to view hierarchy, there are some different scenarios:
1) all images (in uiimageviews and calayer) are drawn with random delay
2) some images are drawn, but some not, when we perform a simple touch event anywhere - they appear
3) some images are not drawn and they won't appear after simple touch events, the only way make them to appear is to minimize the app and to expand it again.
The last case appears much less than two others. That problem occurs only on iOS7, iOS 4.3-6.1 is totally OK. We have viewed a lot of possible solutions but they were pretty primitive and none of those helped.
Any help would be appreciated! Thanks in advance!
we solved the problem. For everyone, who has the same problem, - all you need is to create CALayer and UIImageView objects on main thread, while UIImage objects still could be created in background thread. All these fixes are needed only in iOS 7

UICollectionView not showing when running on iOS 7

I have a UIViewController subclass called FLProfileViewController that contains a UICollectionView. The view of FLProfileViewController is added as a subview to another UIViewController's view. The problem is that the UICollectionView doesn't render.... only if I execute the code from XCode 5 (final release). Even when running the same project from XCode 5 DP 6, the UICollectionView is rendered.
What is more, another instance of the same class is actually rendered when adding its view to a different UIViewController of the project.
Debugging the code, I see that numberOfSectionsInCollectionView: is called and returns 1, collectionView:numberOfItemsInSection: is called and returns 47.
But collectionView:cellForItemAtIndexPath: and collectionView:layout:sizeForItemAtIndexPath: are not being called.
Has anyone find a similar problem? Any ideas about what could be going on?
I have found the problem.
My UICollectionView is shown in the first screen of the app. To avoid showing it empty I have a fake app splash screen that extends the default one. The fake splash is shown with presentViewController:animated:completion: and doesn't disappear until I receive the data from the server.
The problem seems to be that with the final released version of the iOS7 SDK, the UICollectionView is not rendered if it is not visible to the user. In my case I was rendering the UICollectionView while the fake splash screen was still on top.
As I said, my solution worked in iOS6, and the iOS7 version shipped with XCode 5 DP 6.
Anyway, this might help someone else.

Resources