好了,修好了,我的錯,我猜。
看起來Keyboard和UIViewController分別調用supportedInterfaceOrientations
並根據其返回值進行旋轉。我在那裏有一個if-else
聲明,並且僅在某些情況下才返回AllButUpsideDown
。當鍵盤檢查是否應該旋轉方法返回Portrait
,並且viewcontroller
值爲AllButUpsideDown
。
所以我改變了這一點:
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
if (someStatement)
{
return UIInterfaceOrientationMask.AllButUpsideDown;
}
return UIInterfaceOrientationMask.Portrait;
}
要這樣:
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
return UIInterfaceOrientationMask.AllButUpsideDown;
}
現在只ShouldAutoRotate
決定是否轉動應該發生與否。
要一些了,應該是這樣的:
public override bool ShouldAutorotate()
{
if (someStatement)
{
return true;
}
return false;
}
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
return UIInterfaceOrientationMask.AllButUpsideDown;
}
你可以顯示你處理你的方向的代碼嗎,如果使用IB創建的話,可能會顯示一些截圖嗎? – IamNguele
@IamNguele我可以,但代碼是在Xamarin。如果沒有絕對的必要性,我通常會避免將Xamarin代碼放在我希望本機開發人員回答的問題中。不幸的是,他們不太可能會回答。 :( – arsena
http://stackoverflow.com/questions/40318488/uialertcontroller-addtextfield-orientation-issue-from-ios10-on-ipad#comment68002435_40318488 - 可能是這可以幫助 - 閱讀評論 –