سؤال

أنا أعمل التطبيق في الدعوة presentModalViewController وبمجرد الانتهاء(الدعوة dismissModalViewControllerAnimated:YES) يجب الاتصال فورا popToRootViewControllerAnimated.

ولكن القضية dismissModalViewControllerAnimated:YES هو يعمل بشكل صحيح ولكن popToRootViewControllerAnimatedلا يعمل بعد ذلك.

رمز هو مبين أدناه:

[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self.navigationController popToRootViewControllerAnimated:YES];
هل كانت مفيدة؟

المحلول

جرب شيئًا كهذا:

[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self performSelector:@selector(patchSelector) withObject:nil afterDelay:0.3];


-(void)patchSelector{
  [self.navigationController popToRootViewControllerAnimated:YES]; 
}

إنه ليس أنيقًا ولكنه يجب أن يعمل.

تحديث:يجب أن تستخدم

 [self dismissModalViewControllerAnimated:YES];

في حين أن

 [self.navigationController dismissModalViewControllerAnimated:YES] ;

الكائن الذي يقدم الوسيط هو وحدة تحكم العرض ، وليس وحدة تحكم التنقل.

نصائح أخرى

إذا كان لديك وحدة تحكم التنقل مع مجموعة من UiviewControllers:

[self dismissModalViewControllerAnimated:YES];
[(UINavigationController*)self.parentViewController popToRootViewControllerAnimated:YES];
//UIViewController *vc = [[UIViewController new] autorelease];
//[(UINavigationController*)self.parentViewController pushViewController:vc animated:YES];

يفترض ، أن وحدة التحكم في العرض والتي تسمى وحدة تحكم العرض Modal لديها NavigationController.

أعتقد أنك لا تتصل

[self.navigationController popToRootViewControllerAnimated:YES];

في المستهدف Modal ViewController. تحقق من ذلك.

ركضت إلى شيء مماثل لهذا.تحتاج إلى تقديم نسخة من الذاتية الخاصة بك.navigationcontroller الأولى و أيضا الإبقاء على نفسك ، حتى عند استدعاء الثانية البوب, لا يزال هناك إشارة إلى NC و أنت لا تزال موجودة.

    // locally store the navigation controller since
    // self.navigationController will be nil once we are popped
UINavigationController *navController = self.navigationController;

    // retain ourselves so that the controller will still exist once it's popped off
[[self retain] autorelease];

    // Pop this controller and replace with another
[navController popViewControllerAnimated:NO];
[navController pushViewController:someViewController animated:NO];

انظر : كيف يمكنني البوب عرض من UINavigationController مكان آخر في العملية ؟

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