iOS Tools V 6.2

The way tool library callbacks work has changed for better transparency and customization. Updating existing code to work with the new PDFViewCtrl should only take a couple of minutes and is described here.

Previously, PDFViewCtrl had a tool property that would be sent events and would be destroyed and replaced by new tools by the control when required. The new system moves the tools destruction/creation logic outside of the control so that it can be accessed and modified by users of the SDK. In 6.2.0, instead of directly setting a tool on the PDFViewCtrl, a “ToolManager” is registered to receive events, and it is the ToolManager’s job to then pass these events to the actual tools as well as destroy and create new tools when necessary.

So before the first tool would have been registered as so:

// assign the initial tool as a PanTool
 [myPDFViewCtrl setTool:[[PanTool alloc] initWithPDFViewCtrl:myPDFViewCtrl];

This is now done as so:

// create a tool manager
_toolManager = [[ToolManager alloc] initWithPDFViewCtrl:myPDFViewCtrl];

// set the initial tool to be a pan tool
[_toolManager changeTool:[PanTool class]];

// set the tool manager to receive the events from the PDFViewCtrl
myPDFViewCtrl.toolDelegate = _toolManager;

Subsequent changes to the active tool can be made within the app like this:

[_toolManager changeTool:[ADifferentTool class]];
or
[_toolManager setTool:[[ADifferentTool alloc] initWithPDFViewCtrl:myPDFViewCtrl]];

The source code for the new (default) ToolManager can be found in the Tools project, located at Lib/src/PDFViewCtrlTools/Tools/ToolManager.m.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s