From this, you will see the addBlcok functions can only be used in a "Text Document" part, not a "Text" part.

The AddBlock function doesn't allow to set the height and width of a block, all you provide is the "approximate" position of where you want the top-left corner of your block to be, and the iink will try to put the block where it can. If there is not enough place, it will not add the block and will raise an IllegalStateException exception.

From this, you will see the addBlcok functions can only be used in a "Text Document" part, not a "Text" part.

The AddBlock function doesn't allow to set the height and width of a block, all you provide is the "approximate" position of where you want the top-left corner of your block to be, and the iink will try to put the block where it can. If there is not enough place, it will not add the block and will raise an IllegalStateException exception.

James Sumners

said
about 1 month ago

I looked at the example you gave me and add the below code based on the link you just gave me. The result if "-[IINKEditor addBlock:type:error:]::416 invalid text data (cannot create text block with empty data)"

If I do the statement I did before where I give the text I want to input it gives the same error as before. When I have time I will go back to your example swift code and dod the same thing and see if it actually works.

James Sumners

said
about 1 month ago

The difference between the example you pointed me to and what I want to do is that I want to import some initial text. I don’t want to add text after some existing block. Is there some way to define an independent text block and then save that to the root block?

J

James Sumners

said
about 1 month ago

Went back and tried this on the example GetStartedSwift addBlock after creating the part, just like in my code, will actually work. So I copied the storyboard from the example and the HomeViewContriller.swift file to my project and used a UIViewControllerRepresentable to connect it to the swiftui code. Got it working in only a few minutes. When I clean it up I will post it.