SCSArticleViewController

@interface SCSArticleViewController : UIViewController

View controller capable of displaying the contents of an article. When used in conjunction with a navigation controller, the title property of the view will automatically be set to the title of the article, or nil if no article is assigned.

Article content is automatically rendered into content capable of being displayed within this view controller. The articles data is laid out as HTML and rendered within a WKWebView instance.

HTML content is rendered using a structure like the following:

<html>
 <head>
   <meta name="viewport" content="initial-scale=1"/>
   <link rel="stylesheet" href="/style.css" type="text/css" media="all"/>
   <link rel="stylesheet" href="/article/{{article.id}}/style.css" type="text/css" media="all"/>
 </head>
 <body>
   <header>
     {{article.title}}
   </header>
   <main>
     <field name="{{field.name}}" type="{{field.type}}">
       <field-title>{{field.title}}</field-title>
       <field-value>{{field.value}}</field-value>
     </field>
     ...
   </main>
   <script src="/script.js"></script>
   <script src="/article/{{article.id}}/script.js"></script>
 </body>

Smart link tags (anchors referencing other articles within Salesforce) will be decorated with a smart-link CSS class, which can be used to style those links differently as needed.

Each article field is separated into its own block which can be independently formatted, hidden, or otherwise styled using custom CSS. The default global CSS is automatically populated based on the fonts and colors defined in SCAppearanceConfiguration. Furthermore, if any custom styles need to be changed, SCAppearanceConfiguration.globalArticleCSS property can be used to add default syles that are applied to all articles. Likewise, the SCAppearanceConfiguration.globalArticleJavascript property can be used to supply common javascript to be injected to all articles when they’re loaded.

The -[SCSArticleViewControllerDelegate articleController:additionalCSSForArticle:] and -[SCSArticleViewControllerDelegate articleController:additionalJavascriptForArticle:] delegate methods can be used to provide more granular per-article control over both CSS and javascript.

  • The category information to use when displaying empty content. If nil is assigned, the value will automatically reset to the root data category.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, null_resettable) SCSCategory *category;

    Swift

    var category: SCSCategory! { get set }
  • The article to display. If the article is not yet cached, its content will automatically be downloaded on-demand when the view is loaded. If nil is assigned, an empty view will automatically be shown to display information about the data category.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) SCSArticle *article;

    Swift

    @NSCopying var article: SCSArticle? { get set }
  • Delegate property to use to interact with the article view controller.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable)
        NSObject<SCSArticleViewControllerDelegate> *delegate;