3

When I create a MSStickerBrowserViewController subclass by embedding it in a container view (using a storyboard) as the documentation suggests, I appear to have no opportunity to set the stickerSize. The Sticker Browser VC is initialized with init(coder:), and I have no way that I can see to override the get-only property stickerSize. I can only get stickerSize = MSStickerSize.regular.

I don't see any control in interface builder to configure the property either, though the documentation says "You can also customize the size of the stickers inside the browser."

Thanks to shallowThought, I see that an initializer is available init(stickerSize: MSStickerSize) on MSStickerBrowserViewController, but so far I have been unable to find a way to trigger that initializer when using a storyboard and overriding the required init(coder:) initializer.

Am i missing something?

Thanks!

shallowThought
  • 19,212
  • 9
  • 65
  • 112
Jeff
  • 51
  • 4
  • Post the the code you have tried to make others see and better understand what your issue is in regards to the initializers. – shallowThought Dec 17 '16 at 14:57

2 Answers2

5

This worked for me: I added stickerSize to the "User Defined Runtime Attributes" section of the Identity Inspector.

In this example, PetStickerBrowserViewController is a subclass of MSBrowserStickerViewController. stickerSize is set to 0, which corresponds to MSStickerSize.small.

At runtime, when the view controller is instantiated from the storyboard, its stickerSize property is set to .small. Use 1 for .regular (the default), and 2 for .large.

enter image description here

bunnyhero
  • 757
  • 2
  • 10
  • 23
1

You can set it when initializing.

From Apples documentation.

StickerBroweserView

init(frame: CGRect, stickerSize: MSStickerSize)

Creates a new sticker browser containing stickers of the specified size.

StickerBroweserViewController

init(stickerSize: MSStickerSize)

Creates a new sticker browser view controller with stickers of the provided size.

To subclass it, implement the corresponding initializers.

I can not see a way to call init(stickerSize: MSStickerSize) by somehow chaining init calls from required init?(coder aDecoder: NSCoder), so you might have to instantiate the viewControllers programmatically.

shallowThought
  • 19,212
  • 9
  • 65
  • 112
  • Welcome. On SO we thank by upvoting / accepting answers. – shallowThought Dec 16 '16 at 20:12
  • One thing: When I instantiate from a storyboard init(coder:) is used, so I am not able to call init(stickerSize:). If I override init(stickerSize:) in my MSStickerBrowserViewController subclass, and set a breakpoint I see that that initializer never runs. Any thoughts? I may have to set it up programmatically rather than using the storyboard to avoid triggering init(coder:)? – Jeff Dec 16 '16 at 20:14
  • Hi I did just upvote, but SO informed me that the upvote will not show publicly until I gain more rep on SO :-) And still looking for how to trigger init(stickerSize:) while using storyboard, so I haven't marked accepted just yet. Really do appreciate it! – Jeff Dec 16 '16 at 20:17
  • All good :-). Regarding init(coder:: That is a good question. I am afraid you have to set it up programmatically, but I am not sure right now if it is possible to create a initializer chain from `required` ` init(coder:` up to `super.init(stickerSize:`. I can not try in the moment. Append this to your question, maybe someone else helps you faster. – shallowThought Dec 16 '16 at 20:22