I created a widget in Dashcode. It has some buttons, text fields and texts. It works fine when run from Dashcode or when installed into the Dashboard. When I install it into an iBook (via iBooks Author) and run it on the iPad then the buttons and texts all disappear (as well as a few other minor visual changes). Interestingly if I tap where some of buttons are, it invokes the button click event, but others don't work. Also, when a button click event updates the value of a text then that text becomes visible.
I tried both GlassButtons and regular Buttons, neither shows up. I inspected the properties of the buttons that work vs those that don't and they seem to be the same (beyond id and value).
Here is a screenshot of it running on the Mac:
Here is a screenshot of it running in iBooks on my iPad:
Notice the 8 where a text's value was updated. The connect and update buttons work when you tap in the right spot, but none of the others work.
As a side note, this widget is connecting to a web service over the network using RemObjects SDK for JavaScript, which is really cool. The web service works, if I can just get the buttons to show up.
Update: I replaced the <div>
tag which Dashcode uses for a button with an actual HTML <input type="button">
and that shows up in the iBook. Text still doesn't show up. It is also a <div>
.
I figured it out. When saving the widget it needs to be saved with a minimum Mac OS X version of 10.4.0 which is considered "Backwards-compatible". The default (at least on my install) was 10.4.3. The difference is that when it is saved backwards-compatible then the libraries are included that render the buttons and the text. Why it needs special libraries to render text is beyond me.
One note though is the text position gets messed up a bit when it runs in iBooks. I don't think Apple finished iBooks Author and iBooks 2 before they released it.
来源:https://stackoverflow.com/questions/9013907/why-are-some-widget-elements-not-showing-up-when-embedded-in-ibook