2013-04-14 3 views
1

У меня есть контроллер просмотра в моем приложении, который хочет всегда показывать в режиме prtaint. Объекты этого экрана добавляются во время выполнения и основаны на режиме доступа. Это мой первый диспетчер представлений.Заставляю viewcontroller быть портрет monotouch iphone

я попробовал некоторые коды, такие как:

first

second

Third

, но ни один из них не couldent помочь мне. может знать любое другое решение для этого состояния?

я нашел некоторые вещи там:

Monotouch - View created in landscape orientation is displayed in portrait orientation

, но я не знаю, как использовать это. может ли любой орган помочь?

я использовать эти коды

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) 
     { 
      // Return true for supported orientations 
      if (UserInterfaceIdiomIsPhone) { 
       return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown ); 
      } else { 
       return true; 
      } 

     } 


     public override bool ShouldAutorotate() 
     { 
      return true ; 
     } 
     public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation() 
     { 
      return UIInterfaceOrientation.Portrait ; 
     } 

    public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations() 
     { 
      return UIInterfaceOrientationMask.Portrait ; 
     } 

, но ни один из них не работает. ..

функция autoroatate никогда не вызывает :(

+0

У вас есть несколько Ориентаций в разных взглядах? В "Поддерживаемых ориентациях интерфейса" у вас есть все четыре галочки? И только в том, что вы запускаете во время выполнения, что хотите всегда быть в портрете, является ли это правильным предположением? –

+0

Да, контроллер просмотра - мой первый контроллер представления в моем приложении, который я хочу быть портрет, а также в поддерживаемых интерфейсах. У меня есть 3 из четырех. –

ответ

1

Может быть, вы используете Навигационный контроллер в вас приложении закончили режим завтракал Если правильно, то вы должны переопределить контроллер UINavigation и добавить Yous собственного механизма rotaion на это смотрите этот код:

public class RltNavigationController : UINavigationController 
{ 
    public RltNavigationController() : base() 
    { 
    } 

    public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations() 
    { 
     if(this.TopViewController is HomeScreen) 
      return UIInterfaceOrientationMask.Portrait ; 
     else 
      return UIInterfaceOrientationMask.AllButUpsideDown ; 

    } 

    public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) 
    { 
     // Return true for supported orientations 
     if(this.TopViewController is HomeScreen) 
      return (toInterfaceOrientation == UIInterfaceOrientation.Portrait); 
     else 
      return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown) ; 

    } 
} 
+0

ShouldAutotrotateToInterfaceOrientation лишается iOS6. – cdbitesky

+0

ShouldAutorotateToInterfaceOrientation предназначен для устройств ios 5 и GetSupportedInterfaceOrientations для ios 6 и upper. оба метода были отменены –

Смежные вопросы