IDMPhotoProtocol.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // IDMPhotoProtocol.h
  3. // IDMPhotoBrowser
  4. //
  5. // Created by Michael Waterfall on 02/01/2012.
  6. // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "IDMPBConstants.h"
  10. // Name of notification used when a photo has completed loading process
  11. // Used to notify browser display the image
  12. #define IDMPhoto_LOADING_DID_END_NOTIFICATION @"IDMPhoto_LOADING_DID_END_NOTIFICATION"
  13. // If you wish to use your own data models for photo then they must conform
  14. // to this protocol. See instructions for details on each method.
  15. // Otherwise you can use the IDMPhoto object or subclass it yourself to
  16. // store more information per photo.
  17. //
  18. // You can see the IDMPhoto class for an example implementation of this protocol
  19. //
  20. @protocol IDMPhoto <NSObject>
  21. @required
  22. // Return underlying UIImage to be displayed
  23. // Return nil if the image is not immediately available (loaded into memory, preferably
  24. // already decompressed) and needs to be loaded from a source (cache, file, web, etc)
  25. // IMPORTANT: You should *NOT* use this method to initiate
  26. // fetching of images from any external of source. That should be handled
  27. // in -loadUnderlyingImageAndNotify: which may be called by the photo browser if this
  28. // methods returns nil.
  29. - (UIImage *)underlyingImage;
  30. // Called when the browser has determined the underlying images is not
  31. // already loaded into memory but needs it.
  32. // You must load the image asyncronously (and decompress it for better performance).
  33. // See IDMPhoto object for an example implementation.
  34. // When the underlying UIImage is loaded (or failed to load) you should post the following
  35. // notification:
  36. //
  37. // [[NSNotificationCenter defaultCenter] postNotificationName:IDMPhoto_LOADING_DID_END_NOTIFICATION
  38. // object:self];
  39. //
  40. - (void)loadUnderlyingImageAndNotify;
  41. // This is called when the photo browser has determined the photo data
  42. // is no longer needed or there are low memory conditions
  43. // You should release any underlying (possibly large and decompressed) image data
  44. // as long as the image can be re-loaded (from cache, file, or URL)
  45. - (void)unloadUnderlyingImage;
  46. @optional
  47. // Return a caption string to be displayed over the image
  48. // Return nil to display no caption
  49. - (NSString *)caption;
  50. // Return placeholder UIImage to be displayed while loading underlyingImage
  51. // Return nil if there is no placeholder
  52. - (UIImage *)placeholderImage;
  53. @end