2014-11-13 2 views
0

내 Xamarin 프로젝트에 대한 광고 SDK 바인딩이 있습니다. 바인딩은 여기에 있습니다 : https://github.com/bbhsu2/XamarinAdMarvelBinding 내 문제는 방법에서 오는Xamarin Binding에서 UIKit 메서드 호출

:

내 수업 시간에
[Export("adMarvelViewFrame")] 
RectangleF AdMarvelViewFrame(); 

내가 같은 그것을 구현 : 그러나

[Export("adMarvelViewFrame")] 
public RectangleF AdMarvelViewFrame() 
{ 
    return new RectangleF(0.0f, 0.0f, UIScreen.MainScreen.Bounds.Width, 250.0f); 
} 

,보기로드, 난을 얻을 때 오류 :

UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread. 

나는이 오류의 의미를 이해하지만 어떻게 호출합니까? 네이티브 코드로 다른 곳에서 호출 될 때 메인 쓰레드에서?

답변

2

호출중인 UIKIt 메서드는 UIScreen.MainScreen입니다.

쉽게 해결할 수있는 방법은 클래스 변수에서 UIScreen.MainScreen을 프리 페치하고 AdMarvelViewFrame에서 클래스 변수를 사용하는 것입니다.

관련 문제