PTTabbedDocumentViewController

@interface PTTabbedDocumentViewController : UIViewController <PTDocumentOpening>

A container view controller that displays multiple documents with a tab bar control to allow switching between documents.

  • Whether multiple tabs can be displayed.

    The default value of this property is YES. If tabs are disabled, the tab bar will be hidden and all tabs except the selected tab will be removed.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL tabsEnabled;

    Swift

    var tabsEnabled: Bool { get set }
  • The maximum number of tabs allowed. There is no limit by default.

    When the maximum number of tabs is reached, adding subsequent tabs will remove other tabs to respect the limit.

    Note

    The value of this property must be greater than zero.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger maximumTabCount;

    Swift

    var maximumTabCount: UInt { get set }
  • An array of the URLs managed by the view controller and displayed by the tab bar interface. The tabs are displayed in the same order as in the array.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nonnull) NSArray<NSURL *> *tabURLs;

    Swift

    var tabURLs: [URL] { get set }
  • Returns the PTDocumentViewController at the specified tab index.

    Declaration

    Objective-C

    - (nullable PTDocumentViewController *)documentViewControllerAtIndex:
        (NSUInteger)index;

    Swift

    func documentViewController(at index: UInt) -> PTDocumentViewController?

    Parameters

    index

    the view controller’s tab index

    Return Value

    the PTDocumentViewController at the specified tab index, or nil if it is not loaded.

  • Inserts the given PTCoordinatedDocument at the end of the tab bar.

    If a tab showing a tab backed by the same URL already exists in the view controller then it will not be re-added.

    Declaration

    Objective-C

    - (void)addTabWithCoordinatedDocument:
                (nonnull PTCoordinatedDocument *)coordinatedDocument
                                 selected:(BOOL)selected
                        completionHandler:(nullable void (^)(NSError *_Nullable))
                                              completionHandler;

    Swift

    func addTab(with coordinatedDocument: PTCoordinatedDocument, selected: Bool, completionHandler: ((Error?) -> Void)? = nil)

    Parameters

    coordinatedDocument

    The PTCoordinatedDocument to add to the end of the tab bar.

    selected

    Whether to select the tab after it has been added.

    error

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

  • Inserts the given PTCoordinatedDocument into the tab bar at the specified index.

    If a tab showing a tab backed by the same URL already exists in the view controller then it will not be re-added.

    Declaration

    Objective-C

    - (void)insertTabWithCoordinatedDocument:
                (nonnull PTCoordinatedDocument *)coordinatedDocument
                                     atIndex:(NSUInteger)index
                                    selected:(BOOL)selected
                           completionHandler:(nullable void (^)(NSError *_Nullable))
                                                 completionHandler;

    Swift

    func insertTab(with coordinatedDocument: PTCoordinatedDocument, at index: UInt, selected: Bool, completionHandler: ((Error?) -> Void)? = nil)

    Parameters

    coordinatedDocument

    The PTCoordinatedDocument to add to the end of the tab bar.

    selected

    Whether to select the tab after it has been added.

    error

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

  • Removes the first occurence of the tab

    Declaration

    Objective-C

    - (void)removeTabWithCoordinatedDocument:
        (nonnull PTCoordinatedDocument *)coordinatedDocument;

    Swift

    func removeTab(with coordinatedDocument: PTCoordinatedDocument)

    Parameters

    url

    The URL to remove from the tab bar.

  • Inserts the given URL at the end of the tab bar.

    If the URL already exists in the view controller then it will not be re-added.

    Declaration

    Objective-C

    - (BOOL)addTabWithURL:(nonnull NSURL *)url
                 selected:(BOOL)selected
                    error:(NSError *_Nullable *_Nullable)error;

    Swift

    func addTab(with url: URL, selected: Bool) throws

    Parameters

    url

    The URL to add to the end of the tab bar.

    selected

    Whether to select the tab after it has been added.

    error

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    YES if the URL could be added to the tab bar. Returns NO if an error occurred.

  • Inserts the given URL into the tab bar at the specified index.

    If the URL already exists in the view controller then it will not be re-added.

    Declaration

    Objective-C

    - (BOOL)insertTabWithURL:(nonnull NSURL *)url
                     atIndex:(NSUInteger)index
                    selected:(BOOL)selected
                       error:(NSError *_Nullable *_Nullable)error;

    Swift

    func insertTab(with url: URL, at index: UInt, selected: Bool) throws

    Parameters

    url

    The URL to add to the tab bar.

    index

    The index in the tab bar at which to insert the URL. This value must not be greater than the number of tabs in the tab bar.

    selected

    Whether to selected the tab after it has been inserted.

    error

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    YES if the URL could be inserted into the tab bar. Returns NO if an error occurred.

  • Removes the first occurence of the given URL in the tab bar.

    Declaration

    Objective-C

    - (void)removeTabWithURL:(nonnull NSURL *)url;

    Swift

    func removeTab(with url: URL)

    Parameters

    url

    The URL to remove from the tab bar.

  • Removes the tab at the given index.

    Declaration

    Objective-C

    - (void)removeTabAtIndex:(NSUInteger)index;

    Swift

    func removeTab(at index: UInt)

    Parameters

    index

    The index from which to remove the tab in the tab bar.

  • The URL associated with the currently selected tab.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) NSURL *selectedURL;

    Swift

    weak var selectedURL: NSURL? { get set }
  • The index of the tab URL associated with the currently selected tab.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger selectedIndex;

    Swift

    var selectedIndex: UInt { get set }
  • The currently selected PTDocumentViewController.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable)
        PTDocumentViewController *selectedViewController;

    Swift

    var selectedViewController: PTDocumentViewController? { get }
  • A Boolean value that indicates whether the tab bar is hidden.

    If YES, the tab bar is hidden. The default value is NO if the tabsEnabled property is enabled. Setting this property changes the visibility of the tab bar without animating the changes. If you want to animate the change, use the -setTabBarHidden:animated: method instead.

    Declaration

    Objective-C

    @property (getter=isTabBarHidden, assign, readwrite, nonatomic)
        BOOL tabBarHidden;

    Swift

    var isTabBarHidden: Bool { get set }
  • Sets whether the tab bar is hidden.

    For animated transitions, the duration of the animation is specified by the value in the UINavigationControllerHideShowBarDuration constant.

    Declaration

    Objective-C

    - (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated;

    Swift

    func setTabBarHidden(_ hidden: Bool, animated: Bool)

    Parameters

    hidden

    Specify YES to hide the tab bar or NO to show it

    animated

    Specify YES if you want to animate the change in visibility or NO if you want the tab bar to appear immediately.