title: Nativescript iOS delegate listView (lazy loading ?)
body: <p>I would like to use the onScroll event on a listview in nativescript but the event does not exist. So I go through the native, so I would like to create a delegate for my listview. Everything works but I do not know why, I have to make a console.log my delegate to use it, otherwise it does not run. Do you have an idea of ​​the reason?</p>
  
  <pre><code>export class ItemsComponent implements OnInit, AfterViewInit {
     items: Array&lt;Item&gt;;
  
     @ViewChild('header') header: ElementRef;
     @ViewChild('listView') listView: ElementRef;
  
     // This pattern makes use of Angular’s dependency injection implementation to
     // inject an instance of the ItemService service into this class.
     // Angular knows about this service because it is included in your app’s main NgModule,
     // defined in app.module.ts.
     constructor(private itemService: ItemService, private zone: NgZone) { }
  
     ngOnInit(): void {
         this.items = this.itemService.getItems();
     }
  
     ngAfterViewInit() {
         setTimeout(() =&gt; {
            if (isIOS) {
                 let newDelegate = newUITableViewDelegateImpl.initWithOriginalDelegate(this.listView.nativeElement._delegate);
                 this.listView.nativeElement.ios.delegate = newDelegate;
                 console.log(this.listView.nativeElement.ios.delegate);
             }
         }, 50)
  
     }
  }
  
  
  class newUITableViewDelegateImpl extends NSObject implements UITableViewDelegate {
      public static ObjCProtocols = [UITableViewDelegate];
  
      private _originalDelegate: UITableViewDelegate;
  
      public static initWithOriginalDelegate(originalDelegate: UITableViewDelegate): newUITableViewDelegateImpl {
          console.log("initWithOwner")
  
          let delegate = &lt;newUITableViewDelegateImpl&gt;newUITableViewDelegateImpl.new();
          delegate._originalDelegate = originalDelegate;
  
          return delegate;
      }
  
      public scrollViewWillBeginDragging(scrollView: UIScrollView) {
          console.log("scrollViewWillBeginDragging");
      }
      public scrollViewDidScroll(scrollView: UIScrollView) {
          console.log("scrollViewDidScroll");
  
      }
  }
  </code></pre>