FBPlacePickerViewController.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Copyright 2010-present Facebook.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <CoreLocation/CoreLocation.h>
  17. #import <UIKit/UIKit.h>
  18. #import "FBCacheDescriptor.h"
  19. #import "FBGraphObjectPickerViewController.h"
  20. #import "FBGraphPlace.h"
  21. @protocol FBPlacePickerDelegate;
  22. /*!
  23. @class FBPlacePickerViewController
  24. @abstract
  25. The `FBPlacePickerViewController` class creates a controller object that manages
  26. the user interface for displaying and selecting nearby places.
  27. @discussion
  28. When the `FBPlacePickerViewController` view loads it creates a `UITableView` object
  29. where the places near a given location will be displayed. You can access this view
  30. through the `tableView` property.
  31. The place data can be pre-fetched and cached prior to using the view controller. The
  32. cache is setup using an <FBCacheDescriptor> object that can trigger the
  33. data fetch. Any place data requests will first check the cache and use that data.
  34. If the place picker is being displayed cached data will initially be shown before
  35. a fresh copy is retrieved.
  36. The `delegate` property may be set to an object that conforms to the <FBPlacePickerDelegate>
  37. protocol. The `delegate` object will receive updates related to place selection and
  38. data changes. The delegate can also be used to filter the places to display in the
  39. picker.
  40. */
  41. @interface FBPlacePickerViewController : FBGraphObjectPickerViewController
  42. /*!
  43. @abstract
  44. The coordinates to use for place discovery.
  45. */
  46. @property (nonatomic) CLLocationCoordinate2D locationCoordinate;
  47. /*!
  48. @abstract
  49. The radius to use for place discovery.
  50. */
  51. @property (nonatomic) NSInteger radiusInMeters;
  52. /*!
  53. @abstract
  54. The maximum number of places to fetch.
  55. */
  56. @property (nonatomic) NSInteger resultsLimit;
  57. /*!
  58. @abstract
  59. The search words used to narrow down the results returned.
  60. */
  61. @property (nonatomic, copy) NSString *searchText;
  62. /*!
  63. @abstract
  64. The place that is currently selected in the view. This is nil
  65. if nothing is selected.
  66. */
  67. @property (nonatomic, retain, readonly) id<FBGraphPlace> selection;
  68. /*!
  69. @abstract
  70. Configures the properties used in the caching data queries.
  71. @discussion
  72. Cache descriptors are used to fetch and cache the data used by the view controller.
  73. If the view controller finds a cached copy of the data, it will
  74. first display the cached content then fetch a fresh copy from the server.
  75. @param cacheDescriptor The <FBCacheDescriptor> containing the cache query properties.
  76. */
  77. - (void)configureUsingCachedDescriptor:(FBCacheDescriptor *)cacheDescriptor;
  78. /*!
  79. @method
  80. @abstract
  81. Creates a cache descriptor with additional fields and a profile ID for use with the
  82. `FBPlacePickerViewController` object.
  83. @discussion
  84. An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
  85. the view controller. It may also be used to configure the `FBPlacePickerViewController`
  86. object.
  87. @param locationCoordinate The coordinates to use for place discovery.
  88. @param radiusInMeters The radius to use for place discovery.
  89. @param searchText The search words used to narrow down the results returned.
  90. @param resultsLimit The maximum number of places to fetch.
  91. @param fieldsForRequest Addtional fields to fetch when making the Graph API call to get place data.
  92. */
  93. + (FBCacheDescriptor *)cacheDescriptorWithLocationCoordinate:(CLLocationCoordinate2D)locationCoordinate
  94. radiusInMeters:(NSInteger)radiusInMeters
  95. searchText:(NSString *)searchText
  96. resultsLimit:(NSInteger)resultsLimit
  97. fieldsForRequest:(NSSet *)fieldsForRequest;
  98. @end
  99. /*!
  100. @protocol
  101. @abstract
  102. The `FBPlacePickerDelegate` protocol defines the methods used to receive event
  103. notifications and allow for deeper control of the <FBPlacePickerViewController>
  104. view.
  105. The methods of <FBPlacePickerDelegate> correspond to <FBGraphObjectPickerDelegate>.
  106. If a pair of corresponding methods are implemented, the <FBGraphObjectPickerDelegate>
  107. method is called first.
  108. */
  109. @protocol FBPlacePickerDelegate <FBGraphObjectPickerDelegate>
  110. @optional
  111. /*!
  112. @abstract
  113. Tells the delegate that data has been loaded.
  114. @discussion
  115. The <FBPlacePickerViewController> object's `tableView` property is automatically
  116. reloaded when this happens. However, if another table view, for example the
  117. `UISearchBar` is showing data, then it may also need to be reloaded.
  118. @param placePicker The place picker view controller whose data changed.
  119. */
  120. - (void)placePickerViewControllerDataDidChange:(FBPlacePickerViewController *)placePicker;
  121. /*!
  122. @abstract
  123. Tells the delegate that the selection has changed.
  124. @param placePicker The place picker view controller whose selection changed.
  125. */
  126. - (void)placePickerViewControllerSelectionDidChange:(FBPlacePickerViewController *)placePicker;
  127. /*!
  128. @abstract
  129. Asks the delegate whether to include a place in the list.
  130. @discussion
  131. This can be used to implement a search bar that filters the places list.
  132. If -[<FBGraphObjectPickerDelegate> graphObjectPickerViewController:shouldIncludeGraphObject:]
  133. is implemented and returns NO, this method is not called.
  134. @param placePicker The place picker view controller that is requesting this information.
  135. @param place An <FBGraphPlace> object representing the place.
  136. */
  137. - (BOOL)placePickerViewController:(FBPlacePickerViewController *)placePicker
  138. shouldIncludePlace:(id<FBGraphPlace>)place;
  139. /*!
  140. @abstract
  141. Called if there is a communication error.
  142. @param placePicker The place picker view controller that encountered the error.
  143. @param error An error object containing details of the error.
  144. */
  145. - (void)placePickerViewController:(FBPlacePickerViewController *)placePicker
  146. handleError:(NSError *)error;
  147. @end