دوران iPad ، أي طريقة لتحميل طريقة العرض المخصصة على أساس الاتجاه؟

StackOverflow https://stackoverflow.com/questions/3125768

سؤال

أنا أكتب تطبيقًا أود عرض طرق عرض مختلفة بناءً على الاتجاه. على سبيل المثال ، إذا كان الجهاز هو Portrait Load PVIOW ، إذا كان LVIEW تحميل المناظر الطبيعية. فيما يلي رمز IVE حاليًا.

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation duration:(NSTimeInterval)duration {
 if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
      self.view = portrait;
}
 else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
      self.view = portrait;
 }
 else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
      self.view = portrait;
 }
 else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
      self.view = landscape;
 }

}

مع هذا ، قمت بإنشاء عرضين في IB وتوصيل المنافذ بالعرض الصحيح. لقد حاولت هذا أيضًا:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation duration:(NSTimeInterval)duration {
 if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
      self.view = portrait;
}
 else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
      self.view = portrait;
 }
 else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
      lView *abo = [[lView alloc] initWithNibName:@"lView" bundle:nil];
      [self.navigationController pushViewController:abo animated:NO];
      [abo release];

 }
 else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
      lView *abo = [[lView alloc] initWithNibName:@"lView" bundle:nil];
      [self.navigationController pushViewController:abo animated:NO];
      [abo release];

 }

}

تم عمل الكود أعلاه مباشرة مع iPod ولكن ليس iPad. أيه أفكار؟

هل كانت مفيدة؟

المحلول

لقد وجدت مشاريع عينة 2 (Apple) التالية مفيدة:

http://developer.apple.com/library/ios/#samplecode/alternateviews/introduction/intro.html

http://developer.apple.com/library/ios/#samplecode/whichwayisup/introduction/intro.html

تذكر أيضًا من منظور الجهاز أن هناك أيضًا اتجاهات وجهاً لوجه. هذا قبض علي.

نصائح أخرى

يجب أن أطرح السؤال الواضح:

هل لديك مفتاح قفل اتجاه الشاشة قيد التشغيل لجهاز iPad الخاص بك؟

اعتمادًا على ما تحاول القيام به ، يمكنك إعداد الواجهة الخاصة بك في IB للتعامل مع التناوب تلقائيًا. يمكنك تغيير حجم المكونات ، ونقل الصور والعلامات حولها ، أشياء من هذا القبيل. قد تفعل ما تريد القيام به ...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top