Как сделать детальный вид из списка свойств? - PullRequest
0 голосов
/ 17 августа 2011

Я создал список свойств с логическим путем, подобным этому:

    <array>
    <dict>
        <key>Title</key>
        <string>Construction</string>
        <key>Children</key>
        <array>
            <dict>
                <key>Title</key>
                <string>Advisory Services</string>
            </dict>
            <dict>
                <key>Title</key>
                <string>Disputes Services</string>
                <key>Details</key>
                <dict>
                    <key>Title</key>
                    <string>Disputes Services</string>
                    <key>Associated Image</key>
                    <string>Construction_iPhone.png</string>
                    <key>Industry Info</key>
                    <string>Planning and executing a construction project is a complex process that can be thrown off course by a variety of factors.  Many root causes of delivery overrun are seeded during project development and procurement. Through our extensive construction dispute experience, we have discerned patterns of cost and schedule overruns and project failures that repeat themselves among projects. We leverage this insight to help owners, contractors, providers of capital and counsel identify and proactively manage potential problems throughout the lifecycle of large construction projects.   We also help to manage the risks associated with any claims arising in those projects, particularly those in the infrastructure, healthcare and energy industries.</string>
                </dict>
            </dict>
        </array>

Я создал детализированное приложение, которое по сути сводит вас к списку строк. Я хочу настроить свой контроллер детального просмотра сейчас, поэтому я создал несколько переменных, чтобы начать работу.

//DetailViewController.h

IBOutlet NSString *title;
IBOutlet UIImage *associatedImage;
IBOutlet NSString *IndustryInfo;

Я перетащил изображение и два поля текста в конструктор интерфейсов. Связал их соответственно. Это просто изображение вверху страницы, а затем два поля текста, ничего сложного.

Очевидно, я бы хотел настроить его так, чтобы он просто использовал список свойств для получения этой информации. Проблема в том, что я новичок в разработке для iOS. Как бы я настроить метод, используя objectForKey в моей реализации, чтобы проанализировать информацию, которую я хочу, и отобразить ее на экране? Кроме того, как мне настроить UIImage, учитывая тот факт, что я настроил его как строку в моем .plist? Спасибо!

1 Ответ

0 голосов
/ 17 августа 2011

Вы можете прочитать файл plist с помощью NSPropertyListSerialization или [NSArray arrayWithContentsOfFile:...] или [NSDictionary dictionaryWithContentsOfFile:...] в зависимости от вашего списка. Я не уверен, как у вас настроено изображение, но вы можете загрузить его с [UIImage imageNamed:...] или [UIImage imageWithContentsOfFile:...].

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...