如何获得图像的路径?

时间:2017-11-02 20:02:15

标签: ios swift phasset

如何获取PHAsset图片的路径或目录?

我遇到了@diegomen写的答案here,但当我尝试selectedAssets[0].PHAsset.getURL()时,它要求输入参数,但@diegomen表示它不需要评论中的参数。

我申请错了吗?

或者是否有其他方式从PHAsset获取图片路径?

注意:我在@Clay中找到了另一个解决方案here,但它似乎不是一个很好的做法。

2 个答案:

答案 0 :(得分:2)

如果您已将图像存储在本地文件路径中,并且想从PHAsset图像地址中检索图像文件路径,则使用此功能:

[asset requestContentEditingInputWithOptions:[PHContentEditingInputRequestOptions new] completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
    NSURL *imageURL = contentEditingInput.fullSizeImageURL;
    }];

asset = PHAsset * asset

答案 1 :(得分:-1)

您应该将图像存储到本地文件。之后你会有文件网址。

template<class ItemType>
class DoubleListInterface
{
public:
    /** Sees whether this list is empty.
      @return True if the list is empty; otherwise returns false. */
    virtual bool isEmpty() const = 0;

    /** Gets the current number of entries in this list.
      @return The integer number of entries currently in the list. */
    virtual int getLength() const = 0;

    /** Inserts an entry into this list at the front.
      @pre  None.
      @post  If the insertion is successful, newEntry is at the front of
        the list, other entries are renumbered accordingly, and the returned value
        is true.
      @param newEntry  The entry to insert into the list.
      @return  True if insertion is successful, or false if not. */
    virtual bool insertFront(const ItemType& newEntry) = 0;

     /** Inserts an entry into this list at the back.
        @pre  None.
        @post  If the insertion is successful, newEntry is at the back of
          the list, other entries are renumbered accordingly, and the returned value
          is true.
        @param newEntry  The entry to insert into the list.
        @return  True if insertion is successful, or false if not. */
     virtual bool insertBack(const ItemType& newEntry) = 0;

    /** Removes the entry at a given position from this list.
      @pre  None.
      @post  If 1 <= position <= getLength() and the removal is successful,
        the entry at the given position in the list is removed, other
        items are renumbered accordingly, and the returned value is true.
      @param position  The list position of the entry to remove.
      @return  True if removal is successful, or false if not. */
    virtual bool remove(int position) = 0;

    /** Removes all entries from this list.
      @post  List contains no entries and the count of items is 0. */
    virtual void clear() = 0;

    /** Gets the entry at the given position in this list.
      @pre  1 <= position <= getLength().
      @post  The desired entry has been returned.
      @param position  The list position of the desired entry.
      @return  The entry at the given position. */
    virtual ItemType getEntry(int position) const = 0;

    virtual ~DoubleListInterface() { }
};

#endif