简体   繁体   中英

back button with jasonett/iOS

I am trying to create a back button that when the user clicks on it, it will take them to the previous page.

I found this code of a medium post by the author of Jasonett but it doesn't work for me. It creates the label but I can't click on it

 "layers": [{ "type": "label", "text": "👈", "style": { "top": "10", "right": "10", "width": "100", "height": "100" }, "action": { "type": "$back" } }] 

Source: The documentation

The element label is clickable or you can attach an action on a label only if it is at the item level.

So, for example, the following code will accept touch and the action set there would work fine.

{
  "items": [{
    "type": "label",
    "text": "Submit",
    "action": { SOME_ACTION } 
  }]
}

Where as the following won't accept a click.

{
  "items": [{
    "type": "vertical",
    "components": [{
      "type": "label",
      "text": "touch me",
      "action": { ... } 
    }]
  }]
}

In your example, label is defined inside layers. Thus it is not accepting a click.

Basically you have two options here.

  1. Implement a click handler in JasonLabelComponent.m so regardless of their position labels always respond to action if it is provided in JSON.
  2. Take the label out and make it a button, which by default would have action enabled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM