شريط التبويب في سبليت عرض وحدة تحكم الجذر - كيفية الاتصال عرض التفاصيل؟

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

  •  15-11-2019
  •  | 
  •  

سؤال

العمل على أول مشروع iPad الخاص بي وبعد العديد من البداية الخاطئة لدي واجهة أساسية أنا سعيد بتلك التي تتألف من وحدة تحكم عرض تقسيم مع شريط علامة تبويب 4-Tab في الجزء السفلي من الجذر / Popover.

لدي 4 وحدات تحكم عرض مختلفة لكل علامة تبويب 4. ثلاثة من هذه تحتوي على جداول، الرابع يحتوي على الإحضارات المتزلجين ومفاتيح. كل هذا يعمل بشكل جيد في صورة أو مناظر طبيعية.

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

لم أجد أي أمثلة أخرى على أشرطة التبويب تستخدم مثل هذا، ولكن يبدو أن الحل الأمثل للتطبيق الخاص بي.

كيف أقوم بتأسيس اتصال بحيث عند تحديد خلية جدول، يتم عرض معلومات Detailitem في عرض التفاصيل؟ تمت إضافة شريط التبويب إلى عرض الجذر في IB. يجب أن أضيفها برمجيا بدلا من ذلك؟

هل لدى أي شخص مشروع مثال حيث حصلت على هذا العمل؟

شكرا!

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

المحلول

Don't get too caught up in the 'tabbar' piece of this. Consider how a simpler app would work: if you select a cell in the RootViewController, how would you notify the DetailViewController?

It won't be automatic. Most likely, you will have a dedicated connection from the RootViewController to the DetailViewController - and you will invoke some method on the DetailViewController from the RootViewController in something like the

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

method in the RootViewController. Indeed, this is how the template UISplitView iPad app is setup. There is an IBOutlet connection from the RootViewController to the DetailViewController.

As long as you manage the memory correctly (retain, release) - there should be no problem if each of your (root) view controllers (in the tab view) have a connection to the single DetailViewController. To keep the tab'd controllers from stepping on each other, you may wish to centralize the logic into a 'middleman' class. Maybe you want to clean something up just before ViewControllerB sorts the details that ViewControllerA just sorted ...

That part is up to you. Just note that there is no backend black magic going on such that a DetailViewController is automatically updated to show something based on a cell selected in any RootViewController.

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