Я пишу приложение «Библейская память» для IPhone, и мне нужна помощь с выбором стихов, отображаемых в UIWebView.
У меня есть XML-файл, который читается в UIWebView, и мне нужно иметь возможность определить, когда пользователь нажимает на определенный стих.Вот пример XML-файла:
<bible translation="KJV">
<testament name="Old">
<book name="Genesis">
<chapter number="1">
<verse number="1">In the beginning God created the heaven and the earth.</verse>
<verse number="2">And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.</verse>
<verse number="3">And God said, Let there be light: and there was light.</verse>
<verse number="4">And God saw the light, that it was good: and God divided the light from the darkness.</verse>
<verse number="5">And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.</verse>
По отношению к коду выше, если пользователь нажимает «В начале ...», программа должна знать (по крайней мере), что пользователь только что нажалэлемент «стих» и его «число = 1».
=================== РЕДАКТИРОВАНИЕ ==========================
Вот мое предложенное решение .. type..thingy.Дайте мне знать, как это звучит.
У меня все еще есть UIWebView, читающий файл XML.Это также форматируется мой файл CSS в комплекте.Поскольку UIWebViews принимают к сведению ссылки (hrefs) [спасибо Джонатану], я могу добавить номера стихов перед каждым помеченным стихом (я знаю, это немного утомительно, но я все равно планировал это сделать:)
Таким образомXML-файл будет выглядеть следующим образом:
<bible translation="KJV">
<testament name="Old">
<book name="Genesis">
<chapter number="1">
<n>1</n><verse number="1">In the beginning God created the heaven and the earth.</verse>
<n>2</n><verse number="2">And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.</verse>
<n>3</n><verse number="3">And God said, Let there be light: and there was light.</verse>
<n>4</n><verse number="4">And God saw the light, that it was good: and God divided the light from the darkness.</verse>
<n>5</n><verse number="5">And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.</verse>
<n>6</n><verse number="6">And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.</verse>
<n>7</n><verse number="7">And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.</verse>
Я либо использую css для принудительного использования тега 'n' в качестве ссылки, либо просто помещаю вместо него элементы 'href'.Таким образом, при нажатии номера стиха, который будет показан перед стихом, я могу запустить собственный метод, чтобы выяснить, где я нахожусь (в каком стихе я нахожусь).Вот пост, который я нашел о том, как перехватывать ссылки в UIWebView: http://dblog.com.au/iphone-development/iphone-sdk-tip-firing-custom-events-when-a-link-is-clicked-in-a-uiwebview/
Я надеюсь, что это сработает, немного рекламно ... но программы часто начинаются именно так.Кто-нибудь пробовал что-то подобное раньше?
Дон