FBProfilePictureView loading with delay - ios

I'm setting the FBProfilePictureView with the user id but it takes a while, so i'd like to know if there is anything that indicates when the loading is done, so i can show an ActivityIndicator

You should take a look at SDWebImage librabry, you will be able to put a placeholder while loading your picture or add a progress indicator. I think everything you need is there.
Hope it helps.

There is no delegate or something similar in FBProfilePictureView that indicates when the image finished loading. Looking at the source code (https://github.com/facebook/facebook-ios-sdk/blob/master/src/UI/FBProfilePictureView.m) it seems like it should be fairly easy to fork the repo and add a few changes to notify you when the HTTP request has finished.

Related

iOS Swift 4 before loading content

I build chat app using Firebase API right now. I wan't to make preload icons like on facebook screenshot. I thought i can create empty images and label fields and fill them after content loaded, but i don't know how to check if all data loaded from DB. How i can do that in correct way?
This is where i want to place objects
Install ListPlaceholder this lib.
import ListPlaceholder
To show the loader, start showing this from start
tableView.showLoader()
To hide the loader, end showing after data has been loaded
tableView.hideLoader()
Please refer this may get help.
https://github.com/malkouz/ListPlaceholder
Facebook has it's own library called Shimmer. To use this on tableview, you can follow this StackOverflow question answer.
You'll just have to create the UIView you want to animate and above that you'll have to add your FBShimmeringView. At the end set shimmeringView.shimmering = true to start shimmering
To hide the loading use tableView.hideLoader()
ListPlaceholder helped me to resolve the issue. All that I did was added the ListLoader.swift file to my project and added tableView.reloadData(), tableView.showLoader() in viewDidAppear in the tableView where I wanted to show loading.
( ListLoader.swif uses visibleCells to determine the number of rows on which the loading should be shown. In my applications, visibleCell's count was incorrect on calling tableView.showLoader() method in viewDidLoad )

SDWebImage - SDWebImagePrefetcher not using transformDownloadedImage

I am currently successfully using 'SDWebImageManager downloadImageWithURL' for downloading single images , followed by the delegate method 'transformDownloadedImage' automatically called upon completion to resize the images before caching them.
I would like, however, in the background to prefetch a bunch of images (~25) not yet displayed using the prefetcher code below in a similar way. However the problem is that the 'transformDownloadedImage' delegate is not called upon completion (of 1 or all the images) - images are cached as is.
SDWebImagePrefetcher *prefetcher = [SDWebImagePrefetcher sharedImagePrefetcher];
[prefetcher prefetchURLs:array progress:nil completed:^(NSUInteger completedNo, NSUInteger skippedNo) {
}];
Am I missing something? or is there some other efficient way to do this by pulling out the cached images upon completion, resizing, and reinserting? I am using "UIImage+Resize" to resize and manipulate, and obviously this needs to happen in background without blocking the UI.
Any and all advice about how to go about this efficiently will be greatly appreciated!
If you look at the implementation of SDWebImagePrefetcher you'll notice that it's using SDWebImageManager to perform the downloads, and it's available as a property. So you should be able to do something like this:
prefetcher.manager.delegate = self;
Now you can implement the downloadImageWithURL delegate method as you did before. I didn't try it but it should work.

SDWebImage: running a method BEFORE image is refreshed and placed

So before anything else, I found this:
SDWebImage process images before caching
which kind of helps but I really want to use SDWebImage, is there a way to process the images via a method outside of the class before completion?
To my understanding, the completion block in
- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock
is run after the image is placed. I would like to run a method before the loaded image is placed.
Is there an easy way to do this?
thank you,
reposting my answer from: SDWebImage process images before caching
SDWebImage developer Olivier Poitrey answered this question for me here.
You have to implement the SDWebImageManagerDelegate protocol and then set it as the shared manager's delegate like this:
SDWebImageManager.sharedManager.delegate = self;
using the imageManager:transformDownloadedImage:withURL: instance method.
More information.
Worked perfectly for me.
Two options:
Write your own routine that would Use Asynchronous Image Caching Independently, process the image, and then set the image view's image property. There are interesting permutations you'd have to worry about (e.g. if cell has been reused before the download has finished, you'd want to cancel the prior image download for that image view), so you need to be careful, but it's not too bad.
Probably easier, though, would be to write your own UIImageView category that is like the existing one for SDWebImage (UIImageView+WebCache.m), but introduce your own permutation of setImageWithURL which is just like the original, but offers a pre-process completion block, too.
I'd probably lean towards the latter, but both would work perfectly well

iOS some problems during download multiple images and update UIProgressView

I have this 3 classes.
MyViewController.m (click to see code)
MySync.m (click to see code)
ImageDownload.m (click to see code)
When I download a image, I try to update the UIProgressView in my UIViewController, but the update are delayed, and I see a strange problem (see the blank space in attach image).
When all downloads are complete and execute the method "syncComplete" of "MyViewController", the method "dismissAlertView" is not triggered :S
I hope somebody can help me.
Thanks.
Assuming that syncComplete is the one calling dismissAlertView, make sure iI is calling to the UI thread (main thread). Something like this if you use GCD:
dispatch_async (dispatch_get_main_queue (),  ^{
// call the dismissAlertView method here
}); 

Black temporary alert box in iOS

I need a black temporary transparent box that must show something like "Loading...." with a spinner it. We can see such a view in twitter when "Tweeting" an update - it says "Sending tweet..." kinda thing.
Is this an inbuilt behavior in UIKit. How do I get this box to show up on screen for a few seconds and disappear.
please help.
You need to use DSActivityView. All this is handled there. Instead of doing your own thing I suggest you use this.
For what you need this is how you need to go -
#import "DSActivityView.h"
[DSActivityView activityViewForView:self.view withLabel:#"Tweeting"]; //to show spinner with label
[DSActivityView removeView]; //once its done
You can also try using MBProgressHud

Resources