سؤال

مرحبًا ، لدي هذه القطعة من الكود ...

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

و

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

  if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){
    // WTF, this runs when I change to Landscape
  } else {
    // this runs when I change to Portrait??? shouldn't it be the contrary?
  }
}

كما ترى ، يتم تشغيل الرمز في الاتجاه المعاكس ، وأعني ، الجزء الذي يجب تشغيله عندما أقوم بتغيير الجهاز إلى صورة ، وجزء المشهد من الكود والعكس بالعكس.

عندما أقلب الجهاز ، تدور Self.view.

هل اختبار uiinterfaceorientationisportrait هذا كيف تكون الواجهة قبل الدوران أم أنني أفتقد شيئًا؟

شكرا على اي مساعدة.

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

المحلول

لاحظ أن الطريقة تدعى didrotateمنالواجهة ، لذلك بطبيعة الحال interfaceOrientation المعلمة تحتوي على الاتجاه القديم ، وليس الجديد.

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