Best practices for managing facebook friends pics in iOS App - ios

i'm working on an iOS app which has a tableview containing facebook friends' list, I want to manage this list for scrolling performance.
i don't want to load the images each time user open that friend list view, and for that images can be saved locally but at the same time it would not be a good practice as users can change their profile pictures after we already saved older ones to file system.
So i just wondering what is the best way to manage this?
Also how can i get those images in best possible optimized size?
thanks in advance

You might be able to use setImageWithURL:placeholderImage: in the UIImageView class in AFNetworking to load a placeholder (or existing image) and then request the latest image which will get updated when fetched.
The docs are here:
http://afnetworking.org/Documentation/Categories/UIImageView+AFNetworking.html
The project is here:
https://github.com/AFNetworking/AFNetworking/
UIImageView should take care of resizing the images.

Well if you want to set placeholder image it is possible. The FBProfilePictureView is a UIView but if take a look into the code you'll see that they add UIImageView to it. That's why you can use:
for (UIView *view in cell.faceImageView.subviews) {
if ([view isKindOfClass:[UIImageView class]]) {
[(UIImageView*)view setImage:[UIImage imageNamed:#"placeholder"]];
break;
}
}
Ofc, that's a workaround. However until they provide better thing you don't have to mess here with AFNetworking(which is a great lib btw) and finding facebook image url ;).

Related

iOS, How to know whether a photo is a screenshot taken by user? How to delete photos in Photos?

In AppStore(China), an App called Tencent Mobile Manager released a series of functions related to photos, including detecting whether a photo is a screenshot taken by user, deleting photos.
I got screenshots of this app to demonstrate my question here (I added English texts myself for you since the app only shows Chinese):
This app knows what photos are screenshots and what not
When you tap Delete Button at the bottom, it shows:
Asking permission from user to delete photos
As far as I know, Photo APIs (AssetsLibrary, PHPhotoLibrary) in iOS don't give an absolute path of a photo, and iOS SandBox doesn't allow apps to delete user's assets as well, which makes deleting users photos almost impossible. All photos saved in iOS device follows the same naming system: "IMG_001.jpg", which makes it impossible to detect whether a photo is a screenshot from their names.
But apparently, this app implemented both functions. Does anyone have any ideas about this?
Thanks!
You can check using PHAsset's mediaSubtypes property.
let types = phAsset.mediaSubtypes /// phAsset is a PHAsset
let isScreenshot = types.contains(.photoScreenshot) /// true if is screenshot
For screenshot, its UTI is always a "public.png" and same size as screen (be sure you have multiply [UIScreen scale] on screen bounds width and height), just need to check these 2 metadata, you can easily identify screenshot.
Hope this will helps you

How to get all the system icons in Xcode

I want to be able to use the camera switch icon that is listed here not the plain one the switch one.
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/BarIcons.html
But in Xcode under my bar button item it does not seem to be listed?
I understand I am probably missing something blatantly obvious. Can anyone help with this?
We are talking about this like
Your aim is to grab the 1x and 2x icons?
There are several online resources (free and paid), but I assume your aim is to get those icons from the device directly in some way.
Those are the ones coming from the UITabBarItem init with TabBarSystemItem
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0]
If you are going to extract all of them, see here to have an idea.
If you want just to list them, taking a look at the headers you will find
typedef enum {
UITabBarSystemItemMore,
UITabBarSystemItemFavorites,
UITabBarSystemItemFeatured,
UITabBarSystemItemTopRated,
UITabBarSystemItemRecents,
UITabBarSystemItemContacts,
UITabBarSystemItemHistory,
UITabBarSystemItemBookmarks,
UITabBarSystemItemSearch,
UITabBarSystemItemDownloads,
UITabBarSystemItemMostRecent,
UITabBarSystemItemMostViewed,
} UITabBarSystemItem;
My 5cnt
Since iOS 13 I think the proper way would be to use SF-Symbols (just download the app). They are free and configurable
(Human Interface Guidelines )

Adding "stretchable" images to and image selected from gallery

Im trying to make an app for planning out where you want to put "shelves" on a wall (sounds strange i know ;) )
i have got it so the image is picked from the UIImagePickerController then loaded in a new ViewController i also have a button at the bottom of the ViewController that i want to open a list of images to select from that once selected the user can move around then stretch the required size if they don't like, delete and once they are happy i want my second button to save the image and put it into an email ready for sending.
I have looked at a few ways but none of them seem to be "adequate" would be so grateful anyone could suggest any ways or even help me with some code, I'm very new to this and this is my first app.
Im not too sure on the code you'd need to see as none of what is written yet is relevant to this part of the app
This is a 2 part so the first is, what way do i go about it?, the second is what code?
Thanks
-(UIImage *)GetStreachableImage
{
UIImage *takephotoButtonImagenormal = [UIImage imageNamed:CHOOSE_TAKE_NORMAL_IMAGE];
UIImage *strechableButtonImageNormal1 = [takephotoButtonImagenormal stretchableImageWithLeftCapWidth:takephotoButtonImagenormal.size.width/2 topCapHeight:takephotoButtonImagenormal.size.height/2];
takephotoButtonImagenormal=nil;
return strechableButtonImageNormal1;
}
try this

How to get system images programmatically? (example: disclosure chevron)

I want to create UIImageView with some system-image in it. (Example: the disclosure chevron image, etc.). How can I do so programmatically?
Note: I don't want to download the image and add it to the project, I want to fetch it from the user programmatically / from the Interface Builder.
From iOS 13 and Xcode 11 you can get system images by giving system name.
let image = UIImage(systemName: "info.circle")
Reference : UIImage Apple Documentation
If you mean you can to set the button to use the system disclosure icon, just do as #middaparka suggested and use this:
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
If you're asking how you can access the image directly, you can't do that. This is your only option: Use default apple icons for pdfs and docs in iOS app?
I think iOS-Artwork-Extractor is the tool you are looking for. It lets you extract the artwork into png files.
There is no clean programmatical way to access the images of system buttons. Quote from the documentation of the UIButton.imageView property:
The value of the property is nil for system buttons.
You may do an off screen rendering of the views and extract the resources on the fly but that's a very shaky approach. It's better to extract every asset you need and use them as intended. You'll suffer much more in the end with the programmatic way.

Does hiding "Legal" in MKMapView result in an App Store rejection?

I'm displaying an MKMapView in a somewhat small square. It's small enough that the "Legal" text pretty much blocks half the map, so I'd like to get rid of it.
Is this allowed:
for (UIView *view in mapView.subviews) {
if ([NSStringFromClass([view class]) isEqualToString:#"MKAttributionLabel"]) {
view.hidden = YES;
break;
}
}
Not sure if I am risking App Store rejection by hiding it or using this method?
Yes, it will probably get rejected. Either because having the link is a legal requirement, or it'll be detected that you're using a private class (MKAttributionLabel).
That being said, you might get away with it for a few releases, if they don't notice.
Have you thought about using a static image instead of an MKMapView?
You are using undocumented features/classes. Since your map feature is very limited, you are better off using google's static map api instead of linking to a full feature framework just to show a small square of a map.

Resources