Skip to content

Not returning a view on the view parameter of the creatingView event handler of the placeholder crash the application #343

Closed

Description

@AlexandreRoba

How to reproduce:
Create an xml page with the following nested elements:
Page
StackLayout
Placehodler

Add an event handler to the creatingView placeholder event named creatingImageView such as:
function creatingImageView(args) {
console.log("Creating View called");
}
exports.creatingImageView = creatingImageView;

Run the application it will crash with the following error:
/app/tns_modules/ui/core/view.js:85:116: JS ERROR Error: onMeasure() did not set the measured dimension by calling setMeasuredDimension()

replace the event handler with the following code and the application will start
function creatingImageView(args) {
console.log("Creating View called");
var nativeView = new UILabel();
nativeView.text = "Native";
args.view = nativeView;
}
exports.creatingImageView = creatingImageView;

Activity

  1. hamorphis commented on Jun 25, 2015

    @hamorphis
    Contributor

    Why would one use a placeholder if he does not intend to hold anything in this place?

  2. AlexandreRoba commented on Jun 25, 2015

    @AlexandreRoba
    Author

    You could have it visible and filled on ios and not in android...

  3. hamorphis commented on Jun 25, 2015

    @hamorphis
    Contributor

    I am not sure that I understand why would I want to use a placeholder, if I don't want to supply a view to show. What will show there if there is not view supplied. What are you trying to achieve? Please, elaborate? Perhaps you should use something else and not a placeholder. For example some layout?

  4. AlexandreRoba commented on Jun 25, 2015

    @AlexandreRoba
    Author

    Thanks for the feedback. you guys are doing an amazing work with Native Script.

    I'm writing a poc application that should run on Ios and Android. I'm sharing the same xml for both application. On this XML I have one place holder.
    At the moment only the android application has a proper implementation that returns a view on the creatingView Eventhandler. the ios does not. It simply returns null. This makes the all ios application crash with the message I mentionned previously :(

    I would expect the placeHolder that has a creatingView event handler that do not return anything to simply not show anything on the screen. Not crash :)

    Think about the stacklayout or the gridlayout... will they make the application crash if there is no other views inside them? Would you say "Why would you put a stack layout on the screen if there is nothing in it?...". ;)

  5. hamorphis commented on Jun 25, 2015

    @hamorphis
    Contributor

    Use one of the Layouts. You can put a layout on the screen with many purposes. For example you might want to paint it red. Or out can add children later on programmatically on a button click for example. Anyway, I will see whether I can catch the exception.

  6. self-assigned this
    on Jun 25, 2015
  7. added this to the 1.2.0 milestone on Jun 30, 2015
  8. added 2 commits that reference this issue on Jun 30, 2015
  9. hamorphis commented on Jun 30, 2015

    @hamorphis
    Contributor

    Fixed!

  10. removed this from the 1.2.0 milestone on Jul 1, 2016
  11. lock commented on Aug 29, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  12. locked and limited conversation to collaborators on Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions