Polyv Help Center

Help Center

手机开播场景 文档管理

Updated: 2023-04-17 15:27:57

1 Feature Overview

The document management module includes features such as selecting a document, viewing details of the selected document, uploading a document, and deleting a document. The document management page is a popup layer, and the entire interface is encapsulated in PLVLSDocumentSheet.

2 Usage Demo

PLVLSDocumentSheet is a popup layer page that inherits from the base class PLVLSBottomSheet. To use the document management popup, simply create a popup object and call the -showInView: method to display it.

self.docSheet = [[PLVLSDocumentSheet alloc] init];
self.docSheet.delegate = self;
[self.docSheet showInView:self.superview];

The page that triggers the document management popup must conform to the protocol PLVLSDocumentSheetDelegate and implement the following delegate methods. The PPT & whiteboard page should switch to a new document or document page, or switch to the whiteboard, within these delegate methods:

@protocol PLVLSDocumentSheetDelegate <NSObject>

///  选择文档、文档页回调
/// @param documentSheet 文档弹层对象
/// @param autoId 选择的文档autoId
/// @param pageIndex 选择的文档页序号(页码)
- (void)documentSheet:(PLVLSDocumentSheet *)documentSheet didSelectAutoId:(NSInteger)autoId pageIndex:(NSInteger)pageIndex;

@end

3 Implementation Details

The document management popup PLVLSDocumentSheet consists of the following components:

@property (nonatomic, strong) UIScrollView *scrollView ;            // 文档父层View
@property (nonatomic, strong) PLVLSDocumentListView *docListView;   // 文档列表视图
@property (nonatomic, strong) PLVLSDocumentPagesView *docPagesView; // 文档页面列表视图

scrollView is a horizontally paging scroll view. The first page is the document list view docListView. After selecting a specific document, the scroll view scrolls to the second page, displaying the page detail list view docPagesView of the selected document.

3.1 PLVLSDocumentListView

The document list view class PLVLSDocumentListView encapsulates the business logic of document management internally. For external use, simply initialize an instance of PLVLSDocumentListView, conform to the protocol PLVLSDocumentListViewDelegate, and implement the relevant callbacks.

self.docListView = [[PLVLSDocumentListView alloc] init];
self.docListView.delegate = self;
[self.scrollView addSubview:self.docListView];
self.docListView.frame = self.scrollView.bounds;

The callback methods of the protocol PLVLSDocumentListViewDelegate are defined as follows:

@protocol PLVLSDocumentListViewDelegate <NSObject>

///  点击上传文档按钮回调
///
/// @param documentListView 文档列表对象
- (void)documentListViewUploadDocument:(PLVLSDocumentListView *)documentListView;

///  文档上传须知按钮响应回调
///
/// @param documentListView 文档列表对象
- (void)documentListViewShowTip:(PLVLSDocumentListView *)documentListView;

///  选择文档回调
///
/// @param documentListView 文档列表对象
/// @param model 选择的文档数据对象
/// @param isChangeDocument YES 切换文档,NO 没有切换只是单纯的二次点击
- (void)documentListView:(PLVLSDocumentListView *)documentListView didSelectItemModel:(PLVLSDocumentModel *)model changeDocument:(BOOL)isChangeDocument;

@end

3.2 PLVLSDocumentPagesView

The document page list view only appears when a specific document is selected for display. Therefore, it is initialized on demand and recycled when the document selection is canceled:

// 选中某个文档时
if (!self.docPagesView) {
    self.docPagesView = [[PLVLSDocumentPagesView alloc] init];
    self.docPagesView.delegate = self;
}

// 返回文档列表时
[self.docPagesView removeFromSuperview];
self.docPagesView = nil;

The data required by docPagesView is held by the document management popup docSheet. It is only assigned to docPagesView when the document page details need to be displayed.

self.docPagesView.title = self.pagesTitle; // 文档标题
[self.docPagesView setPagesViewDatas:self.imageUrls]; //  设置文档页面缩略图
[self.docPagesView setSelectPageIndex:self.selectPageId]; // 选中文档页面

Additionally, conform to the protocol PLVLSDocumentPagesViewDelegate and implement the following methods:

@protocol PLVLSDocumentPagesViewDelegate <NSObject>

///  点击返回按钮响应回调
///
/// @param documentPagesView 文档列表页面对象
- (void)documentPagesViewDidBackAction:(PLVLSDocumentPagesView *)documentPagesView;

///  选中文档页面回调
///
/// @param documentPagesView 文档列表页面对象
/// @param index 选择的文档页面序号
- (void)documentPagesView:(PLVLSDocumentPagesView *)documentPagesView didSelectItemAtIndex:(NSInteger)index;

@end
联系客服,在线咨询
在线咨询