Limits of Ti.UI.createWindow Modal Property Across iOS and Android
0 reputation · 02 Mar 2024, 09:35 UTC
0 reputation · 02 Mar 2024, 09:35 UTC
The Ti.UI.createWindow API is the primary declarative entry point for creating native window objects in Appcelerator Titanium. While the API promises a unified lifecycle across iOS and Android, certain properties such as modal and fullscreen have historically exhibited platform‑specific differences.
modal:true typically presents a full‑screen modal view controller.modal:true setting consistently produce a full‑screen modal on Android, or does it default to a dialog‑style presentation in newer SDKs?35275 reputation · 02 Mar 2024, 10:40 UTC
The modal property in Ti.UI.createWindow does not behave consistently across platforms. While Titanium attempts to provide a unified declarative API, the underlying implementation relies on native windowing and activity models that differ fundamentally between iOS and Android.
On iOS, setting modal:true maps directly to the native view controller's modal presentation. This presents a window that blocks interaction with the previous view until it is dismissed. This aligns with standard iOS expectations for modal interfaces.
On Android, the modal flag is largely ignored by the Titanium framework. The window is launched as a standard Activity. Because Android does not have a native 'modal window' concept in the same way iOS does, the window does not block the previous activity unless custom theme logic is implemented.
modal flag. It will remain a full-screen activity regardless of the modal setting.To achieve a consistent modal experience across both platforms, do not rely solely on the modal property. Instead, follow these steps:
Ti.platform to handle window creation.modal:true flag.styles.xml.Note: If you are experiencing specific crashes during rapid window creation, please confirm if you are nulling window references after calling close().
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 02 Mar 2024, 14:10 UTC
To build on the discussion regarding platform divergence, it is critical to note a strict lifecycle constraint: the modal property must be defined before calling win.open().
In Titanium, the modal state is determined during the native window instantiation process. Attempting to toggle win.modal = false or true after the window is already visible will have no effect on the native presentation style, and the SDK will typically trigger a console warning stating that the property cannot be modified post-open.
If you are experiencing inconsistent blocking behavior on Android, verify your SDK version. While newer versions have improved alignment with iOS, you can confirm the native implementation using the Android Studio Layout Inspector to see if the window is being treated as a standard Activity or a dialog-themed window.