Apple Object-Oriented Programming with Objective-C Guide Manuel Apple sur Fnac.com - Pour voir la liste complète des manuels APPLE, cliquez ici
ou juste avant la balise de fermeture -->
ou juste avant la balise de fermeture -->

 

 

TELECHARGER LE PDF sur :

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/OOP_ObjC/OOP_ObjC.pdf

Commander un produit Apple sur Fnac.com

 

 

Voir également d'autres Guides et documentation APPLE :

Apple-TV_2nd_gen_Setup_Guide.pdf-manuel

Apple-Archives-and-Serializations-Programming-manuel

Apple-SafariWebContent.pdf-Guide-manuel

Apple-iTunes_ExtrasandiTunes_LPTestGuide1.1.pdf-manuel

Apple-Text-System-User-Interface-Layer-Programming-manuel

Apple-CocoaTextArchitecture.pdf-manuel

Apple-Key-Value-Observing-Programming-Guide-manuel

Apple-Location-Awareness-Programming-Guide-manuel

Apple-SharkUserGuide.pdf-manuel

Apple-drawingprintingios.pdf-manuel

Apple-QuickTime7_User_Guide.pdf-manuel

Apple-Event-Handling-Guide-for-iOS-manuel

Apple-ipod_nano_3rd_gen_features_guide.pdf-manuel

Apple-iTunes_VideoandAudio_Asset_Guide5.0.pdf-manuel

Apple-ARD3_AdminGuide.pdf-manuel

Apple-SafariWebContent.pdf-Guide-manue

Apple-iphone_3gs_finger_tips.pdf-manuel

Apple-InstrumentsUserGuide.pdf-manuel

Apple-Logic-Pro-9-TDM-Guide-manuel

Apple-macbook_air_users_guide.pdf-manuel

Apple-macbook_air-13-inch_mid-2012-qs_ta.pdf-manuel

Apple-AppStoreMarketingGuidelines-JP.pdf-Japon-manuel

Apple-macbook_pro_retina_qs_ta.pdf-manuel

Apple-ipad_user_guide_tu.pdf-manuel

Apple-ipad_user_guide_th.pdf-manuel

Apple-iphone_user_guide_gr.pdf-manuel

Apple-Nike_Plus_iPod_Sensor_UG_2A.pdf-manuel

Apple-ipad_manual_del_usuario.pdf-manuel

Apple-ipad_uzivatelska_prirucka.pdf-manuel

Apple-ipad_wifi_informations_importantes.pdf-manuel

Apple-Xsan_2_Admin_Guide_v2.3.pdf-manuel

Apple-macbook_pro-13-inch-late-2012-quick_start.pdf-manuel

Apple-CocoaDrawingGuide.pdf-manuel

Apple-Cryptographic-Services-Guide-manuel

Apple-Resource-Programming-Guide-manuel

AppleSafariVisualEffectsProgGuide.pdf-manuel

/Apple-WorkingWithUSB.pdf-manuel

Apple-macbook_pro-retina-mid-2012-important_product_info_f.pdf-manuel

Apple-iOS_Security_May12.pdf-manue

Apple-Mac-Pro-2008-Performance-and-Productivity-for-Creative-Pros

Apple-iPod_shuffle_4thgen_Manuale_utente.pdf-Italie-Manuel

Apple-KernelProgramming.pdf-manuel

Apple-Core-Data-Model-Versioning-and-Data-Migration-Programming-Guide-manuel

Apple-RED_Workflows_with_Final_Cut_Pro_X.pdf-manuel

Apple-Transitioning-to-ARC-Release-Notes-manuel

Apple-iTunes-Connect-Sales-and-Trends-Guide-manuel

Apple-App-Sandbox-Design-Guide-manuel

Apple-String-Programming-Guide-manuel

Apple-Secure-Coding-Guide-manuel

Apple_AirPort_Networks_Early2009.pdf-manuel

Apple-TimeCapsule_SetupGuide_TA.pdf-manuel

Apple-time_capsule_4th_gen_setup.pdf-manuel

Apple-TimeCapsule_SetupGuide.pdf-manuel

Apple-TimeCapsule_SetupGuide_CH.pdf-Chinois-manuel

Apple-CodeSigningGuide.pdf-manuel

Apple-ViewControllerPGforiOS.pdf-manuel

Apple-KeyValueObserving.pdf-manuel

Apple-mac_mini-late-2012-quick_start.pdf-manuel

Apple-OS-X-Mountain-Lion-Core-Technologies-Overview-June-2012-manuel

Apple-OS-X-Server-Product-Overview-June-2012-manuel

Apple-Apple_Server_Diagnostics_UG_109.pdf-manuel

Apple-PackageMaker_UserGuide.pdf-manuel

Apple-InstrumentsUserGuide.pdf-manuel

Apple-Logic-Pro-9-TDM-Guide-manuel

Apple-macbook_air_users_guide.pdf-manuel

Apple-macbook_air-13-inch_mid-2012-qs_ta.pdf-manuel

Apple-AppStoreMarketingGuidelines-JP.pdf-Japon-manuel

Apple-macbook_pro_retina_qs_ta.pdf-manuel

Apple-ipad_user_guide_tu.pdf-manuel

Apple-ipad_user_guide_th.pdf-manuel

Apple-iphone_user_guide_gr.pdf-manuel

Apple-Nike_Plus_iPod_Sensor_UG_2A.pdf-manuel

Apple-ipad_manual_del_usuario.pdf-manuel

Apple-ipad_uzivatelska_prirucka.pdf-manuel

Apple-ipad_wifi_informations_importantes.pdf-manuel

Apple-Xsan_2_Admin_Guide_v2.3.pdf-manuel

Apple-macbook_pro-13-inch-late-2012-quick_start.pdf-manuel

Apple-CocoaDrawingGuide.pdf-manuel

Apple-Cryptographic-Services-Guide-manuel

Apple-Resource-Programming-Guide-manuel

AppleSafariVisualEffectsProgGuide.pdf-manuel

/Apple-WorkingWithUSB.pdf-manuel

Apple-macbook_pro-retina-mid-2012-important_product_info_f.pdf-manuel

Apple-iOS_Security_May12.pdf-manue

Apple-Mac-Pro-2008-Performance-and-Productivity-for-Creative-Pros

Apple-iPod_shuffle_4thgen_Manuale_utente.pdf-Italie-Manuel

Apple-KernelProgramming.pdf-manuel

Apple-Core-Data-Model-Versioning-and-Data-Migration-Programming-Guide-manuel

Apple-RED_Workflows_with_Final_Cut_Pro_X.pdf-manuel

Apple-Transitioning-to-ARC-Release-Notes-manuel

Apple-iTunes-Connect-Sales-and-Trends-Guide-manuel

Apple-App-Sandbox-Design-Guide-manuel

Apple-String-Programming-Guide-manuel

Apple-Secure-Coding-Guide-manuel

Apple_AirPort_Networks_Early2009.pdf-manuel

Apple-TimeCapsule_SetupGuide_TA.pdf-manuel

Apple-time_capsule_4th_gen_setup.pdf-manuel

Apple-TimeCapsule_SetupGuide.pdf-manuel

Apple-TimeCapsule_SetupGuide_CH.pdf-Chinois-manuel

Apple-CodeSigningGuide.pdf-manuel

Apple-ViewControllerPGforiOS.pdf-manuel

Apple-KeyValueObserving.pdf-manuel

Apple-mac_mini-late-2012-quick_start.pdf-manuel

Apple-OS-X-Mountain-Lion-Core-Technologies-Overview-June-2012-manuel

Apple-OS-X-Server-Product-Overview-June-2012-manuel

Apple-Apple_Server_Diagnostics_UG_109.pdf-manuel

Apple-PackageMaker_UserGuide.pdf-manuel

Apple-Instrumentos_y_efectos_de_Logic_Studio.pdf-Manuel

Apple-ipod_nano_kayttoopas.pdf-Finlande-Manuel

Apple_ProRes_White_Paper_October_2012.pdf-Manuel

Apple-wp_osx_configuration_profiles.pdf-Manuel

Apple-UsingiTunesProducerFreeBooks.pdf-Manuel

Apple-ipad_manual_do_usuario.pdf-Portugais-Manuel

Apple-Instruments_et_effets_Logic_Studio.pdf-Manuel

Apple-ipod_touch_gebruikershandleiding.pdf-Neerlandais-Manuel

AppleiPod_shuffle_4thgen_Manual_del_usuario.pdf-Espagnol-Manuel

Apple-Premiers-contacts-avec-votre-PowerBook-G4-Manuel

Apple_Composite_AV_Cable.pdf-Manuel

Apple-iPod_shuffle_3rdGen_UG_DK.pdf-Danemark-Manuel

Apple-iPod_classic_160GB_Benutzerhandbuch.pdf-Allemand-Manuel

Apple-VoiceOver_GettingStarted-Manuel

Apple-iPod_touch_2.2_Benutzerhandbuch.pdf-Allemand-Manuel

Apple-Apple_TV_Opstillingsvejledning.pdf-Allemand-Manuel

Apple-iPod_shuffle_4thgen_Manuale_utente.pdf-Italie-Manuel

Apple-iphone_prirucka_uzivatela.pdf-Manuel

Apple-Aan-de-slag-Neerlandais-Manuel

Apple-airmac_express-80211n-2nd-gen_setup_guide.pdf-Thailande-Manuel

Apple-ipod_nano_benutzerhandbuch.pdf-Allemand-Manuel

Apple-aperture3.4_101.pdf-Manuel

Apple-Pages09_Anvandarhandbok.pdf-Manuel

Apple-nike_plus_ipod_sensor_ug_la.pdf-Mexique-Manuel

Apple-ResEdit-Reference-For-ResEdit02.1-Manuel

Apple-ipad_guide_de_l_utilisateur.pdf-Manuel

Apple-Compressor-4-Benutzerhandbuch-Allemand-Manuel

Apple-AirPort_Networks_Early2009_DK.pdf-Danemark-Manuel

Apple-MacBook_Pro_Mid2007_2.4_2.2GHz_F.pdf-Manuel

Apple-MacBook_13inch_Mid2010_UG_F.pdf-Manuel

Apple-Xserve-RAID-Presentation-technologique-Janvier-2004-Manuel

Apple-MacBook_Pro_15inch_Mid2010_F.pdf-Manuel

Apple-AirPort_Express-opstillingsvejledning.pdf-Danemark-Manuel

Apple-DEiPod_photo_Benutzerhandbuch_DE0190269.pdf-Allemand-Manuel

Apple-Final-Cut-Pro-X-Logic-Effects-Reference-Manuel

Apple-iPod_touch_2.1_Brugerhandbog.pdf-Danemark-Manuel

Apple-Remote-Desktop-Administratorhandbuch-Version-3.1-Allemand-Manuel

Apple-Qmaster-4-User-Manual-Manuel

Apple-Server_Administration_v10.5.pdf-Manuel

Apple-ipod_classic_features_guide.pdf-Manuel

Apple-Lecteur-Optique-Manuel

Apple-Carte-AirPort-Manuel

Apple-iPhone_Finger_Tips_Guide.pdf-Anglais-Manuel

Apple-Couvercle-Manuel

Apple-battery.cube.pdf-Manuel

Apple-Boitier-de-l-ordinateur-Manuel

Apple-Pile-Interne-Manuel

Apple-atacable.pdf-Manuel

Apple-videocard.pdf-Manuel

Apple-Guide_de_configuration_de_l_Airport_Express_5.1.pdf-Manuel

Apple-iMac_Mid2010_UG_F.pdf-Manuel

Apple-MacBook_13inch_Mid2009_F.pdf-Manuel

Apple-MacBook_Mid2007_UserGuide.F.pdf-Manuel

Apple-Designing_AirPort_Networks_10.5-Windows_F.pdf-Manuel

Apple-Administration_de_QuickTime_Streaming_et_Broadcasting_10.5.pdf-Manuel

Apple-Opstillingsvejledning_til_TimeCapsule.pdf-Danemark-Manuel

Apple-iPod_nano_5th_gen_Benutzerhandbuch.pdf-Manuel

Apple-iOS_Business.pdf-Manuel

Apple-AirPort_Extreme_Installationshandbuch.pdf-Manuel

Apple-Final_Cut_Express_4_Installation_de_votre_logiciel.pdf-Manuel

Apple-MacBook_Pro_15inch_2.53GHz_Mid2009.pdf-Manuel

Apple-Network_Services.pdf-Manuel

Apple-Aperture_Performing_Adjustments_f.pdf-Manuel

Apple-Supplement_au_guide_Premiers_contacts.pdf-Manuel

Apple-Administration_des_images_systeme_et_de_la_mise_a_jour_de_logiciels_10.5.pdf-Manuel

Apple-Mac_OSX_Server_v10.6_Premiers_contacts.pdf-Francais-Manuel

Apple-Designing_AirPort_Networks_10.5-Windows_F.pdf-Manuel

Apple-Mise_a_niveau_et_migration_v10.5.pdf-Manue

Apple-MacBookPro_Late_2007_2.4_2.2GHz_F.pdf-Manuel

Apple-Mac_mini_Late2009_SL_Server_F.pdf-Manuel

Apple-Mac_OS_X_Server_10.5_Premiers_contacts.pdf-Manuel

Apple-iPod_touch_2.0_Guide_de_l_utilisateur_CA.pdf-Manuel

Apple-MacBook_Pro_17inch_Mid2010_F.pdf-Manuel

Apple-Comment_demarrer_Leopard.pdf-Manuel

Apple-iPod_2ndGen_USB_Power_Adapter-FR.pdf-Manuel

Apple-Feuille_de_operations_10.4.pdf-Manuel

Apple-Time_Capsule_Installationshandbuch.pdf-Allemand-Manuel

Apple-F034-2262AXerve-grappe.pdf-Manuel

Apple-Mac_Pro_Early2009_4707_UG_F

Apple-imacg5_17inch_Power_Supply

Apple-Logic_Studio_Installieren_Ihrer_Software_Retail

Apple-IntroductionXserve1.0.1

Apple-Aperture_Getting_Started_d.pdf-Allemand

Apple-getting_started_with_passbook

Apple-iPod_mini_2nd_Gen_UserGuide.pdf-Anglais

Apple-Deploiement-d-iPhone-et-d-iPad-Reseaux-prives-virtuels

Apple-F034-2262AXerve-grappe

Apple-Mac_OS_X_Server_Glossaire_10.5

Apple-FRLogic_Pro_7_Guide_TDM

Apple-iphone_bluetooth_headset_userguide

Apple-Administration_des_services_reseau_10.5

Apple-imacg5_17inch_harddrive

Apple-iPod_nano_4th_gen_Manuale_utente

Apple-iBook-G4-Getting-Started

Apple-XsanGettingStarted

Apple-Mac_mini_UG-Early2006

Apple-Guide_des_fonctionnalites_de_l_iPod_classic

Apple-Guide_de_configuration_d_Xsan_2

Apple-MacBook_Late2006_UsersGuide

Apple-sur-Fnac.com

Apple-Mac_mini_Mid2010_User_Guide_F.pdf-Francais

Apple-PowerBookG3UserManual.PDF.Anglais

Apple-Installation_de_votre_logiciel_Logic_Studio_Retail

Apple-Pages-Guide-de-l-utilisateur

Apple-MacBook_Pro_13inch_Mid2009.pdf.Anglais

Apple-MacBook_Pro_15inch_Mid2009

Apple-Installation_de_votre_logiciel_Logic_Studio_Upgrade

Apple-FRLogic_Pro_7_Guide_TDM

Apple-airportextreme_802.11n_userguide

Apple-iPod_shuffle_3rdGen_UG

Apple-iPod_classic_160GB_User_Guide

Apple-iPod_nano_5th_gen_UserGuide

Apple-ipod_touch_features_guide

Apple-Wireless_Mighty_Mouse_UG

Apple-Advanced-Memory-Management-Programming-Guide

Apple-iOS-App-Programming-Guide

Apple-Concurrency-Programming-Guide

Apple-MainStage-2-User-Manual-Anglais

Apple-iMacG3_2002MultilingualUserGuide

Apple-iBookG3_DualUSBUserGuideMultilingual.PDF.Anglais

Apple-imacG5_20inch_AirPort

Apple-Guide_de_l_utilisateur_de_Mac_Pro_Early_2008

Apple-Installation_de_votre_logiciel_Logic_Express_8

Apple-iMac_Guide_de_l_utilisateur_Mid2007

Apple-imacg5_20inch_OpticalDrive

Apple-FCP6_Formats_de_diffusion_et_formats_HD

Apple-prise_en_charge_des_surfaces_de_controle_logic_pro_8

Apple-Aperture_Quick_Reference_f

Apple-Shake_4_User_Manual

Apple-aluminumAppleKeyboard_wireless2007_UserGuide

Apple-ipod_shuffle_features_guide

Apple-Color-User-Manual

Apple-XsanGettingStarted

Apple-Migration_10.4_2e_Ed

Apple-MacBook_Air_SuperDrive

Apple-MacBook_Late2007-f

ApplePowerMacG5_(Early_2005)_UserGuide

Apple-iSightUserGuide

Apple-MacBook_Pro_Early_2008_Guide_de_l_utilisateur

Apple-Nouvelles-fonctionnalites-aperture-1.5

Apple-premiers_contacts_2e_ed_10.4.pdf-Mac-OS-X-Server

Apple-premiers_contacts_2e_ed_10.4

Apple-eMac_2005UserGuide

Apple-imacg5_20inch_Inverter

Apple-Keynote2_UserGuide.pdf-Japon

Apple-Welcome_to_Tiger.pdf-Japon

Apple-XsanAdminGuide_j.pdf-Japon

Apple-PowerBookG4_UG_15GE.PDF-Japon

Apple-Xsan_Migration.pdf-Japon

Apple-Xserve_Intel_DIY_TopCover_JA.pdf-Japon

Apple-iPod_nano_6thgen_User_Guide_J.pdf-Japon

Apple-Aperture_Photography_Fundamentals.pdf-Japon

Apple-nikeipod_users_guide.pdf-Japon

Apple-QuickTime71_UsersGuide.pdf-Japon

Apple-iMacG5_iSight_UG.pdf-Japon

Apple-Aperture_Performing_Adjustments_j.pdf-Japon

Apple-iMacG5_17inch_HardDrive.pdf-Japon

Apple-iPod_shuffle_Features_Guide_J.pdf-Japon

Apple-MacBook_Air_User_Guide.pdf-Japon

Apple-MacBook_UsersGuide.pdf-Japon

Apple-iPad_iOS4_Brukerhandbok.pdf-Norge-Norvege

Apple-Apple_AirPort_Networks_Early2009_H.pd-Norge-Norvege

Apple-iPod_classic_120GB_no.pdf-Norge-Norvege

Apple-StoreKitGuide.pdf-Japon

Apple-Xserve_Intel_DIY_ExpansionCardRiser_JA.pdf-Japon

Apple-iMacG5_Battery.pdf-Japon

Apple-Logic_Pro_8_Getting_Started.pdf-Japon

Apple-PowerBook-handbok-Norge-Norveg

Apple-iWork09_formler_og_funksjoner.pdf-Norge-Norvege

Apple-MacBook_Pro_15inch_Mid2010_H.pdf-Norge-Norvege

Apple-MacPro_HardDrive_DIY.pdf-Japon

Apple-iPod_Fifth_Gen_Funksjonsoversikt.pdf-Norge-Norvege

Apple-MacBook_13inch_white_Early2009_H.pdf-Norge-Norvege

Apple-GarageBand_09_Komme_i_gang.pdf-Norge-Norvege

Apple-MacBook_Pro_15inch_Mid2009_H.pdf-Norge-Norvege

Apple-imac_mid2011_ug_h.pdf-Norge-Norvege

Apple-iDVD_08_Komme_i_gang.pdf-Norge-Norvege

Apple-MacBook_Air_11inch_Late2010_UG_H.pdf-Norge-Norvege

Apple-iMac_Mid2010_UG_H.pdf-Norge-Norvege

Apple-MacBook_13inch_Mid2009_H.pdf-Norge-Norvege

/Apple-iPhone_3G_Viktig_produktinformasjon_H-Norge-Norvege

Apple-MacBook_13inch_Mid2010_UG_H.pdf-Norge-Norvege

Apple-macbook_air_13inch_mid2011_ug_no.pdf-Norge-Norvege

Apple-Mac_mini_Early2009_UG_H.pdf-Norge-Norvege

Apple-ipad2_brukerhandbok.pdf-Norge-Norvege

Apple-iPhoto_08_Komme_i_gang.pdf-Norge-Norvege

Apple-MacBook_Air_Brukerhandbok_Late2008.pdf-Norge-Norvege

Apple-Pages09_Brukerhandbok.pdf-Norge-Norvege

Apple-MacBook_13inch_Late2009_UG_H.pdf-Norge-Norvege

Apple-iPhone_3GS_Viktig_produktinformasjon.pdf-Norge-Norvege

Apple-MacBook_13inch_Aluminum_Late2008_H.pdf-Norge-Norvege

Apple-Wireless_Keyboard_Aluminum_2007_H-Norge-Norvege

Apple-NiPod_photo_Brukerhandbok_N0190269.pdf-Norge-Norvege

Apple-MacBook_Pro_13inch_Mid2010_H.pdf-Norge-Norvege

Apple-MacBook_Pro_17inch_Mid2010_H.pdf-Norge-Norvege

Apple-Velkommen_til_Snow_Leopard.pdf-Norge-Norvege.htm

Apple-TimeCapsule_Klargjoringsoversikt.pdf-Norge-Norvege

Apple-iPhone_3GS_Hurtigstart.pdf-Norge-Norvege

Apple-Snow_Leopard_Installeringsinstruksjoner.pdf-Norge-Norvege

Apple-iMacG5_iSight_UG.pdf-Norge-Norvege

Apple-iPod_Handbok_S0342141.pdf-Norge-Norvege

Apple-ipad_brukerhandbok.pdf-Norge-Norvege

Apple-GE_Money_Bank_Handlekonto.pdf-Norge-Norvege

Apple-MacBook_Air_11inch_Late2010_UG_H.pdf-Norge-Norvege

Apple-iPod_nano_6thgen_Brukerhandbok.pdf-Norge-Norvege

Apple-iPod_touch_iOS4_Brukerhandbok.pdf-Norge-Norvege

Apple-MacBook_Air_13inch_Late2010_UG_H.pdf-Norge-Norvege

Apple-MacBook_Pro_15inch_Early2011_H.pdf-Norge-Norvege

Apple-Numbers09_Brukerhandbok.pdf-Norge-Norvege

Apple-Welcome_to_Leopard.pdf-Japon

Apple-PowerMacG5_UserGuide.pdf-Norge-Norvege

Apple-iPod_touch_2.1_Brukerhandbok.pdf-Norge-Norvege

Apple-Boot_Camp_Installering-klargjoring.pdf-Norge-Norvege

Apple-MacOSX10.3_Welcome.pdf-Norge-Norvege

Apple-iPod_shuffle_3rdGen_UG_H.pdf-Norge-Norvege

Apple-iPhone_4_Viktig_produktinformasjon.pdf-Norge-Norvege

Apple_TV_Klargjoringsoversikt.pdf-Norge-Norvege

Apple-iMovie_08_Komme_i_gang.pdf-Norge-Norvege

Apple-iPod_classic_160GB_Brukerhandbok.pdf-Norge-Norvege

Apple-Boot_Camp_Installering_10.6.pdf-Norge-Norvege

Apple-Network-Services-Location-Manager-Veiledning-for-nettverksadministratorer-Norge-Norvege

Apple-iOS_Business_Mar12_FR.pdf

Apple-PCIDualAttachedFDDICard.pdf

Apple-Aperture_Installing_Your_Software_f.pdf

Apple-User_Management_Admin_v10.4.pdf

Apple-Compressor-4-ユーザーズマニュアル Japon

Apple-Network_Services_v10.4.pdf

Apple-iPod_2ndGen_USB_Power_Adapter-DE

Apple-Mail_Service_v10.4.pdf

Apple-AirPort_Express_Opstillingsvejledning_5.1.pdf

Apple-MagSafe_Airline_Adapter.pdf

Apple-L-Apple-Multiple-Scan-20-Display

Apple-Administration_du_service_de_messagerie_10.5.pdf

Apple-System_Image_Admin.pdf

Apple-iMac_Intel-based_Late2006.pdf-Japon

Apple-iPhone_3GS_Finger_Tips_J.pdf-Japon

Apple-Power-Mac-G4-Mirrored-Drive-Doors-Japon

Apple-AirMac-カード取り付け手順-Japon

Apple-iPhone開発ガイド-Japon

Apple-atadrive_pmg4mdd.j.pdf-Japon

Apple-iPod_touch_2.2_User_Guide_J.pdf-Japon

Apple-Mac_OS_X_Server_v10.2.pdf

Apple-AppleCare_Protection_Plan_for_Apple_TV.pdf

Apple_Component_AV_Cable.pdf

Apple-DVD_Studio_Pro_4_Installation_de_votre_logiciel

Apple-Windows_Services

Apple-Motion_3_New_Features_F

Apple-g4mdd-fw800-lowerfan

Apple-MacOSX10.3_Welcome

Apple-Print_Service

Apple-Xserve_Setup_Guide_F

Apple-PowerBookG4_17inch1.67GHzUG

Apple-iMac_Intel-based_Late2006

Apple-Installation_de_votre_logiciel

Apple-guide_des_fonctions_de_l_iPod_nano

Apple-Administration_de_serveur_v10.5

Apple-Mac-OS-X-Server-Premiers-contacts-Pour-la-version-10.3-ou-ulterieure

Apple-boot_camp_install-setup

Apple-iBookG3_14inchUserGuideMultilingual

Apple-mac_pro_server_mid2010_ug_f

Apple-Motion_Supplemental_Documentation

Apple-imac_mid2011_ug_f

Apple-iphone_guide_de_l_utilisateur

Apple-macbook_air_11inch_mid2011_ug_fr

Apple-NouvellesfonctionnalitesdeLogicExpress7.2

Apple-QT_Streaming_Server

Apple-Web_Technologies_Admin

Apple-Mac_Pro_Early2009_4707_UG

Apple-guide_de_l_utilisateur_de_Numbers08

Apple-Decouverte_d_Aperture_2

Apple-Guide_de_configuration_et_d'administration

Apple-mac_integration_basics_fr_106.

Apple-iPod_shuffle_4thgen_Guide_de_l_utilisateur

Apple-ARA_Japan

Apple-081811_APP_iPhone_Japanese_v5.4.pdf-Japan

Apple-Recycle_Contract120919.pdf-Japan

Apple-World_Travel_Adapter_Kit_UG

Apple-iPod_nano_6thgen_User_Guide

Apple-RemoteSupportJP

Apple-Mac_mini_Early2009_UG_F.pdf-Manuel-de-l-utilisateur

Apple-Compressor_3_Batch_Monitor_User_Manual_F.pdf-Manuel-de-l-utilisateur

Apple-Premiers__contacts_avec_iDVD_08

Apple-Mac_mini_Intel_User_Guide.pdf

Apple-Prise_en_charge_des_surfaces_de_controle_Logic_Express_8

Apple-mac_integration_basics_fr_107.pdf

Apple-Final-Cut-Pro-7-Niveau-1-Guide-de-preparation-a-l-examen

Apple-Logic9-examen-prep-fr.pdf-Logic-Pro-9-Niveau-1-Guide-de-preparation-a-l-examen

Apple-aperture_photography_fundamentals.pdf-Manuel-de-l-utilisateu

Apple-emac-memory.pdf-Manuel-de-l-utilisateur

Apple-Apple-Installation-et-configuration-de-votre-Power-Mac-G4

Apple-Guide_de_l_administrateur_d_Xsan_2.pdf

Apple-premiers_contacts_avec_imovie6.pdf

Apple-Tiger_Guide_Installation_et_de_configuration.pdf

Apple-Final-Cut-Pro-7-Level-One-Exam-Preparation-Guide-and-Practice-Exam

Apple-Open_Directory.pdf

Apple-Nike_+_iPod_User_guide

Apple-ard_admin_guide_2.2_fr.pdf

Apple-systemoverviewj.pdf-Japon

Apple-Xserve_TO_J070411.pdf-Japon

Apple-Mac_Pro_User_Guide.pdf

Apple-iMacG5_iSight_UG.pdf

Apple-premiers_contacts_avec_iwork_08.pdf

Apple-services_de_collaboration_2e_ed_10.4.pdf

Apple-iPhone_Bluetooth_Headset_Benutzerhandbuch.pdf

Apple-Guide_de_l_utilisateur_de_Keynote08.pdf

APPLE/Apple-Logic-Pro-9-Effectsrfr.pdf

Apple-Logic-Pro-9-Effectsrfr.pdf

Apple-iPod_shuffle_3rdGen_UG_F.pdf

Apple-iPod_classic_160Go_Guide_de_l_utilisateur.pdf

Apple-iBookG4GettingStarted.pdf

Apple-Administration_de_technologies_web_10.5.pdf

Apple-Compressor-4-User-Manual-fr

Apple-MainStage-User-Manual-fr.pdf

Apple-Logic_Pro_8.0_lbn_j.pdf

Apple-PowerBookG4_15inch1.67-1.5GHzUserGuide.pdf

Apple-MacBook_Pro_15inch_Mid2010_CH.pdf

Apple-LED_Cinema_Display_27-inch_UG.pdf

Apple-MacBook_Pro_15inch_Mid2009_RS.pdf

Apple-macbook_pro_13inch_early2011_f.pdf

Apple-iMac_Mid2010_UG_BR.pdf

Apple-iMac_Late2009_UG_J.pdf

Apple-iphone_user_guide-For-iOS-6-Software

Apple-iDVD5_Getting_Started.pdf

Apple-guide_des_fonctionnalites_de_l_ipod_touch.pdf

Apple_iPod_touch_User_Guide

Apple_macbook_pro_13inch_early2011_f

Apple_Guide_de_l_utilisateur_d_Utilitaire_RAID

Apple_Time_Capsule_Early2009_Setup_F

Apple_iphone_4s_finger_tips_guide_rs

Apple_iphone_upute_za_uporabu

Apple_ipad_user_guide_ta

Apple_iPod_touch_User_Guide

apple_earpods_user_guide

apple_iphone_gebruikershandleiding

apple_iphone_5_info

apple_iphone_brukerhandbok

apple_apple_tv_3rd_gen_setup_tw

apple_macbook_pro-retina-mid-2012-important_product_info_ch

apple_Macintosh-User-s-Guide-for-Macintosh-PowerBook-145

Apple_ipod_touch_user_guide_ta

Apple_TV_2nd_gen_Setup_Guide_h

Apple_ipod_touch_manual_del_usuario

Apple_iphone_4s_finger_tips_guide_tu

Apple_macbook_pro_retina_qs_th

Apple-Manuel_de_l'utilisateur_de_Final_Cut_Server

Apple-iMac_G5_de_lutilisateur

Apple-Cinema_Tools_4.0_User_Manual_F

Apple-Personal-LaserWriter300-User-s-Guide

Apple-QuickTake-100-User-s-Guide-for-Macintosh

Apple-User-s-Guide-Macintosh-LC-630-DOS-Compatible

Apple-iPhone_iOS3.1_User_Guide

Apple-iphone_4s_important_product_information_guide

Apple-iPod_shuffle_Features_Guide_F

Liste-documentation-apple

Apple-Premiers_contacts_avec_iMovie_08

Apple-macbook_pro-retina-mid-2012-important_product_info_br

Apple-macbook_pro-13-inch-mid-2012-important_product_info

Apple-macbook_air-11-inch_mid-2012-qs_br

Apple-Manuel_de_l_utilisateur_de_MainStage

Apple-Compressor_3_User_Manual_F

Apple-Color_1.0_User_Manual_F

Apple-guide_de_configuration_airport_express_4.2

Apple-TimeCapsule_SetupGuide

Apple-Instruments_et_effets_Logic_Express_8

Apple-Manuel_de_l_utilisateur_de_WaveBurner

Apple-Macmini_Guide_de_l'utilisateur

Apple-PowerMacG5_UserGuide

Disque dur, ATA parallèle Instructions de remplacement

Apple-final_cut_pro_x_logic_effects_ref_f

Apple-Leopard_Installationshandbok

Manuale Utente PowerBookG4

Apple-thunderbolt_display_getting_started_1e

Apple-Compressor-4-Benutzerhandbuch

Apple-macbook_air_11inch_mid2011_ug

Apple-macbook_air-mid-2012-important_product_info_j

Apple-iPod-nano-Guide-des-fonctionnalites

Apple-iPod-nano-Guide-des-fonctionnalites

Apple-iPod-nano-Guide-de-l-utilisateur-4eme-generation

Apple-iPod-nano-Guide-de-l-utilisateur-4eme-generation

Apple-Manuel_de_l_utilisateur_d_Utilitaire_de_reponse_d_impulsion

Apple-Aperture_2_Raccourcis_clavier

AppleTV_Setup-Guide

Apple-livetype_2_user_manual_f

Apple-imacG5_17inch_harddrive

Apple-macbook_air_guide_de_l_utilisateur

Apple-MacBook_Early_2008_Guide_de_l_utilisateur

Apple-Keynote-2-Guide-de-l-utilisateur

Apple-PowerBook-User-s-Guide-for-PowerBook-computers

Apple-Macintosh-Performa-User-s-Guide-5200CD-and-5300CD

Apple-Macintosh-Performa-User-s-Guide

Apple-Workgroup-Server-Guide

Apple-iPod-nano-Guide-des-fonctionnalites

Apple-iPad-User-Guide-For-iOS-5-1-Software

Apple-Boot-Camp-Guide-d-installation-et-de-configuration

Apple-iPod-nano-Guide-de-l-utilisateur-4eme-generation

Power Mac G5 Guide de l’utilisateur APPLE

Guide de l'utilisateur PAGE '08 APPLE

Guide de l'utilisateur KEYNOTE '09 APPLE

Guide de l'Utilisateur KEYNOTE '3 APPLE

Guide de l'Utilisateur UTILITAIRE RAID

Guide de l'Utilisateur Logic Studio

Power Mac G5 Guide de l’utilisateur APPLE

Guide de l'utilisateur PAGE '08 APPLE

Guide de l'utilisateur KEYNOTE '09 APPLE

Guide de l'Utilisateur KEYNOTE '3 APPLE

Guide de l'Utilisateur UTILITAIRE RAID

Guide de l'Utilisateur Logic Studio

Guide de l’utilisateur ipad Pour le logiciel iOS 5.1

PowerBook G4 Premiers Contacts APPLE

Guide de l'Utilisateur iphone pour le logiciel ios 5.1 APPLE

Guide de l’utilisateur ipad Pour le logiciel iOS 4,3

Guide de l’utilisateur iPod nano 5ème génération

Guide de l'utilisateur iPod Touch 2.2 APPLE

Guide de l’utilisateur QuickTime 7  Mac OS X 10.3.9 et ultérieur Windows XP et Windows 2000

Guide de l'utilisateur MacBook 13 pouces Mi 2010

Guide de l’utilisateur iPhone (Pour les logiciels iOS 4.2 et 4.3)

Guide-de-l-utilisateur-iPod-touch-pour-le-logiciel-ios-4-3-APPLE

Guide-de-l-utilisateur-iPad-2-pour-le-logiciel-ios-4-3-APPLE

Guide de déploiement en entreprise iPhone OS

Guide-de-l-administrateur-Apple-Remote-Desktop-3-1

Guide-de-l-utilisateur-Apple-Xserve-Diagnostics-Version-3X103

Guide-de-configuration-AirPort-Extreme-802.11n-5e-Generation

Guide-de-configuration-AirPort-Extreme-802-11n-5e-Generation

Guide-de-l-utilisateur-Capteur-Nike-iPod

Guide-de-l-utilisateur-iMac-21-5-pouces-et-27-pouces-mi-2011-APPLE

Guide-de-l-utilisateur-Apple-Qadministrator-4

Guide-d-installation-Apple-TV-3-eme-generation

User-Guide-iPad-For-ios-5-1-Software

Object-Oriented Programming with Objective-CContents Introduction 5 Who Should Read This Document 5 Organization of This Document 6 See Also 6 Why Objective-C? 7 Object-Oriented Programming 8 Data and Operations 8 Interface and Implementation 9 The Object Model 12 The Messaging Metaphor 13 Classes 15 Modularity 16 Reusability 16 Mechanisms of Abstraction 18 Encapsulation 18 Polymorphism 19 Inheritance 20 Class Hierarchies 21 Subclass Definitions 21 Uses of Inheritance 22 Dynamism 23 Dynamic Typing 24 Dynamic Binding 25 Dynamic Loading 27 Structuring Programs 29 Outlet Connections 29 Extrinsic and Intrinsic Connections 30 Activating the Object Network 31 Aggregation and Decomposition 31 Models and Frameworks 32 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 2Structuring the Programming Task 34 Collaboration 34 Organizing Object-Oriented Projects 35 Designing on a Large Scale 35 Separating the Interface from the Implementation 35 Dividing the Work into Modules 35 Keeping the Interface Simple 36 Making Decisions Dynamically 36 Inheriting Generic Code 36 Reusing Tested Code 36 Document Revision History 38 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 3 ContentsFigures Object-Oriented Programming 8 Figure 2-1 Interface and implementation 9 The Object Model 12 Figure 3-1 An object 12 Figure 3-2 Objects in a network 13 Figure 3-3 An inheritance hierarchy 21 Structuring Programs 29 Figure 4-1 Outlets 30 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 4An object-oriented approach to application development makes programs more intuitive to design, faster to develop, more amenable to modification, and easier to understand. Most object-oriented development environments consist of at least three parts: ● A library of objects ● A set of development tools ● An object-oriented programming language and support library The Objective-C language is a programming language designed to enable sophisticated object-oriented programming. Objective-C is defined as a small but powerfulset of extensionsto the standard ANSI C language. Its additions to C are mostly based on Smalltalk, one of the first object-oriented programming languages. Objective-C is designed to give C full object-oriented programming capabilities and to do so in a simple and straightforward way. Important: This document does not describe the Objective-C language itself. To learn about the language, see The Objective-C Programming Language . Every object-oriented programming language and environment has a different perspective on what object-oriented means, how objects behave, and how programs might be structured. This document offers the Objective-C perspective. Who Should Read This Document For those who have never used object-oriented programming to create applications, this document is designed to help you become familiar with object-oriented development. It spells out some of the implications of object-oriented design and gives you a flavor of what writing an object-oriented program is really like. If you have developed applications using an object-oriented environment, this document will help you understand the fundamental concepts that are essential to understanding how to use Objective-C effectively and how to structure a program that uses Objective-C. 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 5 IntroductionBecause this isn’t a document about C, it assumes some prior acquaintance with that language. However, it doesn’t have to be an extensive acquaintance. Object-oriented programming in Objective-C is sufficiently different from procedural programming in ANSI C that you won’t be hampered if you’re not an experienced C programmer. Organization of This Document This document is divided into several chapters: ● “Why Objective-C?” (page 7) explains why Objective-C was chosen as the development language for the Cocoa frameworks. ● “Object-Oriented Programming” (page 8) discusses the rationale for object-oriented programming languages and introduces much of the terminology. It develops the ideas behind object-oriented programming techniques. Even if you’re already familiar with object-oriented programming, you are encouraged to read this chapter to gain a sense of the Objective-C perspective on object orientation and its use of terminology. ● “The Object Model” (page 12) describes how you can think of a program in terms of units that combine state and behavior—objects. It then explains how you characterize these objects as belonging to a particular class, how one class can inheritstate and behavior from another class, and how objects can send messages to other objects. ● “Structuring Programs” (page 29) explains how you think about designing an object-oriented program by creating connections between objects. It introducesthe techniques of aggregation and decomposition, which divide responsibility between differentsorts of object, and the role of frameworksin defining libraries of objects designed to work together. ● “Structuring the Programming Task” (page 34) discusses issues of project management related to collaboration among programmers and to code implementation. See Also The Objective-C Programming Language describes the Objective-C programming language. Objective-C Runtime Programming Guide describes how you can interact with the Objective-C runtime. Objective-C Runtime Reference describes the data structures and functions of the Objective-C runtime support library. Your programs can use these interfaces to interact with the Objective-C runtime system. For example, you can add classes or methods, or obtain a list of all class definitions for loaded classes. Introduction Organization of This Document 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 6The Objective-C language was chosen for a variety of reasons. First and foremost, it’s an object-oriented language. The kind of functionality that’s packaged in the Cocoa frameworks can only be delivered through object-oriented techniques. Second, because Objective-C is an extension ofstandard ANSI C, existing C programs can be adapted to use the software frameworks without losing any of the work that went into their original development. Because Objective-C incorporates C, you get all the benefits of C when working within Objective-C. You can choose when to do something in an object-oriented way (define a new class, for example) and when to stick to procedural programming techniques (define a structure and some functions instead of a class). Moreover, Objective-C is a fundamentally simple language. Its syntax is small, unambiguous, and easy to learn. Object-oriented programming, with its self-conscious terminology and emphasis on abstract design, often presents a steep learning curve to new recruits. A well-organized language like Objective-C can make becoming a proficient object-oriented programmer that much less difficult. Compared to other object-oriented languages based on C, Objective-C is very dynamic. The compiler preserves a great deal of information about the objects themselves for use at runtime. Decisions that otherwise might be made at compile time can be postponed until the program isrunning. Dynamism gives Objective-C programs unusual flexibility and power. For example, it yields two big benefits that are hard to get with other nominally object-oriented languages: ● Objective-C supports an open style of dynamic binding, a style that can accommodate a simple architecture for interactive user interfaces. Messages are not necessarily constrained by either the class of the receiver or even the method name, so a software framework can allow for user choices at runtime and permit developers freedom of expression in their design. (Terminology such as dynamic binding , message , class, and receiver are explained in due course in this document.) ● Dynamism enables the construction of sophisticated development tools. An interface to the runtime system provides access to information about running applications, so it’s possible to develop tools that monitor, intervene, and reveal the underlying structure and activity of Objective-C applications. Historical note: As a language, Objective-C has a long history. It was created at the Stepstone company in the early 1980s by Brad Cox and Tom Love. It was licensed by NeXT Computer Inc. in the late 1980s to develop the NeXTStep frameworks that preceded Cocoa. NeXT extended the language in several ways, for example, with the addition of protocols. 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 7 Why Objective-C?As humans, we’re constantly faced with myriad facts and impressions that we must make sense of. To do so, we must abstract underlying structure away from surface details and discover the fundamental relations at work. Abstractions reveal causes and effects, expose patterns and frameworks, and separate what’s important from what’s not. Object orientation provides an abstraction of the data on which you operate; moreover, it provides a concrete grouping between the data and the operations you can perform with the data—in effect giving the data behavior. Data and Operations Programming languages have traditionally divided the world into two parts—data and operations on data. Data is static and immutable, except as the operations may change it. The procedures and functions that operate on data have no lasting state of their own; they’re useful only in their ability to affect data. This division is, of course, grounded in the way computers work, so it’s not one that you can easily ignore or push aside. Like the equally pervasive distinctions between matter and energy and between nouns and verbs, it forms the background against which we work. At some point, all programmers—even object-oriented programmers—must lay out the data structures that their programs will use and define the functions that will act on the data. With a procedural programming language like C, that’s about all there is to it. The language may offer various kinds of support for organizing data and functions, but it won’t divide the world any differently. Functions and data structures are the basic elements of design. Object-oriented programming doesn’tso much dispute this view of the world asrestructure it at a higher level. It groups operations and data into modular units called objects and lets you combine objects into structured networks to form a complete program. In an object-oriented programming language, objects and object interactions are the basic elements of design. Every object has both state (data) and behavior (operations on data). In that, they’re not much different from ordinary physical objects. It’s easy to see how a mechanical device,such as a pocket watch or a piano, embodies both state and behavior. But almost anything that’s designed to do a job does, too. Even simple things with no moving parts such as an ordinary bottle combine state (how full the bottle is, whether or not it’s open, how warm its contents are) with behavior (the ability to dispense its contents at various flow rates, to be opened or closed, to withstand high or low temperatures). 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 8 Object-Oriented ProgrammingIt’sthisresemblance to real thingsthat gives objects much of their power and appeal. They can not only model components of real systems, but equally as well fulfill assigned roles as components in software systems. Interface and Implementation To invent programs, you need to be able to capture abstractions and express them in the program design. It’s the job of a programming language to help you do this. The language should facilitate the process of invention and design by letting you encode abstractions that reveal the way things work. It should let you make your ideas concrete in the code you write. Surface details shouldn’t obscure the architecture of your program. All programming languages provide devices that help express abstractions. In essence, these devices are ways of grouping implementation details, hiding them, and giving them, at least to some extent, a common interface—much as a mechanical objectseparatesitsinterface from itsimplementation, asillustrated in Figure 2-1. Figure 2-1 Interface and implementation 9 10 11 8 7 6 interface implementation Looking at such a unit from the inside, as the implementer, you’d be concerned with what it’s composed of and how it works. Looking at it from the outside, as the user, you’re concerned only with what it is and what it does. You can look past the details and think solely in terms of the role that the unit plays at a higher level. The principal units of abstraction in the C language are structures and functions. Both, in different ways, hide elements of the implementation: ● On the data side of the world, C structures group data elements into larger units that can then be handled as single entities. While some code must delve inside the structure and manipulate the fields separately, much of the program can regard it as a single thing—not as a collection of elements, but as what those elements taken together represent. One structure can include others, so a complex arrangement of information can be built from simpler layers. Object-Oriented Programming Interface and Implementation 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 9In modern C, the fields of a structure live in their own namespace—that is, their names won’t conflict with identically named data elements outside the structure. Partitioning the program namespace is essential for keeping implementation details out of the interface. Imagine, for example, the enormous task of assigning a different name to every piece of data in a large program and of making sure new names don’t conflict with old ones. ● On the proceduralside of the world, functions encapsulate behaviorsthat can be used repeatedly without being reimplemented. Data elements local to a function, like the fields within a structure, are protected within their own namespace. Because functions can reference (call) other functions, complex behaviors can be built from smaller pieces. Functions are reusable. Once defined, they can be called any number of times without again considering the implementation. The most generally useful functions can be collected in libraries and reused in many different applications. All the user needs is the function interface, not the source code. However, unlike data elements, functions aren’t partitioned into separate namespaces. Each function must have a unique name. Although the function may be reusable, its name is not. C structures and functions are able to expresssignificant abstractions, but they maintain the distinction between data and operations on data. In a procedural programming language, the highest units of abstraction still live on one side or the other of the data-versus-operations divide. The programs you design must always reflect, at the highest level, the way the computer works. Object-oriented programming languages don’t lose any of the virtues of structures and functions—they go a step further and add a unit capable of abstraction at a higher level, a unit that hides the interaction between a function and its data. Suppose, for example, that you have a group of functions that act on a particular data structure. You want to make those functions easier to use by, asfar as possible, taking the structure out of the interface. So you supply a few additional functions to manage the data. All the work of manipulating the data structure—allocating memory for it, initializing it, getting information from it, modifying values within it, keeping it up to date, and freeing its memory—is done through the functions. All the user doesis call the functions and passthe structure to them. With these changes, the structure has become an opaque token that other programmers never need to look inside. They can concentrate on what the functions do, not on how the data is organized. You’ve taken the first step toward creating an object. The nextstep isto give thisidea support in the programming language and completely hide the data structure so that it doesn’t even have to be passed between the functions. The data becomes an internal implementation detail; all that’s exported to users is a functional interface. Because objects completely encapsulate their data (hide it), users can think of them solely in terms of their behavior. Object-Oriented Programming Interface and Implementation 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 10With thisstep, the interface to the functions has become much simpler. Callers don’t need to know how they’re implemented (what data they use). It’s fair now to call this an object. The hidden data structure unites all the functions that share access to it. So an object is more than a collection of random functions; it’s a bundle of related behaviors that are supported by shared data. To use a function that belongs to an object, you first create the object (thus giving it its internal data structure), and then tell the object which function it should perform. You begin to think in terms of what the object does, rather than in terms of the individual functions. This progression from thinking about functions and data structures to thinking about object behaviors is the essence of learning object-oriented programming. It may seem unfamiliar at first, but as you gain experience with object-oriented programming, you find it’s a more natural way to think about things. Everyday programming terminology isreplete with analogiesto real-world objects of various kinds—lists, containers, tables, controllers, even managers. Implementing such things as programming objects merely extends the analogy in a natural way. A programming language can be judged by the kinds of abstractions that it enables you to encode. You shouldn’t be distracted by extraneous matters or forced to express yourself using a vocabulary that doesn’t match the reality you’re trying to capture. If, for example, you must alwaystend to the business of keeping the right data matched with the right procedure, you’re forced at all times to be aware of the entire program at a low level of implementation. While you might still invent programs at a high level of abstraction, the path from imagination to implementation can become quite tenuous—and more and more difficult as programs become bigger and more complicated. By providing another, higher level of abstraction, object-oriented programming languages give you a larger vocabulary and a richer model to program in. Object-Oriented Programming Interface and Implementation 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 11The insight of object-oriented programming isto combine state and behavior—data and operations on data—in a high-level unit, an object, and to give it language support. An object is a group of related functions and a data structure that serves those functions. The functions are known as the object’s methods, and the fields of its data structure are its instance variables. The methods wrap around the instance variables and hide them from the rest of the program, as Figure 3-1 illustrates. Figure 3-1 An object method method e m doht method data If you’ve ever tackled any kind of difficult programming problem, it’slikely that your design hasincluded groups of functions that work on a particular kind of data—implicit “objects” without the language support. Object-oriented programming makes these function groups explicit and permits you to think in terms of the group, rather than its components. The only way to an object’s data, the only interface, is through its methods. By combining both state and behavior in a single unit, an object becomes more than either alone; the whole really is greater than the sum of its parts. An object is a kind of self-sufficient “subprogram” with jurisdiction over a specific functional area. It can play a full-fledged modular role within a larger program design. Terminology: Object-oriented terminology variesfrom language to language. For example, in C++, methods are called member functions and instance variables are known as data members. This document uses the terminology of Objective-C, which has its basis in Smalltalk. For example, if you were to write a program that modeled home water usage, you might invent objects to represent the various components of the water-delivery system. One might be a Faucet object that would have methods to start and stop the flow of water, set the rate of flow, return the amount of water consumed in a given period, and so on. To do this work, a Faucet object would need instance variables to keep track of whether the tap is open or shut, how much water is being used, and where the water is coming from. 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 12 The Object ModelClearly, a programmatic Faucet object can be smarter than a real one (it’s analogous to a mechanical faucet with lots of gauges and instruments attached). But even a real faucet, like any system component, exhibits both state and behavior. To effectively model a system, you need programming units, like objects, that also combine state and behavior. A program consists of a network of interconnected objects that call upon each other to solve a part of the puzzle (as illustrated in Figure 3-2 (page 13)). Each object has a specific role to play in the overall design of the program and is able to communicate with other objects. Objects communicate through messages, which are requests to perform methods. Figure 3-2 Objects in a network data data data message The objects in the network won’t all be the same. For example, in addition to Faucet objects, the program that models water usage might also have Pipe objectsthat can deliver water to the Faucet and Valve objects to regulate the flow among pipes. There could be a Building object to coordinate a set of pipes, valves, and faucets, some Appliance objects—corresponding to dishwashers, toilets, and washing machines—that can turn valves on and off, and maybe some User objects to work the appliances and faucets. When a Building object is asked how much water is being used, it might call upon each Faucet and Valve object to report its current state. When a user starts up an appliance, the appliance will need to turn on a valve to get the water it requires. The Messaging Metaphor Every programming paradigm comes with its own terminology and metaphors. The jargon associated with object-oriented programming invites you to think about what goes on in a program from a particular perspective. The Object Model The Messaging Metaphor 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 13There’s a tendency, for example, to think of objects as actors and to endow them with human-like intentions and abilities. It’s tempting sometimes to talk about an object deciding what to do about a situation, asking other objectsfor information, introspecting about itself to get requested information, delegating responsibility to another object, or managing a process. Rather than think in terms of functions or methods doing the work, as you would in a procedural programming language, this metaphor asks you to think of objects as performing their methods. Objects are not passive containers for state and behavior, but are said to be the agents of the program’s activity. This metaphor is actually very useful. An object is like an actor in a couple of respects: It has a particular role to play within the overall design of the program, and within that role it can act fairly independently of the other parts of the program. It interacts with other objects as they play their own roles, but it is self-contained and to a certain extent can act on its own. Like an actor onstage, it can’t stray from the script, but the role it plays can be multifaceted and complex. The idea of objects as actorsfits nicely with the principal metaphor of object-oriented programming—the idea that objects communicate through messages. Instead of calling a method as you would a function, you send a message to an object requesting it to perform one of its methods. Although it can take some getting used to, this metaphor leads to a useful way of looking at methods and objects. It abstracts methods away from the particular data they act on and concentrates on behavior instead. For example, in an object-oriented programming interface, a start method might initiate an operation, an archive method might archive information, and a draw method might produce an image. Exactly which operation is initiated, which information is archived, and which image is drawn isn’t revealed by the method name. Different objects might perform these methods in different ways. Thus, methods are a vocabulary of abstract behaviors. To invoke one of those behaviors, you have to make it concrete by associating the method with an object. This is done by naming the object as the receiver of a message. The object you choose as receiver determines the exact operation that is initiated, the data that is archived, or the image that is drawn. Because methods belong to objects, they can be invoked only through a particular receiver (the owner of the method and of the data structure the method will act on). Different receivers can have different implementations of the same method. Consequently, different receivers can do different thingsin response to the same message. The result of a message can’t be calculated from the message or method name alone; it also depends on the object that receives the message. By separating the message (the requested behavior) from the receiver (the owner of a method that can respond to the request), the messaging metaphor perfectly captures the idea that behaviors can be abstracted away from their particular implementations. The Object Model The Messaging Metaphor 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 14Classes A program can have more than one object of the same kind. The program that models water usage, for example, might have several faucets and pipes and perhaps a handful of appliances and users. Objects of the same kind are said to be members of the same class. All members of a class are able to perform the same methods and have matching sets of instance variables. They also share a common definition; each kind of object is defined just once. In this, objects are similar to C structures. Declaring a structure defines a type. For example, the declaration struct key { char *word; int count; }; defines the struct key type. Once defined, the structure name can be used to produce any number of instances of the type: struct key a, b, c, d; struct key *p = malloc(sizeof(struct key) * MAXITEMS); The declaration is a template for a kind of structure, but it doesn’t create a structure that the program can use. It takes another step to allocate memory for an actual structure of that type, a step that can be repeated any number of times. Similarly, defining an object creates a template for a kind of object. It defines a class of objects. The template can be used to produce any number of similar objects—instances of the class. For example, there would be a single definition of the Faucet class. Using this definition, a program could allocate as many Faucet instances as it needed. A class definition is like a structure definition in that it lays out an arrangement of data elements (instance variables) that become part of every instance. Each instance has memory allocated for its own set of instance variables, which store values particular to the instance. However, a class definition differs from a structure declaration in that it also defines methods that specify the behavior of class members. Every instance is characterized by its access to the methods defined for the class. Two objects with equivalent data structures but different methods would not belong to the same class. The Object Model Classes 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 15Modularity To a C programmer, a module is nothing more than a file containing source code. Breaking a large (or even not-so-large) program into different files is a convenient way of splitting it into manageable pieces. Each piece can be worked on independently and compiled alone, and then integrated with other pieces when the program is linked. Using the static storage class designator to limit the scope of names to just the files where they’re declared enhances the independence of source modules. This kind of module is a unit defined by the file system. It’s a container for source code, not a logical unit of the language. What goes into the container is up to each programmer. You can use them to group logically related parts of the code, but you don’t have to. Files are like the drawers of a dresser; you can put your socks in one drawer, underwear in another, and so on, or you can use another organizing scheme or simply choose to mix everything up. Access to methods: It’s convenient to think of methods as being part of an object, just as instance variables are. As in Figure 3-1 (page 12), methods can be diagrammed as surrounding the object’s instance variables. But methods aren’t grouped with instance variables in memory. Memory is allocated for the instance variables of each new object, but there’s no need to allocate memory for methods. All an instance needs is access to its methods, and all instances of the same class share access to the same set of methods. There’s only one copy of the methods in memory, no matter how many instances of the class are created. Object-oriented programming languages support the use of file containers for source code, but they also add a logical module to the language—class definitions. As you’d expect, it’s often the case that each classis defined in its own source file—logical modules are matched to container modules. In Objective-C, for example, it would be possible to define the part of the Valve class that interacts with Pipe objects in the same file that defines the Pipe class, thus creating a container module for Pipe-related code and splitting the Valve class into more than one file. The Valve class definition would still act as a modular unit within the construction of the program—it would still be a logical module—no matter how many files the source code was located in. The mechanisms that make class definitions logical units of the language are discussed in some detail under “Mechanisms of Abstraction” (page 18). Reusability A principal goal of object-oriented programming is to make the code you write as reusable as possible—to have it serve many different situations and applications—so that you can avoid reimplementing, even if only slightly differently, something that’s already been done. The Object Model Classes 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 16Reusability is influenced by factors such as these: ● How reliable and bug-free the code is ● How clear the documentation is ● How simple and straightforward the programming interface is ● How efficiently the code performs its tasks ● How full the feature set is These factors don’t apply just to the object model. They can be used to judge the reusability of any code—standard C functions as well as class definitions. Efficient and well-documented functions, for example, would be more reusable than undocumented and unreliable ones. Nevertheless, a general comparison would show that class definitions lend themselves to reusable code in waysthat functions do not. There are variousthings you can do to make functions more reusable—for example, passing data as parameters rather than assuming specifically named global variables. Even so, it turns out that only a small subset of functions can be generalized beyond the applications they were originally designed for. Their reusability is inherently limited in at least three ways: ● Function names are global; each function must have a unique name (except for those declared static). This naming requirement makesit difficult to rely heavily on library code when building a complex system. The programming interface would be hard to learn and so extensive that it couldn’t easily capture significant generalizations. Classes, on the other hand, can share programming interfaces. When the same naming conventions are used over and over, a great deal of functionality can be packaged with a relatively small and easy-to-understand interface. ● Functions are selected from a library one at a time. It’s up to programmersto pick and choose the individual functions they need. In contrast, objects come as packages of functionality, not as individual methods and instance variables. They provide integrated services, so users of an object-oriented library won’t get bogged down piecing together their own solutions to a problem. ● Functions are typically tied to particular kinds of data structures devised for a specific program. The interaction between data and function is an unavoidable part of the interface. A function is useful only to those who agree to use the same kind of data structures it accepts as parameters. Because it hides its data, an object doesn’t have this problem. This is one of the principal reasons that classes can be reused more easily than functions. The Object Model Classes 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 17An object’s data is protected and won’t be touched by any other part of the program. Methods can therefore trust its integrity. They can be sure that external access hasn’t put data into an illogical or untenable state. As a result, an object data structure is more reliable than one passed to a function, and methods can depend on it more. Reusable methods are consequently easier to write. Moreover, because an object’s data is hidden, a class can be reimplemented to use a different data structure without affecting its interface. All programs that use the class can pick up the new version without changing any source code; no reprogramming is required. Mechanisms of Abstraction To this point, objects have been introduced as units that embody higher-level abstractions and as coherent role-players within an application. However, they couldn’t be used this way without the support of various language mechanisms. Two of the most important mechanisms are encapsulation and polymorphism. Encapsulation keeps the implementation of an object out of its interface, and polymorphism results from giving each class its own namespace. The following sections discuss each of these mechanisms in turn. Encapsulation To design effectively at any level of abstraction, you need to be able to leave details of implementation behind and think in terms of units that group those details under a common interface. For a programming unit to be truly effective, the barrier between interface and implementation must be absolute. The interface must encapsulate the implementation—that is, hide it from other parts of the program. Encapsulation protects an implementation from unintended actions and from inadvertent access. In C, a function is clearly encapsulated; its implementation is inaccessible to other parts of the program and protected from whatever actions might be taken outside the body of the function. In Objective-C, method implementations are similarly encapsulated, but more importantly so are an object’sinstance variables. They’re hidden inside the object and invisible outside it. The encapsulation of instance variables is sometimes also called information hiding . It might seem, at first, that hiding the information in instance variables might constrain your freedom as a programmer. Actually, it gives you more room to act and frees you from constraints that might otherwise be imposed. If any part of an object’s implementation could leak out and become accessible or a concern to other parts of the program, it would tie the hands both of the object’s implementer and of those who would use the object. Neither could make modifications without first checking with the other. The Object Model Mechanisms of Abstraction 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 18Suppose, for example, that you’re interested in the Faucet object being developed for the program that models water use and you want to incorporate it in another program you’re writing. Once the interface to the object is decided, you don’t have to be concerned when others work on it, fix bugs, and find better ways to implement it. You get the benefit of these improvements, but none of them affects what you do in your program. Because you depend solely on the interface, nothing they do can break your code. Your program is insulated from the object’s implementation. Moreover, although those implementing the Faucet object might be interested in how you use the class and might try to make sure it meets your needs, they don’t have to be concerned with the way you write your code. Nothing you do can touch the implementation of the object or limit their freedom to make implementation changesin future releases. The implementation isinsulated from anything that you or other users of the object might do. Polymorphism The ability of different objects to respond, each in its own way, to identical messages is called polymorphism. Polymorphism results from the fact that every class lives in its own namespace. The names assigned within a class definition don’t conflict with names assigned anywhere outside it. Thisistrue both of the instance variables in an object’s data structure and of the object’s methods: ● Just as the fields of a C structure are in a protected namespace, so are an object’s instance variables. ● Method names are also protected. Unlike the names of C functions, method names aren’t global symbols. The name of a method in one class can’t conflict with method names in other classes; two very different classes can implement identically named methods. Method names are part of an object’sinterface. When a message issent requesting that an object do something, the message names the method the object should perform. Because different objects can have methods with the same name, the meaning of a message must be understood relative to the particular object that receives the message. The same message sent to two different objects can invoke two distinct methods. The main benefit of polymorphism is that it simplifies the programming interface. It permits conventions to be established that can be reused in class after class. Instead of inventing a new name for each new function you add to a program, the same names can be reused. The programming interface can be described as a set of abstract behaviors, quite apart from the classes that implement them. The Object Model Mechanisms of Abstraction 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 19Overloading: The terms polymorphism and parameter overloading refer basically to the same thing, but from slightly different points of view. Polymorphism takes a pluralistic point of view and notesthatseveral classes can each have a method with the same name. Parameter overloading takes the point of the view of the method name and notes that it can have different effects depending on the parameters passed to it.Operator overloading issimilar. Itrefersto the ability to turn operators of the language (such as == and + in C) into methods that can be assigned particular meanings for particular kinds of objects. Objective-C implements polymorphism of method names, but not parameter or operator overloading. For example, suppose you want to report the amount of water used by an Appliance object over a given period of time. Instead of defining an amountConsumed method for the Appliance class, an amountDispensedAtFaucet method for a Faucet class, and a cumulativeUsage method for a Building class, you can simply define a waterUsed method for each class. This consolidation reduces the number of methods used for what is conceptually the same operation. Polymorphism also permits code to be isolated in the methods of different objects rather than be gathered in a single function that enumerates all the possible cases. This makes the code you write more extensible and reusable. When a new case comes along, you don’t have to reimplement existing code; you need only to add a new class with a new method, leaving the code that’s already written alone. For example, suppose you have code that sends a draw message to an object. Depending on the receiver, the message might produce one of two possible images. When you want to add a third case, you don’t have to change the message or alter existing code; you merely allow another object to be assigned as the message receiver. Inheritance The easiest way to explain something new is to start with something understood. If you want to describe what a schooner is, it helpsif your listeners already know what a sailboat is. If you want to explain how a harpsichord works, it’s best if you can assume your audience has already looked inside a piano, or has seen a guitar played, or at least is familiar with the idea of a musical instrument. The same is true if you want to define a new kind of object; the description is simpler if it can start from the definition of an existing object. With thisin mind, object-oriented programming languages permit you to base a new class definition on a class already defined. The base class is called a superclass; the new class is its subclass. The subclass definition specifies only how it differs from the superclass; everything else is taken to be the same. The Object Model Inheritance 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 20Nothing is copied from superclass to subclass. Instead, the two classes are connected so that the subclass inherits all the methods and instance variables of itssuperclass, much as you want your listener’s understanding ofschooner to inherit what they already know aboutsailboats. If the subclass definition were empty (if it didn’t define any instance variables or methods of its own), the two classes would be identical (except for their names) and would share the same definition. It would be like explaining what a fiddle is by saying that it’s exactly the same as a violin. However, the reason for declaring a subclassisn’t to generate synonyms; it to create something at least a little different from its superclass. For example, you might extend the behavior of the fiddle to allow it to play bluegrass in addition to classical music. Class Hierarchies Any class can be used as a superclass for a new class definition. A class can simultaneously be a subclass of another class, and a superclass for its own subclasses. Any number of classes can thus be linked in a hierarchy of inheritance, such as the one depicted in Figure 3-3. Figure 3-3 An inheritance hierarchy root C D E F A B Every inheritance hierarchy begins with a root class that has no superclass. From the root class, the hierarchy branches downward. Each class inherits from its superclass and, through its superclass, from all the classes above it in the hierarchy. Every class inherits from the root class. Each class is the accumulation of all the class definitions in its inheritance chain. In the example above, class D inherits both from C—itssuperclass—and the root class. Members of the D class have methods and instance variables defined in all three classes—D, C, and root. Typically, every class has just one superclass and can have an unlimited number of subclasses. However, in some object-oriented programming languages (though not in Objective-C), a class can have more than one superclass; it can inherit through multiple sources. Instead of having a single hierarchy that branches downward as shown in Figure 3-3, multiple inheritance lets some branches of the hierarchy (or of different hierarchies) merge. Subclass Definitions A subclass can make three kinds of changes to the definition it inherits through its superclass: The Object Model Inheritance 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 21● It can expand the class definition it inherits by adding new methods and instance variables. This is the most common reason for defining a subclass. Subclasses always add new methods and add new instance variables if the methods require it. ● It can modify the behavior it inherits by replacing an existing method with a new version. This is done by simply implementing a new method with the same name as one that’sinherited. The new version overrides the inherited version. (The inherited method doesn’t disappear; it’s still valid for the class that defined it and other classes that inherit it.) ● It can refine or extend the behavior it inherits by replacing an existing method with a new version, but it still retains the old version by incorporating it in the new method. A subclass sends a message to perform the old version in the body of the new method. Each class in an inheritance chain can contribute part of a method’s behavior. In Figure 3-3 (page 21), for example, class D might override a method defined in class C and incorporate C’s version, while C’s version incorporates a version defined in the root class. Subclasses thus tend to fill out a superclass definition, making it more specific and specialized. They add, and sometimesreplace, code rather than subtract it. Note that methods generally can’t be disinherited and instance variables can’t be removed or overridden. Uses of Inheritance The classic examples of an inheritance hierarchy are borrowed from animal and plant taxonomies. For example, there could be a class corresponding to the Pinaceae (pine) family of trees. Itssubclasses could be Fir, Spruce, Pine, Hemlock, Tamarack, DouglasFir, and TrueCedar, corresponding to the various genera that make up the family. The Pine class might have SoftPine and HardPine subclasses, with WhitePine, SugarPine, and BristleconePine as subclasses of SoftPine, and PonderosaPine, JackPine, MontereyPine, and RedPine as subclasses of HardPine. There’s rarely a reason to program a taxonomy like this, but the analogy is a good one. Subclasses tend to specialize a superclass or adapt it to a special purpose, much as a species specializes a genus. Here are some typical uses of inheritance: ● Reusing code. If two or more classes have some things in common but also differ in some ways, the common elements can be put in a single class definition that the other classes inherit. The common code is shared and need only be implemented once. For example, Faucet, Valve, and Pipe objects, defined for the program that models water use, all need a connection to a water source and should be able to record the rate of flow. These commonalities can be encoded once, in a class that the Faucet, Valve, and Pipe classes inherit from. A Faucet object can be said to be a kind of Valve object, so perhaps the Faucet class would inherit most of what it is from Valve, and add little of its own. The Object Model Inheritance 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 22● Setting up a protocol. A class can declare a number of methods that its subclasses are expected to implement. The class might have empty versions of the methods, or it might implement partial versions that are to be incorporated into the subclass methods. In either case, its declarations establish a protocol that all its subclasses must follow. When different classes implement similarly named methods, a program is better able to make use of polymorphism in its design. Setting up a protocol that subclasses must implement helps enforce these conventions. ● Delivering generic functionality. One implementer can define a class that contains a lot of basic, general code to solve a problem but that doesn’t fill in all the details. Other implementers can then create subclasses to adapt the generic class to their specific needs. For example, the Appliance class in the program that models water use might define a generic water-using device thatsubclasses would turn into specific kinds of appliances. Inheritance is thus both a way to make someone else’s programming task easier and a way to separate levels of implementation. ● Making slight modifications. When inheritance is used to deliver generic functionality, set up a protocol, or reuse code, a class is devised that other classes are expected to inherit from. But you can also use inheritance to modify classes that aren’t intended as superclasses. Suppose, for example, that there’s an object that would work well in your program, but you’d like to change one or two things that it does. You can make the changes in a subclass. ● Previewing possibilities. Subclasses can also be used to factor out alternatives for testing purposes. For example, if a class is to be encoded with a particular user interface, alternative interfaces can be factored into subclasses during the design phase of the project. Each alternative can then be demonstrated to potential usersto see which they prefer. When the choice is made, the selected subclass can be reintegrated into its superclass. Dynamism At one time in programming history, the question of how much memory a program might use was typically settled when the source code was compiled and linked. All the memory the program would ever need was set aside for it as it was launched. This memory was fixed; it could neither grow nor shrink. In hindsight, it’s evident what a serious constraint this was. It limited not only how programs were constructed, but what you could imagine a program doing. It constrained design, not just programming technique. The introduction of functions that dynamically allocate memory as a program runs (such as malloc) opened possibilities that didn’t exist before. The Object Model Dynamism 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 23Compile-time and link-time constraints are limiting because they force issues to be decided from information found in the programmer’s source code, rather than from information obtained from the user as the program runs. Although dynamic allocation removes one such constraint, many others, equally as limiting as static memory allocation, remain. For example, the elements that make up an application must be matched to data types at compile time. And the boundaries of an application are typically set at link time. Every part of the application must be united in a single executable file. New modules and new types can’t be introduced as the program runs. Objective-C seeks to overcome these limitations and to make programs as dynamic and fluid as possible. It shifts much of the burden of decision making from compile time and link time to runtime. The goal is to let program users decide what will happen, rather than constrain their actions artificially by the demands of the language and the needs of the compiler and linker. Three kinds of dynamism are especially important for object-oriented design: ● Dynamic typing, waiting until runtime to determine the class of an object ● Dynamic binding, determining at runtime what method to invoke ● Dynamic loading, adding new components to a program as it runs Dynamic Typing The compiler typically complains if the code you write assigns a value to a type that can’t accommodate it. You might see warnings like these: incompatible types in assignment assignment of integer from pointer lacks a cast Type checking is useful, but there are times when it can interfere with the benefits you get from polymorphism, especially if the type of every object must be known to the compiler. Suppose, for example, that you want to send an object a message to perform the start method. Like other data elements, the object isrepresented by a variable. If the variable’stype (its class) must be known at compile time, it would be impossible to let runtime factors influence the decision about what kind of object should be assigned to the variable. If the class of the variable is fixed in source code, so is the version of start that the message invokes. The Object Model Dynamism 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 24If, on the other hand, it’s possible to wait until runtime to discover the class of the variable, any kind of object could be assigned to it. Depending on the class of the receiver, the start message might invoke different versions of the method and produce very different results. Dynamic typing thus givessubstance to dynamic binding (discussed next). But it does more than that. It permits associations between objects to be determined at runtime, rather than forcing them to be encoded in a static design. For example, a message could pass an object as a parameter without declaring exactly what kind of object it is—that is, without declaring its class. The message receiver might then send its own messages to the object, again without ever caring about what kind of object it is. Because the receiver uses the passed object to do some of its work, it is in a sense customized by an object of indeterminate type (indeterminate in source code, that is, not at runtime). Dynamic Binding In standard C, you can declare a set of alternative functions, such as the standard string-comparison functions, int strcmp(const char *, const char *); /* case sensitive */ int strcasecmp(const char *, const char *); /*case insensitive*/ and declare a pointer to a function that has the same return and parameter types: int (* compare)(const char *, const char *); You can then wait until runtime to determine which function to assign to the pointer, if ( **argv == 'i' ) compare = strcasecmp; else compare = strcmp; and call the function through the pointer: if ( compare(s1, s2) ) ... Thisis akin to what in object-oriented programming is called dynamic binding, delaying the decision of exactly which method to perform until the program is running. The Object Model Dynamism 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 25Although not all object-oriented languages support it, dynamic binding can be routinely and transparently accomplished through messaging. You don’t have to go through the indirection of declaring a pointer and assigning values to it as shown in the example above. You also don’t have to assign each alternative procedure a different name. Messages invoke methods indirectly. Every message expression must find a method implementation to “call.” To find that method, the messaging machinery must check the class of the receiver and locate itsimplementation of the method named in the message. When this is done at runtime, the method is dynamically bound to the message. When it’s done by the compiler, the method is statically bound. Late binding: Some object-oriented programming languages (notably C++) require a message receiver to be statically typed in source code, but don’t require the type to be exact. An object can be typed to its own class or to any classthat it inheritsfrom. The compiler therefore can’t tell whether the message receiver is an instance of the class specified in the type declaration, an instance of a subclass, or an instance ofsome more distantly derived class. Because it doesn’t know the exact class of the receiver, it can’t know which version of the method named in the message to invoke. In this circumstance, the choice is between treating the receiver as if it were an instance of the specified class and simply bind the method defined for that class to the message, or waiting until some later time to resolve the situation. In C++, the decision is postponed to link time for methods (member functions) that are declared virtual. Thisissometimesreferred to aslate binding rather than dynamic binding . While dynamic in the sense that it happens at runtime, it carries with it strict compile-time type constraints. As discussed here (and implemented in Objective-C), dynamic binding is unconstrained. Dynamic binding is possible even in the absence of dynamic typing, but it’s not very interesting. There’s little benefit in waiting until runtime to match a method to a message when the class of the receiver is fixed and known to the compiler. The compiler could just as well find the method itself; the runtime result won’t be any different. However, if the class of the receiver is dynamically typed, there’s no way for the compiler to determine which method to invoke. The method can be found only after the class of the receiver isresolved at runtime. Dynamic typing thus entails dynamic binding. Dynamic typing also makes dynamic binding interesting, for it opensthe possibility that a message might have very different results depending on the class of the receiver. Runtime factors can influence the choice of receiver and the outcome of the message. The Object Model Dynamism 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 26Dynamic typing and binding also open the possibility that the code you write can send messages to objects not yet invented. If object types don’t have to be decided until runtime, you can give others the freedom to design their own classes and name their own data types and still have your code send messagesto their objects. All you need to agree on are the messages, not the data types. Note: Dynamic binding is routine in Objective-C. You don’t need to arrange for it specially, so your design never needs to bother with what’s being done when. Dynamic Loading Historically, in many common environments, before a program can run, all its parts had to be linked together in one file. When it was launched, the entire program was loaded into memory at once. Some object-oriented programming environments overcome this constraint and allow different parts of an executable program to be kept in different files. The program can be launched in bits and pieces as they’re needed. Each piece is dynamically loaded and linked with the rest of program as it’s launched. User actions can determine which parts of the program are in memory and which aren’t. Only the core of a large program needs to be loaded at the start. Other modules can be added as the user requests their services. Modules the user doesn’t request make no memory demands on the system. Dynamic loading raisesinteresting possibilities. For example, an entire program does not have to be developed at once. You can deliver your software in pieces and update one part of it at a time. You can devise a program that groups several tools under a single interface, and load just the tools the user wants. The program can even offer sets of alternative tools to do the same job—the user then selects one tool from the set and only that tool would be loaded. Perhaps the most important current benefit of dynamic loading is that it makes applications extensible. You can allow others to add to and customize a program you’ve designed. All your program needs to do is provide a framework that others can fill in, and, at runtime, find the pieces that they’ve implemented and load them dynamically. The main challenge that dynamic loading faces is getting a newly loaded part of a program to work with parts already running, especially when the different parts were written by different people. However, much of this problem disappears in an object-oriented environment because code is organized into logical modules with a clear division between implementation and interface. When classes are dynamically loaded, nothing in the newly loaded code can clash with the code already in place. Each class encapsulates its implementation and has an independent namespace. The Object Model Dynamism 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 27In addition, dynamic typing and dynamic binding let classes designed by othersfit effortlessly into the program you’ve designed. Once a class is dynamically loaded, it’s treated no differently than any other class. Your code can send messages to their objects and theirs to yours. Neither of you has to know what classes the other has implemented. You need only agree on a communications protocol. Loading and linking: Although it’s the term commonly used, dynamic loading could just as well be called dynamic linking . Programs are linked when their various parts are joined so that they can work together; they’re loaded when they’re read into volatile memory at launch time. Linking usually precedes loading. Dynamic loading refers to the process of separately loading new or additional parts of a program and linking them dynamically to the parts already running. The Object Model Dynamism 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 28Object-oriented programs have two kinds of structure. One can be seen in the inheritance hierarchy of class definitions. The other is evident in the pattern of message passing as the program runs. These messages reveal a network of object connections. ● The inheritance hierarchy explains how objects are related by type. For example, in the program that models water use, it might turn out that faucets and pipes are the same kind of object, except that faucets can be turned on and off and pipes can have multiple connections to other pipes. This similarity would be captured in the program design if the Faucet and Pipe classes inherit from a common superclass. ● The network of object connections explains how the program works. For example, Appliance objects might send messages requesting water to valves, and valves to pipes. Pipes might communicate with the Building object, and the Building object with all the valves, faucets, and pipes, but not directly with appliances. To communicate with each other in this way, objects must know about each other. An Appliance object would need a connection to a Valve object, and a Valve object to a Pipe object, and so on. These connections define a program structure. Object-oriented programs are designed by laying out the network of objects with their behaviors and patterns of interaction and by arranging the hierarchy of classes. There’s structure both in the program’s activity and in its definition. Outlet Connections Part of the task of designing an object-oriented program isto arrange the object network. The network doesn’t have to be static; it can change dynamically as the program runs. Relationships between objects can be improvised as needed, and the cast of objects that play assigned roles can change from time to time. But there has to be a script. Some connections can be entirely transitory. A message might contain a parameter identifying an object, perhaps the sender of the message, that the receiver can communicate with. As it responds to the message, the receiver can send messages to that object, perhaps identifying itself or still another object that the object can in turn communicate with. Such connections are fleeting; they last only as long as the chain of messages. 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 29 Structuring ProgramsBut not all connections between objects can be handled on the fly. Some need to be recorded in program data structures. There are various ways to do this. A table might be kept of object connections, or there might be a service that identifies objects by name. However, the simplest way is for each object to have instance variables that keep track of the other objects it must communicate with. These instance variables—termed outlets because they record the outlets for messages—define the principal connections between objects in the program network. Although the names of outlet instance variables are arbitrary, they generally reflect the rolesthat outlet objects play. Figure 4-1 illustrates an object with four outlets—an agent, a friend, a neighbor, and a boss. The objects that play these parts may change every now and then, but the roles remain the same. Figure 4-1 Outlets agent friend neighbor boss Some outlets are set when the object isfirst initialized and may never change. Others might be set automatically asthe consequence of other actions. Still others can be set freely, using methods provided just for that purpose. However they’re set, outlet instance variables reveal the structure of the application. They link objects into a communicating network, much as the components of a water system are linked by their physical connections or as individuals are linked by their patterns of social relations. Extrinsic and Intrinsic Connections Outlet connections can capturemany different kinds of relationships between objects. Sometimesthe connection is between objects that communicate more or less as equal partners in an application, each with its own role to play and neither dominating the other. For example, an Appliance object might have an outlet instance variable to keep track of the valve it’s connected to. Structuring Programs Outlet Connections 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 30Sometimes one object should be seen as being part of another. For example, a Faucet object might use a Meter object to measure the amount of water being released. The Meter object would serve no other object and would act only under orders from the Faucet object. It would be an intrinsic part of the Faucet object, in contrast to an Appliance object’s extrinsic connection to a Valve object. Similarly, an object that oversees other objects might keep a list of its charges. A Building object, for example, might have a list of all the Pipe objects in the program. The Pipe objects would be considered an intrinsic part of the Building object and belong to it. Pipe objects, on the other hand, would maintain extrinsic connections to each other. Intrinsic outlets behave differently from extrinsic ones. When an object is freed or archived in a file on disk, the objects that its intrinsic outlets point to must be freed or archived with it. For example, when a faucet is freed, its meter is rendered useless and therefore should be freed as well. A faucet archived without its meter would be of little use when it’s unarchived (unless it could create a new Meter object for itself). Extrinsic outlets, on the other hand, capture the organization of the program at a higher level. They record connections between relatively independent program subcomponents. When an Appliance object is freed, the Valve object it was connected to still is of use and remains in place. When an Appliance object is unarchived, it can be connected to another valve and resume playing the same sort of role it played before. Activating the Object Network The object network is set into motion by an external stimulus. If you’re writing an interactive application with a user interface, it will respond to user actions on the keyboard and mouse. A program that tries to factor very large numbers might start when you pass it a target number on the command line. Other programs might respond to data received over a phone line, information obtained from a database, or information about the state of a mechanical process the program monitors. Programs often are activated by a flow of events, which are reports of external activity ofsome sort. Applications that display a user interface are driven by events from the keyboard and mouse. Every press of a key or click of the mouse generates events that the application receives and responds to. An object-oriented program structure (a network of objects that’s prepared to respond to an external stimulus) is ideally suited for this kind of user-driven application. Aggregation and Decomposition Another part of the design task is deciding the arrangement of classes—when to add functionality to an existing class by defining a subclass and when to define an independent class. The problem can be clarified by imagining what would happen in the extreme case: Structuring Programs Aggregation and Decomposition 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 31● It’s possible to conceive of a program consisting of just one object. Because it’s the only object, it can send messages only to itself. It therefore can’t take advantage of polymorphism, or the modularity of a variety of classes, or a program design conceived as a network of interconnected objects. The true structure of the program would be hidden inside the class definition. Despite being written in an object-oriented language, there would be very little that was object-oriented about it. ● On the other hand, it’s also possible to imagine a program that consists of hundreds of different kinds of objects, each with very few methods and limited functionality. Here, too, the structure of the program would be lost, this time in a maze of object connections. Obviously, it’s best to avoid either of these extremes, to keep objects large enough to take on a substantial role in the program but small enough to keep that role well-defined. The structure of the program should be easy to grasp in the pattern of object connections. Nevertheless, the question often arises of whether to add more functionality to a class or to factor out the additional functionality and put it in a separate class definition. For example, a Faucet object needs to keep track of how much water is being used over time. To do that, you could either implement the necessary methods in the Faucet class, or you could devise a generic Meter object to do the job, as suggested earlier. Each Faucet object would have an outlet connecting it to a Meter object, and the meter would not interact with any object but the faucet. The choice often depends on your design goals. If the Meter object could be used in more than one situation, perhaps in another project entirely, it would increase the reusability of your code to factor the metering task into a separate class. If you have reason to make Faucet objects as self-contained as possible, the metering functionality could be added to the Faucet class. It’s generally better to try for reusable code and avoid having large classes that do so many things that they can’t be adapted to othersituations. When objects are designed as components, they become that much more reusable. What works in one system or configuration might well work in another. Dividing functionality between different classes doesn’t necessarily complicate the programming interface. If the Faucet class keeps the Meter object private, the Meter interface wouldn’t have to be published for users of the Faucet class; the object would be as hidden as any other Faucet instance variable. Models and Frameworks Objects combine state and behavior, and so resemble things in the real world. Because they resemble real things, designing an object-oriented program is very much like thinking about real things—what they do, how they work, and how one thing is connected to another. Structuring Programs Models and Frameworks 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 32When you design an object-oriented program, you are, in effect, putting together a computer simulation of how something works. Object networks look and behave like models of real systems. An object-oriented program can be thought of as a model, even if there’s no actual counterpart to it in the real world. Each component of the model—each kind of object—is described in terms of its behavior, responsibilities, and interactions with other components. Because an object’s interface lies in its methods, not its data, you can begin the design process by thinking about what a system component must do, not how it’s represented in data. Once the behavior of an object is decided, the appropriate data structure can be chosen, but this is a matter of implementation, not the initial design. For example, in the water-use program, you wouldn’t begin by deciding what the Faucet data structure looked like, but what you wanted a Faucet object to do—make a connection to a pipe, be turned on and off, adjust the rate of flow, and so on. The design is therefore not bound from the outset by data choices. You can decide on the behavior first and implement the data afterwards. Your choice of data structures can change over time without affecting the design. Designing an object-oriented program doesn’t necessarily entail writing great amounts of code. The reusability of class definitions means that the opportunity is great for building a program largely out of classes devised by others. It might even be possible to construct interesting programs entirely out of classes someone else defined. As the suite of class definitions grows, you have more and more reusable parts to choose from. Reusable classes come from many sources. Development projects often yield reusable class definitions, and some enterprising developers market them. Object-oriented programming environments typically come with class libraries. There are well over two hundred classes in the Cocoa libraries. Some of these classes offer basic services (hashing, data storage, remote messaging). Others are more specific (user interface devices, video displays, sound). Typically, a group of library classes work together to define a partial program structure. These classes constitute a software framework (or kit) that can be used to build a variety of different kinds of applications. When you use a framework, you accept the program model it provides and adapt your design to it. You use the framework by: ● Initializing and arranging instances of framework classes ● Defining subclasses of framework classes ● Defining new classes of your own to work with classes defined in the framework In each of these ways, you not only adapt your program to the framework, but you also adapt the generic framework structure to the specialized purposes of your application. The framework, in essence, sets up part of an object network for your program and provides part of its class hierarchy. Your own code completes the program model started by the framework. Structuring Programs Models and Frameworks 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 33Object-oriented programming not only structures programs in a better way, it also helps structure the programming task. As software tries to do more and more, and programs become bigger and more complicated, the problem of managing the task also grows. There are more pieces to fit together and more people working together to build them. The object-oriented approach offers ways of dealing with this complexity, not just in design, but also in the organization of the work. Collaboration Complex software requires an extraordinary collaborative effort among people who must be individually creative, yet still make what they do fit exactly with what others are doing. The sheer size of the effort and the number of people working on the same project at the same time in the same place can get in the way of the group’s ability to work cooperatively towards a common goal. In addition, collaboration is often impeded by barriers of time, space, and organization: ● Code must be maintained, improved, and used long after it’s written. Programmers who collaborate on a project may not be working on it at the same time, so they may not be in a position to talk things over and keep each other informed about details of the implementation. ● Even if programmers work on the same project at the same time, they may not be located in the same place. This also inhibits how closely they can work together. ● Programmers working in different groups with different priorities and different schedules often must collaborate on projects. Communication across organizational barriers isn’t always easy to achieve. The answer to these difficulties must grow out of the way programs are designed and written. It can’t be imposed from the outside in the form of hierarchical management structures and strict levels of authority. These often get in the way of people’s creativity, and become burdensin and of themselves. Rather, collaboration must be built into the work itself. 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 34 Structuring the Programming TaskThat’s where object-oriented programming techniques can help. For example, the reusability of object-oriented code means that programmers can collaborate effectively, even when they work on different projects at different times or are in different organizations, just by sharing their code in libraries. This kind of collaboration holds a great deal of promise, for it can conceivably lighten difficult tasks and make seemingly impossible projects achievable. Organizing Object-Oriented Projects Object-oriented programming helps restructure the programming task in ways that benefit collaboration. It helps eliminate the need to collaborate on low-level implementation details, while providing structures that facilitate collaboration at a higher level. Almost every feature of the object model, from the possibility of large-scale design to the increased reusability of code, has consequences for the way people work together. Designing on a Large Scale When programs are designed at a high level of abstraction, the division of labor is more easily conceived. It can match the division of the program on logical lines; the way a project is organized can grow out of its design. With an object-oriented design, it’s easier to keep common goals in sight, instead of losing them in the implementation, and easier for everyone to see how the piece they’re working on fits into the whole. Their collaborative efforts are therefore more likely to be on target. Separating the Interface from the Implementation The connections between the various components of an object-oriented program are worked out early in the design process. They can be well-defined, at least for the initial phase of development, before implementation begins. During implementation, only this interface needs to be coordinated, and most of that falls naturally out of the design. Because each class encapsulates its implementation and has its own namespace, there’s no need to coordinate implementation details. Collaboration is simpler when there are fewer coordination requirements. Dividing the Work into Modules The modularity of object-oriented programming means that the logical components of a large program can each be implemented separately. Different people can work on different classes. Each implementation task is isolated from the others. Structuring the Programming Task Organizing Object-Oriented Projects 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 35Modularity has benefits, not just for organizing the implementation, but for fixing problems later. Because implementations are contained within class boundaries, problems that come up are also likely to be isolated. It’s easier to track down bugs when they’re located in a well-defined part of the program. Separating responsibilities by class also means that each part can be worked on by specialists. Classes can be updated periodically to optimize their performance and make the best use of new technologies. These updates don’t have to be coordinated with other parts of the program. As long as the interface to an object doesn’t change, improvements to its implementation can be scheduled at any time. Keeping the Interface Simple The polymorphism of object-oriented programs yields simpler programming interfaces, since the same names and conventions can be reused in any number of classes. The result is less to learn, a greater shared understanding of how the whole system works, and a simpler path to cooperation and collaboration. Making Decisions Dynamically Because object-oriented programs make decisions dynamically at runtime, lessinformation needsto be supplied at compile time (in source code) to make two pieces of code work together. Consequently, there’s less to coordinate and less to go wrong. Inheriting Generic Code Inheritance is a way of reusing code. If you can define your classes as specializations of more generic classes, your programming task is simplified. The design is simplified as well, since the inheritance hierarchy lays out the relationships between the different levels of implementation and makes them easier to understand. Inheritance also increases the reusability and reliability of code. The code placed in a superclass is tested by its subclasses. The generic class you find in a library will have been tested by other subclasses written by other developers for other applications. Reusing Tested Code The more software you can borrow from others and incorporate in your own programs, the less you have to do yourself. There’s more software to borrow in an object-oriented programming environment because the code is more reusable. Collaboration between programmers working in different places for different organizations is enhanced, while the burden of each project is eased. Structuring the Programming Task Organizing Object-Oriented Projects 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 36Classes and frameworks from an object-oriented library can make substantial contributions to your program. When you program with the software frameworks provided by Apple, for example, you’re effectively collaborating with the programmers at Apple; you’re contracting a part of your program, often a substantial part, to them. You can concentrate on what you do best and leave other tasks to the library developer. Your projects can be prototyped faster, completed faster, with less of a collaborative challenge at your own site. The increased reusability of object-oriented code also increases its reliability. A class taken from a library is likely to have found its way into a variety of applications and situations. The more the code has been used, the more likely it is that problems will have been encountered and fixed. Bugs that would have seemed strange and hard to find in your program might already have been tracked down and eliminated. Structuring the Programming Task Organizing Object-Oriented Projects 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 37This table describes the changes to Object-Oriented Programming with Objective-C. Date Notes 2010-11-15 Edited for content and clarity. 2008-11-19 Corrected typographical errors. 2007-12-11 Corrected a typographical error. 2007-07-09 Originally published as part of "The Objective-C Programming Language". 2010-11-15 | © 2010 Apple Inc. All Rights Reserved. 38 Document Revision HistoryApple Inc. © 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrievalsystem, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Inc., with the following exceptions: Any person is hereby authorized to store documentation on a single computer for personal use only and to print copies of documentation for personal use provided that the documentation contains Apple’s copyright notice. No licenses, express or implied, are granted with respect to any of the technology described in this document. Apple retains all intellectual property rights associated with the technology described in this document. This document is intended to assist application developers to develop applications only for Apple-labeled computers. Apple Inc. 1 Infinite Loop Cupertino, CA 95014 408-996-1010 Apple, the Apple logo, Cocoa, Mac, and Objective-C are trademarks of Apple Inc., registered in the U.S. and other countries. NeXT is a trademark of NeXT Software, Inc., registered in the U.S. and other countries. Even though Apple has reviewed this document, APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS DOCUMENT, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.ASARESULT, THISDOCUMENT IS PROVIDED “AS IS,” AND YOU, THE READER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL,OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS DOCUMENT, even if advised of the possibility of such damages. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, or employee is authorized to make any modification, extension, or addition to this warranty. Some states do not allow the exclusion or limitation of implied warranties or liability for incidental or consequential damages, so the above limitation or exclusion may not apply to you. This warranty gives you specific legal rights, and you may also have other rights which vary from state to state. Table View Programming Guide for iOSContents About Table Views in iOS Apps 8 At a Glance 9 Table Views Draw Their Rows Using Cells 9 Responding to Selections of Rows 9 In Editing Mode You Can Add, Delete, and Reorder Rows 10 To Create a Table View, Use a Storyboard 10 Prerequisites 11 See Also 11 Table View Styles and Accessory Views 12 Table View Styles 12 Plain Table Views 13 Grouped Table Views 15 Standard Styles for Table View Cells 17 Accessory Views 21 Overview of the Table View API 23 Table View 23 Table View Controller 23 Data Source and Delegate 23 Extension to the NSIndexPath Class 24 Table View Cells 24 Navigating a Data Hierarchy with Table Views 25 Hierarchical Data Models and Table Views 25 The Data Model as a Hierarchy of Model Objects 25 Table Views and the Data Model 26 View Controllers and Navigation-Based Apps 28 Navigation Controllers 28 Navigation Bars 29 Table View Controllers 31 Managing Table Views in a Navigation-Based App 32 Design Pattern for Navigation-Based Apps 35 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 2Creating and Configuring a Table View 36 Basics of Table View Creation 36 Recommendations for Creating and Configuring Table Views 38 Creating a Table View Using a Storyboard 38 Choose the Table View’s Display Style 39 Choose the Table View’s Content Type 40 Design the Table View’s Rows 42 Create Additional Table Views 42 Learn More by Creating a Sample App 43 Creating a Table View Programmatically 43 Adopt the Data Source and Delegate Protocols 43 Create and Configure a Table View 44 Populating a Dynamic Table View with Data 44 Populating a Static Table View With Data 46 Populating an Indexed List 47 Optional Table View Configurations 52 Add a Custom Title 52 Provide a Section Title 53 Indent a Row 53 Vary a Row’s Height 54 Customize Cells 54 A Closer Look at Table View Cells 55 Characteristics of Cell Objects 55 Using Cell Objects in Predefined Styles 57 Customizing Cells 60 Loading Table View Cells from a Storyboard 61 Programmatically Adding Subviews to a Cell’s Content View 69 Cells and Table View Performance 73 Managing Selections 74 Selections in Table Views 74 Responding to Selections 74 Programmatically Selecting and Scrolling 78 Inserting and Deleting Rows and Sections 80 Inserting and Deleting Rows in Editing Mode 81 When a Table View is Edited 81 An Example of Deleting a Table-View Row 84 An Example of Adding a Table-View Row 85 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 3 ContentsBatch Insertion, Deletion, and Reloading of Rows and Sections 87 An Example of Batched Insertion and Deletion Operations 88 Ordering of Operations and Index Paths 89 Managing the Reordering of Rows 91 What Happens When a Row is Relocated 92 Examples of Moving a Row 93 Document Revision History 95 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 4 ContentsFigures and Listings About Table Views in iOS Apps 8 Figure I-1 Table views of various kinds 8 Table View Styles and Accessory Views 12 Figure 1-1 A table view in the plain style 13 Figure 1-2 A table view configured as an indexed list 14 Figure 1-3 A table view configured as a selection list 15 Figure 1-4 A table view in the grouped style 16 Figure 1-5 Header and footer of a section 17 Figure 1-6 Default table row style 18 Figure 1-7 Table row style with a subtitle under the title 19 Figure 1-8 Table row style with a right-aligned subtitle 20 Figure 1-9 Table row style in Contacts format 21 Navigating a Data Hierarchy with Table Views 25 Figure 3-1 Mapping levels of the data model to table views 27 Figure 3-2 Navigation controller and view controllers in a navigation-based app 29 Figure 3-3 Navigation bars and common control items 30 Figure 3-4 A storyboard with two table view controllers 33 Listing 3-1 Passing data to a destination view controller 34 Listing 3-2 Passing data to a source view controller 34 Creating and Configuring a Table View 36 Figure 4-1 Calling sequence for creating and configuring a table view 37 Figure 4-2 The master view controller in the Master-Detail Application storyboard 39 Figure 4-3 A dynamic table view 40 Figure 4-4 A static table view 41 Listing 4-1 Adopting the data source and delegate protocols 43 Listing 4-2 Creating a table view 44 Listing 4-3 Populating a dynamic table view with data 45 Listing 4-4 Populating a static table view with data 46 Listing 4-5 Defining the model-object interface 48 Listing 4-6 Loading the table-view data and initializing the model objects 48 Listing 4-7 Preparing the data for the indexed list 49 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 5Listing 4-8 Providing section-index data to the table view 50 Listing 4-9 Populating the rows of an indexed list 51 Listing 4-10 Adding a title to the table view 52 Listing 4-11 Returning a title for a section 53 Listing 4-12 Custom indentation of a row 53 Listing 4-13 Varying row height 54 A Closer Look at Table View Cells 55 Figure 5-1 Parts of a table view cell 55 Figure 5-2 Parts of a table-view cell in editing mode 56 Figure 5-3 Default cell content in a UITableViewCell object 57 Figure 5-4 A table view with rows showing both images and text 58 Figure 5-5 Table view cells in a storyboard 61 Figure 5-6 Table view rows drawn with a custom prototype cell 62 Figure 5-7 Table view rows drawn with multiple cells 66 Figure 5-8 Making connections to your static cell content 68 Figure 5-9 Cells with custom content as subviews 70 Listing 5-1 Configuring a UITableViewCell object with both image and text 58 Listing 5-2 Alternating the background color of cells 60 Listing 5-3 Adding data to a cell using tags 63 Listing 5-4 Adding data to a cell using outlets 65 Listing 5-5 Defining outlet properties for static cell objects 66 Listing 5-6 Setting the data in the user interface 68 Listing 5-7 Adding subviews to a cell’s content view 70 Managing Selections 74 Listing 6-1 Responding to a row selection 75 Listing 6-2 Setting a switch object as an accessory view and responding to its action message 75 Listing 6-3 Managing a selection list—exclusive list 77 Listing 6-4 Managing a selection list—inclusive list 77 Listing 6-5 Programmatically selecting a row 78 Inserting and Deleting Rows and Sections 80 Figure 7-1 Calling sequence for inserting or deleting rows in a table view 82 Figure 7-2 Deletion of section and row and insertion of row 90 Listing 7-1 View controller responding to setEditing:animated: 84 Listing 7-2 Customizing the editing style of rows 84 Listing 7-3 Updating the data-model array and deleting the row 85 Listing 7-4 Adding an Add button to the navigation bar 85 Listing 7-5 Responding to a tap on the Add button 86 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 6 Figures and ListingsListing 7-6 Adding the new item to the data-model array 86 Listing 7-7 Batch insertion and deletion methods 87 Listing 7-8 Inserting and deleting a block of rows in a table view 88 Managing the Reordering of Rows 91 Figure 8-1 Reordering a row 91 Figure 8-2 Calling sequence for reordering a row in a table view 92 Listing 8-1 Excluding a row from relocation 93 Listing 8-2 Updating the data-model array for the relocated row 94 Listing 8-3 Retargeting the destination row of a move operation 94 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 7 Figures and ListingsTable views are versatile user interface objects frequently found in iOS apps. A table view presents data in a scrollable list of multiple rows that may be divided into sections. Table views have many purposes: ● To let users navigate through hierarchically structured data ● To present an indexed list of items ● To display detail information and controls in visually distinct groupings ● To present a selectable list of options Figure I-1 Table views of various kinds A table view has only one column and allows vertical scrolling only. It consists of rows in sections. Each section can have a header and a footer that displaystext or an image. However, many table views have only one section with no visible header or footer. Programmatically, the UIKit framework identifies rows and sections through their index number: Sections are numbered 0 through n – 1 from the top of a table view to the bottom; rows are numbered 0 through n – 1 within a section. A table view can have its own header and footer, distinct from any section; the table header appears before the first row of the first section, and the table footer appears after the last row of the last section. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 8 About Table Views in iOS AppsAt a Glance A table view is an instance of the UITableView class in one of two basic styles, plain or grouped. A plain table view is an unbroken list; a grouped table view has visually distinct sections. A table view has a data source and might have a delegate. The data source object provides the data for populating the sections and rows of the table view. The delegate object customizes its appearance and behavior. Related chapters: “Table View Styles and Accessory Views” (page 12) Table Views Draw Their Rows Using Cells A table view draws its visible rows using cells—that is, UITableViewCell objects. Cells are views that can display text, images, or other kinds of content. They can have background views for both normal and selected states. Cells can also have accessory views, which function as controls for selecting or setting an option. The UIKit framework defines four standard cell styles, each with its own layout of the three default content elements: main label, detail label, and image. You may also create your own custom cellsto acquire a distinctive style for your app’s table views. When you configure the attributes of a table view in the storyboard editor, you choose between two types of cell content: static cells or dynamic prototypes. ● Static cells. Use static cells to design a table with a fixed number of rows, each with its own layout. Use static cells when you know what the table looks like at design time, regardless of the specific information it displays. ● Dynamic prototypes. Use dynamic prototypes to design one cell and then use it as the template for other cells in the table. Use a dynamic prototype when multiple cells in a table should use the same layout to display information. Dynamic prototype content is managed by the data source at runtime, with an arbitrary number of cells. Related Chapters: “Table View Styles and Accessory Views” (page 12), “A Closer Look at Table View Cells” (page 55) Responding to Selections of Rows When users select a row (by tapping it), the delegate of the table view is informed via a message. The delegate is passed the indexes of the row and the section that the row is in. It uses this information to locate the corresponding item in the app’s data model. This item might be at an intermediate level in the hierarchy of About Table Views in iOS Apps At a Glance 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 9data or it might be a “leaf node" in the hierarchy. If the item is at an intermediate level, the app displays a new table view. If the item is a leaf node, the app displays details about the selected item in a grouped-style table view or some other kind of view. In table views that list a series of options, tapping a row simply selects its associated option. No subsequent view of data is displayed. Related Chapters: “Navigating a Data Hierarchy with Table Views” (page 25), “Managing Selections” (page 74) In Editing Mode You Can Add, Delete, and Reorder Rows Table views can enter an editing mode in which users can insert or delete rows, or relocate them within the table. In editing mode, rows that are marked for insertion or deletion display a green plus sign (insertion) or a red minus sign (deletion) near the left edge of the row. If users touch a deletion control or, in some table views, swipe across a row, a red Delete button appears, prompting usersto delete that row. Rowsthat can be relocated display (near their right edge) an image consisting of several horizontal lines. When the table view leaves editing mode, the insertion, deletion, and reordering controls disappear. When users attempt to insert, delete, or reorder rows, the table view sends a sequence of messages to its data source and delegate so that they can manage these operations. Related Chapters: “Inserting and Deleting Rows and Sections” (page 80), “Managing the Reordering of Rows” (page 91) To Create a Table View, Use a Storyboard The easiest and recommended way to create and manage a table view is to use a custom UITableViewController object in a storyboard. If your app is based largely on table views, create your Xcode project using the Master-Detail Application template. This template includes an initial custom UITableViewController class and a storyboard for the scenes in the user interface, including the custom view controller and its table view. In the storyboard editor, choose one of the two styles for this table view and design its content. At runtime, UITableViewController creates the table view and assigns itself as delegate and data source. Immediately after it’s created, the table view asks its data source for the number of sections, the number of rows in each section, and the table view cell to use to draw each row. The data source manages the application data used for populating the sections and rows of the table view. About Table Views in iOS Apps At a Glance 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 10Related Chapters: “Navigating a Data Hierarchy with Table Views” (page 25), “Creating and Configuring a Table View” (page 36) Prerequisites Before reading this document, you should read Start Developing iOS Apps Today to understand the basic process for developing iOS apps. Then read View Controller Programming Guide for iOS for a comprehensive look at view controllers and storyboards. Finally, to gain valuable hands-on experience using table views in a storyboard, read the tutorial Your Second iOS App: Storyboards. The information presented in this introduction and in “Table View Styles and Accessory Views” (page 12) summarizes prescriptive information on table views presented in iOS Human Interface Guidelines. You can find a complete description of the styles and characteristics of table views, as well as their recommended uses, in the chapter “iOS UI Element Usage Guidelines”. See Also You will find the following sample code projects to be instructive models for your own table view implementations: ● SimpleDrillDown project ● Table View Animations and Gestures project For guidance on how to use the standard container view controllers provided by UIKit, see View Controller Catalog for iOS . This document describes split view controllers and navigation controllers, which can both contain table view controllers as children. About Table Views in iOS Apps Prerequisites 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 11Table views come in distinctive styles that are suitable for specific purposes. In addition, the UIKit framework provides standard styles for the cells used to draw the rows of table views. It also gives you standard accessory views (that is, controls) that you can include in cells. Table View Styles There are two major styles of table views: plain and grouped. The two styles are distinguished mainly by appearance. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 12 Table View Styles and Accessory ViewsPlain Table Views A table view in the plain (or regular) style displays rows that stretch across the screen and have a creamy white background (see Figure 1-1). A plain table view can have one or more sections, sections can have one or more rows, and each section can have its own header or footer title. (A header or footer may also have a custom view, for instance one containing an image). When the user scrolls through a section with many rows, the header of the section floats to the top of the table view and the footer of the section floats to the bottom. Figure 1-1 A table view in the plain style A variation of plain table views associates an index with sections for quick navigation; Figure 1-2 shows an example of this kind of table view, which is called an indexed list. The index runs down the right edge of the table view. Entries in the index correspond to section header titles. Touching an item in the index scrolls the table view to the associated section. For example, the section headings could be two-letterstate abbreviations, Table View Styles and Accessory Views Table View Styles 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 13and the rows for a section could be the cities in that state; touching at a certain spot in the index displays the cities for the selected state. The rows in indexed lists should not have disclosure indicators or detail disclosure buttons, because these interfere with the index. Figure 1-2 A table view configured as an indexed list Table View Styles and Accessory Views Table View Styles 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 14The simplest kind of table view is a selection list (see Figure 1-3). A selection list is a plain table view that presents a menu of optionsthat users can select. It can limit the selection to one row or allow multiple selections. A selection list marks a selected row with a checkmark (see Figure 1-3). Figure 1-3 A table view configured as a selection list Grouped Table Views A grouped table view also displays a list of information, but it groups related rows in visually distinct sections. As shown in Figure 1-4, each section has rounded corners and by default appears against a bluish-gray background. Each section may have text or an image for its header or footer to provide some context or Table View Styles and Accessory Views Table View Styles 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 15summary for the section. A grouped table works especially well for displaying the most detailed information in a data hierarchy. It allows you to separate detailsinto conceptual groups and provide contextual information to help users understand it quickly. Figure 1-4 A table view in the grouped style Table View Styles and Accessory Views Table View Styles 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 16The headers and footers of sections in a grouped table view have relative locations and sizes as indicated in Figure 1-5. Figure 1-5 Header and footer of a section Padding Padding Header Table cell Footer On iPad devices, a grouped table view automatically gets wider margins when the table view itself is wide. Standard Styles for Table View Cells In addition to defining two styles of table views, the UIKit framework defines four styles for the cells that a table view uses to draw its rows. You may create custom table view cells with different appearances if you want, but these four predefined cell styles are suitable for most purposes. The techniques for creating table view cells in a predefined style and for creating custom cells are described in “A Closer Look at Table View Cells” (page 55). Table View Styles and Accessory Views Standard Styles for Table View Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 17The defaultstyle for table view rows uses a simple cellstyle that has a single title and an optional image (Figure 1-6). This style is associated with the UITableViewCellStyleDefault constant. Figure 1-6 Default table row style Table View Styles and Accessory Views Standard Styles for Table View Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 18The cell style for the rows in Figure 1-7 left-aligns the main title and puts a gray subtitle under it. It also permits an image in the default image location. This style is associated with the UITableViewCellStyleSubtitle constant. Figure 1-7 Table row style with a subtitle under the title Table View Styles and Accessory Views Standard Styles for Table View Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 19The cell style for the rows in Figure 1-8 left-aligns the main title. It puts the subtitle in blue text and right-aligns it on the right side of the row. Images are not permitted. This style is used in the Settings app, where the subtitle indicatesthe currentsetting for a preference. It is associated with the UITableViewCellStyleValue1 constant. Figure 1-8 Table row style with a right-aligned subtitle Table View Styles and Accessory Views Standard Styles for Table View Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 20The cell style for the rows in Figure 1-9 puts the main title in blue and right-aligns it at a point that’s indented from the left side of the row. The subtitle is left aligned at a short distance to the right of this point. This style does not allow images. It is used in the Contacts part of the Phone app and is associated with the UITableViewCellStyleValue2 constant. Figure 1-9 Table row style in Contacts format Accessory Views There are three standard kinds of accessory views (shown with their accessory-type constants): Standard accessory views Description Disclosure indicator—UITableViewCellAccessoryDisclosureIndicator. You use the disclosure indicator when selecting a cell results in the display of another table view reflecting the next level in the data model hierarchy. Detail disclosure button—UITableViewCellAccessoryDetailDisclosureButton. You use the detail disclosure button when selecting a cell resultsin a detail view of that item (which may or may not be a table view). Table View Styles and Accessory Views Accessory Views 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 21Standard accessory views Description Checkmark—UITableViewCellAccessoryCheckmark. You use a checkmark when a touch on a row results in the selection of that item. This kind of table view is known as a selection list, and it is analogous to a pop-up list. Selection lists can limit selections to one row, or they can allow multiple rows with checkmarks. Instead of the standard accessory views, you may specify a control (for example, a switch) or a custom view as the accessory view. Table View Styles and Accessory Views Accessory Views 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 22The table view programming interface includesseveral UIKit classes, two formal protocols, and a category added to a Foundation framework class. Table View A table view itself is an instance of the UITableView class. You use its methods to configure the appearance of the table view—for example,specifying the default height of rows or providing a subview used asthe header for the table. Other methods give you access to the currently selected row as well as specific rows or cells. You can call other methods of UITableView to manage selections, scroll the table view, and insert or delete rows and sections. UITableView inherits from the UIScrollView class, which defines scrolling behavior for views with content larger than the size of the window. UITableView redefines the scrolling behavior to allow vertical scrolling only. Table View Controller The UITableViewController class manages a table view and addssupport for many standard table-related behaviors such as selection management, row editing, table configuration, and others. This additional support is there to minimize the amount of code you have to write to create and initialize your table-based interface. You don’t use this class directly—instead you subclass UITableViewController to add custom behaviors. Data Source and Delegate A UITableView object must have a delegate and a data source. Following the Model-View-Controller design pattern, the data source mediates between the app’s data model (that is, its model objects) and the table view. The delegate, on the other hand, manages the appearance and behavior of the table view. The data source and the delegate are often (but not necessarily) the same object, and that object is usually a custom subclass of UITableViewController. (See “Navigating a Data Hierarchy with Table Views” (page 25) for further information.) 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 23 Overview of the Table View APIThe data source adoptsthe UITableViewDataSource protocol. UITableViewDataSource hastwo required methods. The tableView:numberOfRowsInSection: method tellsthe table view how many rowsto display in each section, and the tableView:cellForRowAtIndexPath: method provides the cell to display for each row in the table. Optional methods allow the data source to configure multiple sections, provide headers and/or footers, and support adding, removing, and reordering rows in the table. The delegate adoptsthe UITableViewDelegate protocol. This protocol has no required methods. It declares methods that allow the delegate to modify visible aspects of the table view, manage selections, support an accessory view, and support editing of individual rows in a table. An app can make use of the convenience class UILocalizedIndexedCollation to help the data source organize the data for indexed lists and display the proper section when users tap an item in the index. The UILocalizedIndexedCollation class also localizes section titles. Extension to the NSIndexPath Class Many table view methods use index paths as parameters or return values. An index path identifies a path to a specific node in a tree of nested arrays, and in the Foundation framework it isrepresented by an NSIndexPath object. UIKit declares a category on NSIndexPath with methods that return key paths, locate rows in sections, and construct NSIndexPath objects from row and section indexes. For more information, see NSIndexPath UIKit Additions. Table View Cells As noted in “Data Source and Delegate” (page 23), the data source must return a cell object for each visible row that a table view displays. These cell objects must inherit from the UITableViewCell class. This class includes methodsfor managing cellselection and editing, managing accessory views, and configuring the cell. You can instantiate cells directly in the standard styles defined by the UITableViewCell class and give these cells content consisting of one or two strings of text and, in some styles, both image and text. Instead of using a cell in a standard style, you can put your own custom subviews in the content view of an “off-the-shelf” cell object. You may also subclass UITableViewCell to customize the appearance and behavior of table view cells. These approaches are all discussed in “A Closer Look at Table View Cells” (page 55). Overview of the Table View API Extension to the NSIndexPath Class 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 24A common use of table views—and one to which they’re ideally suited—is to navigate hierarchies of data. A table view at a top level of the hierarchy lists categories of data at the most general level. Users select a row to “drill down” to the next level in the hierarchy. At the bottom of the hierarchy is a view (often a table view) that presents details about a specific item (for example, an address book record) and may allow users to edit the item. This section explains how you can map the levels of the data model hierarchy to a succession of table views and describes how you can use the facilities of the UIKit framework to help you implement such navigation-based apps. Hierarchical Data Models and Table Views For a navigation-based app, you typically design your app data as a graph of model objects that is sometimes referred to as the app’s data model. You can then implement the model layer of your app using various mechanisms or technologies, including Core Data, property lists, or archives of custom objects. Regardless of the approach, the traversal of your app’s data model follows patterns that are common to all navigation-based apps. The data model has hierarchical depth, and objects at variouslevels of this hierarchy should be the source for populating the rows of a table view. Note: To learn about the Core Data technology and framework, see Core Data Starting Point. The Data Model as a Hierarchy of Model Objects A well-designed app factors its classes and objects in a way that conforms to the Model-View-Controller (MVC) design pattern. The app’s data model consists of the model objects in this pattern. You can describe model objects (using the terminology provided by the object modeling pattern) in terms of their properties. These properties are of two general kinds: attributes and relationships. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 25 Navigating a Data Hierarchy with Table ViewsNote: The notion of “property” here is abstractly related to, but not identical with, the declared property feature of Objective-C. A class definition typically represents properties programmatically through instance variables and declared properties. For more on declared properties, see The Objective-C Programming Language . To find out more about MVC and object modeling, read “Cocoa Design Patterns” in Cocoa Fundamentals Guide . Attributes represent elements of model-object data. Attributes can range from an instance of a primitive class (for example, an NSString, NSDate, or UIColor object) to a C structure or a simple scalar value. Attributes are generally what you use to populate a table view that represents a “leaf node” of the data hierarchy and that presents a detail view of that item. A model object may also have relationships with other model objects. It is through these relationships that a data model acquires hierarchical depth by composing an object graph. Relationships are of two general kinds in terms of cardinality: to-one and to-many. To-one relationships define an object’s relationship with another object (for example, a parent relationship). A to-many relationship, on the other hand, defines an object’s relationship with multiple objects of the same kind. The to-many relationship is characterized by containment and can be programmatically represented by collections such as NSArray objects (or, simply, arrays). An array might contain other arrays, or it could contain multiple dictionaries, which are collections that identify their contained valuesthrough keys. Dictionaries, in turn, can contain one or more other collections, including arrays, sets, and even other dictionaries. As collections nest in other collections, your data model can acquire hierarchical depth. Table Views and the Data Model The rows of a plain table view are typically backed by collection objects of the app’s data model; these objects are usually arrays. Arrays contain strings or other elements that a table view can use when displaying row content. When you create a table view (described in “Creating and Configuring a Table View” (page 36)), it immediately queries its data source for its dimensions—that is, it requests the number of sections and the number of rows per section—and then asks for the content of each row. The data source fetches this content from an array in the appropriate level of the data-model hierarchy. In many of the methods defined for a table view’s data source and delegate, the table view passes in an index path to identify the section and row that is the focus of the current operation—for example, fetching content for a row or indicating the row the user tapped. An index path is an instance of the Foundation framework’s NSIndexPath classthat you can use to identify an item in a tree of nested arrays. The UIKit framework extends NSIndexPath to add a section and a row property to the class. The data source should use these properties to map a section and row of the table view to a value at the corresponding index of the array being used as the table view’s source of data. Navigating a Data Hierarchy with Table Views Hierarchical Data Models and Table Views 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 26Note: The UIKit framework extension of the NSIndexPath class is described in NSIndexPath UIKit Additions. In the sequence of table views in Figure 3-1, the top level of the data hierarchy is an array of four arrays, with each inner array containing objects representing the trails for a particular region. When the user selects one of these regions, the next table view lists names identifying the trails within the selected array. When the user selects a particular trail, the next table view describes that trail using a grouped table view. Figure 3-1 Mapping levels of the data model to table views "Name" = "Sylvan Trail Loop" "Location" = "Edgewood City Park (Redwood City)" "Distance" = 2 "Difficulty" = "Moderate" "Restrictions" = "No bicycles, pets, or horses" "Map" = pen_map6.png // other key/value pairs Alambique-Skyline Sweeny Ridge Sawyer Camp Trail Purisima Creek Dean-Crystal Springs Sylvan Trail Loop regions array trails array trail dictionary East Bay North Bay Peninsula South Bay Navigating a Data Hierarchy with Table Views Hierarchical Data Models and Table Views 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 27Note: You could easily redesign the app in Figure 3-1 (page 27) to have only two table views. The first table view would be an indexed list of trails by region. The second table view would display the detail for a selected trail. View Controllers and Navigation-Based Apps The UIKit framework provides a number of view controller classesfor managing common user interface patterns in iOS. View controllers are controller objects that inherit from the UIViewController class. They are an essential tool for view management, especially when an app uses those views to present successive levels of its data hierarchy. This section describes how two subclasses of UIViewController, navigation controllers and table view controllers, present and manage a succession of table views. Note: Thissection gives an overview of view controllersto provide some background for the coding tasks discussed later in this document. To learn about view controllers in depth, see View Controller Programming Guide for iOS . Navigation Controllers The UINavigationController classinheritsfromUIViewController, a base classthat definesthe common programmatic interface and behavior for controller objects that manage views in iOS. Through inheritance from this base class, a view controller acquires an interface for general view management. After it implements parts of thisinterface, a view controller can autorotate its view, respond to low-memory notifications, overlay “modal” views, respond to taps on the Edit button, and otherwise manage the view. A navigation controller maintains a stack of view controllers, one for each of the table views displayed (see Figure 3-2). It begins with what’s known as the root view controller. When the user taps a row of the table view (often on a detail disclosure button), the root view controller pushes the next view controller onto the stack. The new view controller’s table view visually slides into place from the right, and the navigation bar Navigating a Data Hierarchy with Table Views View Controllers and Navigation-Based Apps 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 28items are updated appropriately. When users tap the back button in the navigation bar, the current view controller is popped off the stack. As a consequence, the navigation controller displaysthe table view managed by the view controller that is now at the top of the stack. Figure 3-2 Navigation controller and view controllers in a navigation-based app UITableView UIViewController UINavigationController UINavigationBar Navigation Bars Navigation bars are a user-interface device that enables users to navigate a hierarchy of data. Users start with general, top-level items and “drill down” the hierarchy to detailed viewsshowing specific properties of leaf-node items. The view below the navigation bar presents the current level of data. A navigation bar includes a title for the current view and, if that view is lower in the hierarchy than the top level, a back button on the left side of the bar; the back button is a navigation control that the user taps to return to the previous level. (The back Navigating a Data Hierarchy with Table Views View Controllers and Navigation-Based Apps 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 29button by default displaysthe title for the previous view.) A navigation bar may also have an Edit button—used to enter editing mode for the current view—or custom buttons for functions that manage content (see Figure 3-3). Figure 3-3 Navigation bars and common control items Navigational control Controls to manage content A UINavigationController manages the navigation bar, including the items that are displayed in the bar for the view below it. A UIViewController object manages a view displayed below the navigation bar. For this view controller, you create a subclass of UIViewController or a subclass of a view controller class that the UIKit framework provides for managing a particular type of view. For table views, this view controller class is UITableViewController. For a navigation controller that displays a sequence of table views reflecting levels within a data hierarchy, you need to create a separate custom table view controller for each table view. The UIViewController class includes methods that let view controllers access and set the navigation items displayed in the navigation bar for the currently displayed table view. This class also declares a title property through which you can set the title of the navigation bar for the current table view. Navigating a Data Hierarchy with Table Views View Controllers and Navigation-Based Apps 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 30Table View Controllers Although you could manage a table view using a direct subclass of UIViewController, you save yourself a lot of work if instead you subclass UITableViewController. The UITableViewController class takes care of many of the details you would have to implement if you created a directsubclass of UIViewController to manage a table view. The recommended way to create a table view controller is to specify it in a storyboard. The associated table view isloaded from the storyboard, along with the table view’s attributes,size, and autoresizing characteristics. The table view controller sets itself as the data source and the delegate of the table view. Note: You can create a table view controller programmatically by allocating memory for it and initializing it with the initWithStyle: method, passing in either UITableViewStylePlain or UITableViewStyleGrouped for the required table view style. When the table view is about to appear for the first time, the table view controller sends reloadData to the table view, which prompts it to request data from its data source. The data source tells the table view how many sections and rows per section it wants, and then gives the table view the data to display in each row. This process is described in “Creating and Configuring a Table View” (page 36). The UITableViewController class also performs other common tasks. It clears selections when the table view is about to be displayed and flashes the scroll indicators when the table finishes displaying. In addition, it responds properly when users tap the Edit button by putting the table view into editing mode (or taking it out of editing mode if users tap Done). The class exposes one property, tableView, which gives you access to the managed table view. Note: A table view controller supports inline editing of table view rows; if, for example, rows have embedded text fields in editing mode, it scrolls the row being edited above the virtual keyboard that is displayed. It also supports the NSFetchedResultsController class for managing the results returned from a Core Data fetch request. The UITableViewController class implements the foregoing behavior by overriding loadView, viewWillAppear:, and other methods inherited from UIViewController. In your subclass of UITableViewController, you may also override these methods to acquire specialized behavior. If you do override these methods, be sure to invoke the superclass implementation of the method, usually as the first method call, to get the default behavior. Navigating a Data Hierarchy with Table Views View Controllers and Navigation-Based Apps 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 31Note: You should use a UIViewController subclass rather than a subclass of UITableViewController to manage a table view if the view to be managed is composed of multiple subviews, only one of which is a table view. The default behavior of the UITableViewController class is to make the table view fill the screen between the navigation bar and the tab bar (if either are present). If you decide to use a UIViewController subclass rather than a subclass of UITableViewController to manage a table view, you should perform a couple of the tasks mentioned above to conform to the human interface guidelines. To clear any selection in the table view before it’s displayed, implement the viewWillAppear: method to clear the selected row (if any) by calling deselectRowAtIndexPath:animated:. After the table view has been displayed, you should flash the scroll view’sscroll indicators by sending a flashScrollIndicators message to the table view; you can do this in an override of the viewDidAppear: method of UIViewController. Managing Table Views in a Navigation-Based App A UITableViewController object—or any other object that assumes the roles of data source and delegate for a table view—must respond to messages sent by the table view in order to populate its rows, configure it, respond to selections, and manage editing sessions. In the rest of this document, you learn how to do these things. However, there are certain other things you need to do to ensure the proper display of a sequence of table views in a navigation-based app. Note: Thissection summarizes view-controller and navigation-controller tasks, with a focus on table views. For a thorough discussion of view controllers and navigation controllers, including the complete details of their implementation, see View Controller Programming Guide for iOS and View Controller Catalog for iOS . At this point, let’s assume that a table view managed by a table view controller presents a list to the user. How does the app display the next table view in the sequence? When a user taps a row of the table view, the table view callsthe tableView:didSelectRowAtIndexPath: or tableView:accessoryButtonTappedForRowWithIndexPath:method implemented by the delegate. (That latter method is invoked if the user taps a row’s detail disclosure button.) The delegate creates the table view controller managing the next table view in the sequence, sets the data it needs to populate its table view, and pushes this new view controller onto the navigation controller’s stack of view controllers. A storyboard provides the specification that allows UIKit to perform most of this work for you. Navigating a Data Hierarchy with Table Views View Controllers and Navigation-Based Apps 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 32Storyboards represent the screens in an app and the transitions between them. The storyboard in a basic app may contain just a few screens, but a more complex app might have multiple storyboards, each of which represents a different subset of its screens. The storyboard example in Figure 3-4 presents a graphical representation of each scene, its contents, and its connections. Figure 3-4 A storyboard with two table view controllers A scene represents an onscreen content area that is managed by a view controller. (In the context of a storyboard, scene and view controller are synonymous terms.) The leftmost scene in the default storyboard represents a navigation controller. A navigation controller is a container view controller because, in addition to its views, it also manages a set of other view controllers. For example, the navigation controller in Figure 3-4 (page 33) manages the master and detail view controllers, in addition to the navigation bar and the back button that you see when you run the app. A relationship is a type of connection between scenes. In Figure 3-4, there is a relationship between the navigation controller and the master scene. In this case, the relationship represents the containment of the master and detailscenes by the navigation controller. When the app runs, the navigation controller automatically loads the master scene and displays the navigation bar at the top of the screen. A segue represents a transition from one scene (called the source) to the next scene (called the destination). For example, in Figure 3-4, the master scene is the source and the detail scene is the destination. When you select the Detail item in the master list, you trigger a segue from the source to the destination. In this case, the segue is a push segue, which means that the destination scene slides over the source scene from right to left. As the detail screen is revealed, a back button appears at the left end of the navigation bar, titled with the previous screen’s title (in this case, “Master”). The back button is provided automatically by the navigation controller that manages the master-detail hierarchy. Navigating a Data Hierarchy with Table Views View Controllers and Navigation-Based Apps 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 33Storyboards make it easy to pass data from one scene to another via the prepareForSegue:sender: method of the UIViewController class. This method is called when the first scene (the source) is about to transition to the next scene (the destination). The source view controller can implement prepareForSegue:sender: to perform setup tasks, such as passing information to the destination view controller about what it should display in its table view. Listing 3-1 shows one implementation of this method. Listing 3-1 Passing data to a destination view controller - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"ShowDetails"]) { MyDetailViewController *detailViewController = [segue destinationViewController]; NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; detailViewController.data = [self.dataController objectInListAtIndex:indexPath.row]; } } A segue represents a one-way transition from a source scene to a destination scene. One of the consequences of this design is that you can use a segue to pass data to a destination, but you can’t use a segue to send data from a destination to its source. To solve this problem, you create a delegate protocol that declares methods that the destination view controller calls when it needs to pass back some data. Listing 3-2 shows one implementation of a protocol for passing data back to a source view controller. Listing 3-2 Passing data to a source view controller @protocol MyAddViewControllerDelegate - (void)addViewControllerDidCancel:(MyAddViewController *)controller; - (void)addViewControllerDidFinish:(MyAddViewController *)controller data:(NSString *)item; @end - (void)addViewControllerDidCancel:(MyAddViewController *)controller { [self dismissViewControllerAnimated:YES completion:NULL]; } Navigating a Data Hierarchy with Table Views View Controllers and Navigation-Based Apps 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 34- (void)addViewControllerDidFinish:(MyAddViewController *)controller data:(NSString *)item { if ([item length]) { [ self.dataController addData:item]; [[self tableView] reloadData]; } [self dismissViewControllerAnimated:YES completion:NULL]; } Note: The full details of creating storyboards are described in Xcode 4 User Guide . To learn more about using view controllers in storyboards, see View Controller Programming Guide for iOS . Design Pattern for Navigation-Based Apps A navigation-based app with table views should follow these design best practices: ● A view controller (typically a subclass of UITableViewController), acting in the role of data source, populates its table view with data from an object representing a level of the data hierarchy. When the table view displays a list of items, the object is typically an array. When the table view displays item detail (that is, a leaf node of the data hierarchy), the object can be a custom model object, a Core Data managed object, a dictionary, or something similar. ● The view controller stores the data it needs for populating its table view. The view controller can use this data directly for populating the table view, or it can use it to fetch or otherwise obtain the necessary data. When you design your view controller subclass, you should define a property to hold this data. View controllers should not obtain the data for their table view through a global variable or a singleton objectsuch asthe app delegate. Such direct dependencies make your code lessreusable and more difficult to test and debug. ● The current view controller on top of the navigation-controller stack creates the next view controller in the sequence and, before it pushes it onto the stack, sets the data that this view controller, acting as data source, needs to populate its table view. Navigating a Data Hierarchy with Table Views Design Pattern for Navigation-Based Apps 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 35Your app must present a table view to users before it can manage it in response to taps on rows and other actions. This chapter shows what you must do to create a table view, configure it, and populate it with data. Most of the code examples shown in this chapter come from the sample projects TableViewSuite and TheElements. Basics of Table View Creation To create a table view, several entities in an app must interact: the view controller, the table view itself, and the table view’s data source and delegate. The view controller, data source, and delegate are usually the same object. The view controller starts the calling sequence, diagrammed in Figure 4-1 (page 37). 1. The view controller creates a UITableView instance in a certain frame and style. It can do this either programmatically or in a storyboard. The frame is usually set to the screen frame, minus the height of the status bar or, in a navigation-based app, to the screen frame minus the heights of the status bar and the navigation bar. The view controller may also set global properties of the table view at this point, such as its autoresizing behavior or a global row height. To learn how to create table views in a storyboard and programmatically, see “Creating a Table View Using a Storyboard” (page 38) and “Creating a Table View Programmatically” (page 43). 2. The view controllersetsthe data source and delegate of the table view and sends a reloadData message to it. The data source must adopt the UITableViewDataSource protocol, and the delegate must adopt the UITableViewDelegate protocol. 3. The data source receives a numberOfSectionsInTableView: message from the UITableView object and returns the number of sections in the table view. Although this is an optional protocol method, the data source must implement it if the table view has more than one section. 4. For each section, the data source receives a tableView:numberOfRowsInSection: message and responds by returning the number of rows for the section. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 36 Creating and Configuring a Table View5. The data source receives a tableView:cellForRowAtIndexPath: message for each visible row in the table view. It responds by configuring and returning a UITableViewCell object for each row. The UITableView object uses this cell to draw the row. Figure 4-1 Calling sequence for creating and configuring a table view tableView: cellForRowAtIndexPath: Set data source and delegate Client Data Source Table View initWithFrame:style: numberOfSectionsInTableView: tableView:numberOfRowsInSection: The diagram in Figure 4-1 shows the required protocol methods as well as the numberOfSectionsInTableView: method. Populating the table view with data occurs in steps 3 through 5. To learn how to implement the methods in these steps, see “Populating a Dynamic Table View with Data” (page 44). The data source and the delegate may implement other optional methods of their protocolsto further configure the table view. For example, the data source might want to provide titles for each of the sections in the table view by implementing the tableView:titleForHeaderInSection: method. For more on some of these optional table view customizations, see “Optional Table View Configurations” (page 52). You create a table view in either the plain style (UITableViewStylePlain) or the grouped style (UITableViewStyleGrouped). (You specify the style in a storyboard.) Although the procedure for creating a table view in eitherstylesisidentical, you may want to perform different kinds of configurations. For example, because a grouped table view generally presents item detail, you may also want to add custom accessory views (for example, switches and sliders) or custom content (for example, text fields). For an example, see “A Closer Look at Table View Cells” (page 55). Creating and Configuring a Table View Basics of Table View Creation 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 37Recommendations for Creating and Configuring Table Views There are many ways to put together a table view app. For example, you can use an instance of a custom NSObject subclass to create, configure, and manage a table view. However, you will find the task much easier if you adopt the classes, techniques, and design patterns that the UIKit framework offers for this purpose. The following approaches are recommended: ● Use an instance of a subclass of UITableViewController to create and manage a table view. Most apps use a custom UITableViewController object to manage a table view. As described in “Navigating a Data Hierarchy with Table Views” (page 25), UITableViewController automatically creates a table view, assignsitself as both delegate and data source (and adoptsthe corresponding protocols), and initiates the procedure for populating the table view with data. It also takes care of several other “housekeeping” details of behavior. The behavior of UITableViewController (a subclass of UIViewController) within the navigation controller architecture is described in “Table View Controllers” (page 31). ● If your app is largely based on table views, select the Master-Detail Application template provided by Xcode when you create your project. As described in “Creating a Table View Using a Storyboard” (page 38), the template includes stub code and a storyboard defining an app delegate, the navigation controller, and the master view controller (which is an instance of a custom subclass of UITableViewController). ● For successive table views, you should implement custom UITableViewController objects. You can either load them from a storyboard or create the associated table views programmatically. Although either option is possible, the storyboard route is generally easier. If the view to be managed is a composite view in which a table view is one of multiple subviews, you must use a custom subclass of UIViewController to manage the table view (and other views). Do not use UITableViewController, because this controller class sizes the table view to fill the screen between the navigation bar and the tab bar (if either is present). Creating a Table View Using a Storyboard Create an app with a table view using Xcode. When you create your project, select a template that contains stub code and a storyboard that, by default, supply the structure for setting up and managing table views. To create an app structured around table views 1. In Xcode, choose File > New > Project. Creating and Configuring a Table View Recommendations for Creating and Configuring Table Views 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 382. In the iOS section at the left side of the dialog, select Application. 3. In the main area of the dialog, select Master-Detail Application and then click Next. 4. Choose your project options (make sure Use Storyboard is selected), and then click Next. 5. Choose a save location for your project and then click Create. Depending on which device family you chose in step 4, the project has one or two storyboards. To display the storyboard canvas, double-click a storyboard file in the project navigator. If the device family is iPhone, for example, your storyboard should contain a table view controller that looks similar to the one in Figure 4-2. Figure 4-2 The master view controller in the Master-Detail Application storyboard To make sure that the scene on the canvas represents the master view controller class in your code 1. On the canvas, click the scene’s title bar to select the table view controller. 2. Click the Identity button at the top of the utility area to open the Identity inspector. 3. Verify that the Class field contains the project’s custom subclass of UITableViewController. Choose the Table View’s Display Style As described in “Table View Styles” (page 12), every table view has a display style: plain or grouped. To choose the display style of a table view in a storyboard 1. Click the center of the scene to select the table view. Creating and Configuring a Table View Creating a Table View Using a Storyboard 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 392. In the utility area, display the Attributes inspector. 3. In the Table View section of the Attributes inspector, use the Style pop-up menu to choose Plain or Grouped. Choose the Table View’s Content Type Storyboards introduce two convenient ways to design a table view’s content: ● Dynamic prototypes. Design a prototype cell and then use it as the template for other cells in the table. Use a dynamic prototype when multiple cells in a table should use the same layout to display information. Dynamic content is managed by the table view data source (the table view controller) at runtime, with an arbitrary number of cells. Figure 4-3 shows a plain table view with a one prototype cell. Figure 4-3 A dynamic table view Note: If a table view in a storyboard is dynamic, the custom subclass of UITableViewController that contains the table view needs to implement the data source protocol. For more information, see “Populating a Dynamic Table View with Data” (page 44). Creating and Configuring a Table View Creating a Table View Using a Storyboard 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 40● Static cells. Use static content to design the overall layout of the table, including the total number of cells. A table view with static content has a fixed set of cells that you can configure at design time. You can also configure otherstatic data elementssuch assection headers. Use static cells when a table does not change its layout, regardless of the specific information it displays. Figure 4-4 shows a grouped table view with three static cells. Figure 4-4 A static table view Note: If a table view in a storyboard isstatic, the custom subclass of UITableViewController that contains the table view should not implement the data source protocol. Instead, the table view controllershould use its viewDidLoad method to populate the table view’s data. For more information, see “Populating a Static Table View With Data” (page 46). By default, when you add a table view controller to a storyboard, the controller contains a table view that uses prototype-based cells. If you want to use static cells: 1. Select the table view. 2. Display the Attributes inspector. 3. In the the Content pop-up menu, choose Static Cells. Creating and Configuring a Table View Creating a Table View Using a Storyboard 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 41If you’re designing a prototype cell, the table view needs a way to identify the prototype when the data source dequeues reusable cells for the table at runtime. Therefore you must assign a reuse identifier to the cell. In the Table View Cell section of the Attributes inspector, enter an ID in the Identifier text field. By convention, a cell’s reuse identifier should describe what the cell contains, such as BirdSightingCell. Design the Table View’s Rows As described in “Standard Styles for Table View Cells” (page 17), UIKit defines four styles for the cells that a table view uses to draw its rows. You can use one of the four standard styles, design a custom style, or subclass UITableViewCell to define additional behavior or properties for the cell. This topic is covered in detail in “A Closer Look at Table View Cells” (page 55). A table view cell can also have an accessory, as described in “Accessory Views” (page 21). An accessory is a standard user interface element that UIKit draws at the right end of a table cell. For example, the disclosure indicator, which looks similar to a right angle bracket (>), tells users that tapping an item reveals related information in a new screen. In the Attributes inspector, use the Accessory pop-up menu to select a cell’s accessory. Create Additional Table Views If your app displays and manages more than one table view, add those table views to your storyboard. You add a table view by adding a custom UITableViewController object, which contains the table view it manages. To add custom class files to your project 1. In Xcode, choose File > New > File. 2. In the iOS section at the left side of the dialog, select Cocoa Touch. 3. In the main area of the dialog, select Objective-C class, and then click Next. 4. Enter a name for your new class, choose subclass of UITableViewController, and then click Next. 5. Choose a save location for your class files, and then click Create. To add a table view controller to a storyboard 1. Display the storyboard to which you want to add the table view controller. 2. Drag a table view controller out of the object library and drop it on the storyboard. 3. With the new scene still selected on the canvas, click the Identity button in the utility area to open the Identity inspector. Creating and Configuring a Table View Creating a Table View Using a Storyboard 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 424. In the Custom Class section, choose the new custom class in the Class pop-up menu. 5. Set the new table view’s style and cell content (dynamic or static). 6. Create a segue to the new scene. The details of step 7 vary depending on the project. To learn more about adding segues, see Xcode 4 User Guide . Note: Populating a table view with data and configuring a table view are discussed in “Populating a Dynamic Table View with Data” (page 44) and “Optional Table View Configurations” (page 52). Learn More by Creating a Sample App The tutorial Your Second iOS App: Storyboards shows how to create a sample app that is structured around table views. After you complete the steps in this tutorial, you’ll have a working knowledge of how to create both dynamic and static table views using a storyboard. The tutorial creates a basic navigation-based app called BirdWatching that uses table view controllers connected by both push and modal segues. Creating a Table View Programmatically If you choose not to use UITableViewController for table view management, you must replicate what this class gives you “for free.” Adopt the Data Source and Delegate Protocols The class creating the table view typically makes itself the data source and delegate by adopting the UITableViewDataSource and UITableViewDelegate protocols. The adoption syntax appears just after the superclass in the @interface directive, as shown in Listing 4-1. Listing 4-1 Adopting the data source and delegate protocols @interface RootViewController : UIViewController @property (nonatomic, strong) NSArray *timeZoneNames; @end Creating and Configuring a Table View Creating a Table View Programmatically 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 43Create and Configure a Table View The next step is for the client to allocate and initialize an instance of the UITableView class. Listing 4-2 gives an example of a client that creates a UITableView object in the plain style, specifies its autoresizing characteristics, and then sets itself to be both data source and delegate. Again, keep in mind that the UITableViewController does all of this for you automatically. Listing 4-2 Creating a table view - (void)loadView { UITableView *tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain]; tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; tableView.delegate = self; tableView.dataSource = self; [tableView reloadData]; self.view = tableView; } Because in this example the class creating the table view is a subclass of UIViewController, it assigns the created table view to its view property, which it inherits from that class. It also sends a reloadData message to the table view, causing the table view to initiate the procedure for populating its sections and rows with data. Populating a Dynamic Table View with Data Just after a table view object is created, it receives a reloadData message, which tells it to start querying the data source and delegate for the information it needs for the sections and rows it displays. The table view immediately asks the data source for its logical dimensions—that is, the number of sections and the number of rows in each section. It then repeatedly invokes the tableView:cellForRowAtIndexPath: method to get a cell object for each visible row; it uses this UITableViewCell object to draw the content of the row. (Scrolling a table view also causes an invocation of tableView:cellForRowAtIndexPath: for each newly visible row.) Creating and Configuring a Table View Populating a Dynamic Table View with Data 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 44As noted in “Choose the Table View’s Content Type” (page 40), if the table view is dynamic then you need to implement the required data source methods. Listing 4-3 shows an example of how the data source and the delegate could configure a dynamic table view. Listing 4-3 Populating a dynamic table view with data - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [regions count]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Number of rows is the number of time zones in the region for the specified section. Region *region = [regions objectAtIndex:section]; return [region.timeZoneWrappers count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { // The header for the section is the region name -- get this from the region at the section index. Region *region = [regions objectAtIndex:section]; return [region name]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyReuseIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]]; } Region *region = [regions objectAtIndex:indexPath.section]; Creating and Configuring a Table View Populating a Dynamic Table View with Data 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 45TimeZoneWrapper *timeZoneWrapper = [region.timeZoneWrappers objectAtIndex:indexPath.row]; cell.textLabel.text = timeZoneWrapper.localeName; return cell; } The data source, in its implementation of the tableView:cellForRowAtIndexPath: method, returns a configured cell object that the table view can use to draw a row. For performance reasons, the data source tries to reuse cells as much as possible. It first asks the table view for a specific reusable cell object by sending it a dequeueReusableCellWithIdentifier: message. If no such object exists, the data source creates it, assigning it a reuse identifier. The data source sets the cell’s content (in this example, its text) and returns it. “A Closer Look at Table View Cells” (page 55) discusses this data source method and UITableViewCell objects in more detail. If the dequeueReusableCellWithIdentifier: method asks for a cell that’s defined in a storyboard, the method always returns a valid cell. If there is not a recycled cell waiting to be reused, the method creates a new one using the information in the storyboard itself. This eliminates the need to check the return value for nil and create a cell manually. The implementation of the tableView:cellForRowAtIndexPath: method in Listing 4-3 includes an NSIndexPath argument that identifies the table view section and row. UIKit declares a category of the NSIndexPath class, which is defined in the Foundation framework. This category extends the class to enable the identification of table view rows by section and row number. For more information on this category, see NSIndexPath UIKit Additions. Populating a Static Table View With Data As noted in “Choose the Table View’s Content Type” (page 40), if a table view is static then you should not implement any data source methods. The configuration of the table view is known at compile time, so UIKit can get this information from the storyboard at runtime. However, you still need to populate a static table view with data from your data model. “Populating a Static Table View With Data” shows an example of how a table view controller could load user data in a static table view. This example is adapted from Your Second iOS App: Storyboards. Listing 4-4 Populating a static table view with data - (void)viewDidLoad { Creating and Configuring a Table View Populating a Static Table View With Data 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 46[super viewDidLoad]; BirdSighting *theSighting = self.sighting; static NSDateFormatter *formatter = nil; if (formatter == nil) { formatter = [[NSDateFormatter alloc] init]; [formatter setDateStyle:NSDateFormatterMediumStyle]; } if (theSighting) { self.birdNameLabel.text = theSighting.name; self.locationLabel.text = theSighting.location; self.dateLabel.text = [formatter stringFromDate:(NSDate*)theSighting.date]; } } The table view is populated with data in the UIViewController method viewDidLoad, which is called after the view is loaded into memory. The data is passed to the table view controller in the sighting object, which isset in the previous view controller’s prepareForSegue:sender: method. The properties birdNameLabel, locationLabel, and dateLabel are outlets connected to labelsin the static table view (see Figure 4-4 (page 41)). Populating an Indexed List An indexed list (see Figure 1-2 (page 14)) is ideally suited for navigating large amounts of data organized by a conventional ordering scheme such as an alphabet. An indexed list is a table view in the plain style that is specially configured through three UITableViewDataSource methods: ● sectionIndexTitlesForTableView: Returns an array of the strings to use as the index entries (in order). ● tableView:titleForHeaderInSection: Maps these index strings to the titles of the table view’s sections (they don’t have to be the same). ● tableView:sectionForSectionIndexTitle:atIndex: Returns the section index related to the entry the user tapped in the index. Creating and Configuring a Table View Populating an Indexed List 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 47The data you use to populate an indexed list should be organized to reflect this indexing model. Specifically, you need to build an array of arrays. Each inner array corresponds to a section in the table. Section arrays are sorted (or collated) within the outer array according to the prevailing ordering scheme, which is often an alphabetical scheme (for example, A through Z). Additionally, the items in each section array are sorted. You can build and sort this array of arrays yourself, but fortunately the UILocalizedIndexedCollation class greatly simplifies the tasks of building and sorting these data structures and providing data to the table view. The class also collates items in the arrays according to the current localization. However you internally manage this array-of-arrays structure is up to you. The objects to be collated should have a property or method that returns a string value that the UILocalizedIndexedCollation class uses in collation; if it is a method, it should have no parameters. You might find it convenient to define a custom model class whose instances represent the rows in the table view. These model objects not only return a string value but also define a property that holdsthe index of the section array to which the object is assigned. Listing 4-5 illustrates the definition of a class that declares a name property and a sectionNumber property. Listing 4-5 Defining the model-object interface @interface State : NSObject @property(nonatomic,copy) NSString *name; @property(nonatomic,copy) NSString *capitol; @property(nonatomic,copy) NSString *population; @property NSInteger sectionNumber; @end Before your table view controller is asked to populate the table view, you load the data to be used (from whatever source) and create instances of your model class from this data. The example in Listing 4-6 loads data defined in a property list and creates the model objects from that. It also obtains the shared instance of UILocalizedIndexedCollation and initializes the mutable array (states) that will contain the section arrays. Listing 4-6 Loading the table-view data and initializing the model objects - (void)viewDidLoad { [super viewDidLoad]; UILocalizedIndexedCollation *theCollation = [UILocalizedIndexedCollation currentCollation]; self.states = [NSMutableArray arrayWithCapacity:1]; Creating and Configuring a Table View Populating an Indexed List 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 48NSString *thePath = [[NSBundle mainBundle] pathForResource:@"States" ofType:@"plist"]; NSArray *tempArray; NSMutableArray *statesTemp; if (thePath && (tempArray = [NSArray arrayWithContentsOfFile:thePath]) ) { statesTemp = [NSMutableArray arrayWithCapacity:1]; for (NSDictionary *stateDict in tempArray) { State *aState = [[State alloc] init]; aState.name = [stateDict objectForKey:@"Name"]; aState.population = [stateDict objectForKey:@"Population"]; aState.capitol = [stateDict objectForKey:@"Capitol"]; [statesTemp addObject:aState]; } } else { return; } After the data source has this “raw” array of model objects, it can process it with the facilities of the UILocalizedIndexedCollation class. In Listing 4-7, the code is annotated with numbers. Listing 4-7 Preparing the data for the indexed list // viewDidLoad continued... // (1) for (State *theState in statesTemp) { NSInteger sect = [theCollation sectionForObject:theState collationStringSelector:@selector(name)]; theState.sectionNumber = sect; } // (2) NSInteger highSection = [[theCollation sectionTitles] count]; NSMutableArray *sectionArrays = [NSMutableArray arrayWithCapacity:highSection]; for (int i = 0; i < highSection; i++) { NSMutableArray *sectionArray = [NSMutableArray arrayWithCapacity:1]; [sectionArrays addObject:sectionArray]; } Creating and Configuring a Table View Populating an Indexed List 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 49// (3) for (State *theState in statesTemp) { [(NSMutableArray *)[sectionArrays objectAtIndex:theState.sectionNumber] addObject:theState]; } // (4) for (NSMutableArray *sectionArray in sectionArrays) { NSArray *sortedSection = [theCollation sortedArrayFromArray:sectionArray collationStringSelector:@selector(name)]; [self.states addObject:sortedSection]; } } // end of viewDidLoad Here's what the code in Listing 4-7 does: 1. The data source enumerates the array of model objects and sends sectionForObject:collationStringSelector: to the collation manager on each iteration. This method takes as arguments a model object and a property or method of the object that it usesin collation. Each call returns the index of the section array to which the model object belongs, and that value is assigned to the sectionNumber property. 2. The data source source then creates a (temporary) outer mutable array and mutable arraysfor each section; it adds each created section array to the outer array. 3. It then enumerates the array of model objects and adds each object to its assigned section array. 4. The data source enumerates the array of section arrays and calls sortedArrayFromArray:collationStringSelector: on the collation manager to sort the items in each array. It passes in a section array and a property or method that is to be used in sorting the items in the array. Each sorted section array is added to the final outer array. Now the data source is ready to populate its table view with data. It implements the methods specific to indexed lists as shown in Listing 4-8. In doing this it calls two UILocalizedIndexedCollation methods: sectionIndexTitles and sectionForSectionIndexTitleAtIndex:. Also note that in tableView:titleForHeaderInSection: itsuppresses any headersfrom appearing in the table view when the associated section does not have any items. Listing 4-8 Providing section-index data to the table view - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { Creating and Configuring a Table View Populating an Indexed List 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 50return [[UILocalizedIndexedCollation currentCollation] sectionIndexTitles]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if ([[self.states objectAtIndex:section] count] > 0) { return [[[UILocalizedIndexedCollation currentCollation] sectionTitles] objectAtIndex:section]; } return nil; } - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { return [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index]; } Finally, the data source should implement the UITableViewDataSource methods that are common to all table views. Listing 4-9 gives examples of these implementations, and illustrates how to use the section and row properties of the table view–specific category of the NSIndexPath class described in NSIndexPath UIKit Additions. Listing 4-9 Populating the rows of an indexed list - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.states count]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[self.states objectAtIndex:section] count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"StateCell"; Creating and Configuring a Table View Populating an Indexed List 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 51UITableViewCell *cell; cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]]; } State *stateObj = [[self.states objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; cell.textLabel.text = stateObj.name; return cell; } For table views that are indexed lists, when the data source assigns cells for rows in tableView:cellForRowAtIndexPath:, it should ensure that the accessoryType property of the cell is set to UITableViewCellAccessoryNone. After initially populating the table view following the procedure outlined above, you can reload the contents of the index by calling the reloadSectionIndexTitles method. Optional Table View Configurations The table view API allows you to configure various visual and behavioral aspects of a table view, including specific rows and sections. The following examples serve to give you some idea of the options available to you. Add a Custom Title In the same block of code that createsthe table view, you can apply global configurations using certain methods of the UITableView class. The code example in Listing 4-10 adds a custom title for the table view (using a UILabel object). Listing 4-10 Adding a title to the table view - (void)loadView { CGRect titleRect = CGRectMake(0, 0, 300, 40); UILabel *tableTitle = [[UILabel alloc] initWithFrame:titleRect]; Creating and Configuring a Table View Optional Table View Configurations 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 52tableTitle.textColor = [UIColor blueColor]; tableTitle.backgroundColor = [self.tableView backgroundColor]; tableTitle.opaque = YES; tableTitle.font = [UIFont boldSystemFontOfSize:18]; tableTitle.text = [curTrail objectForKey:@"Name"]; self.tableView.tableHeaderView = tableTitle; [self.tableView reloadData]; } Provide a Section Title The example in Listing 4-11 returns a title string for a section. Listing 4-11 Returning a title for a section - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { // Returns section title based on physical state: [solid, liquid, gas, artificial] return [[[PeriodicElements sharedPeriodicElements] elementPhysicalStatesArray] objectAtIndex:section]; } Indent a Row The code in Listing 4-12 moves a specific row to the next level of indentation. Listing 4-12 Custom indentation of a row - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath { if ( indexPath.section==TRAIL_MAP_SECTION && indexPath.row==0 ) { return 2; } return 1; } Creating and Configuring a Table View Optional Table View Configurations 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 53Vary a Row’s Height The example in Listing 4-13 varies the height of a specific row based on its index value. Listing 4-13 Varying row height - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGFloat result; switch ([indexPath row]) { case 0: { result = kUIRowHeight; break; } case 1: { result = kUIRowLabelHeight; break; } } return result; } Customize Cells You can also affect the appearance of rows by returning custom UITableViewCell objects with specially formatted subviews for content in tableView:cellForRowAtIndexPath:. Cell customization is discussed in “A Closer Look at Table View Cells” (page 55). Creating and Configuring a Table View Optional Table View Configurations 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 54A table view uses cell objects to draw its visible rows and then caches those objects as long as the rows are visible. Cells inherit from the UITableViewCell class. The table view’s data source provides the cell objects to the table view by implementing the tableView:cellForRowAtIndexPath: method, a required method of the UITableViewDataSource protocol. In this chapter, you’ll learn about: ● The characteristics of cells ● How to use the default capabilities of UITableViewCell for setting cell content ● How to create custom UITableViewCell objects Characteristics of Cell Objects A cell object has various parts, which can change depending on the mode of the table view. Normally, most of a cell object is reserved for its content: text, image, or any other kind of distinctive identifier. Figure 5-1 shows the major parts of a cell. Figure 5-1 Parts of a table view cell Cell content Accessory view The smaller area on the rightside of the cell isreserved for accessory views: disclosure indicators, detail disclosure controls, control objects such as sliders or switches, and custom views. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 55 A Closer Look at Table View CellsWhen the table view goes into editing mode, the editing control for each cell object (if it’s configured to have such a control) appears on its left side, in the area shown in Figure 5-2. Figure 5-2 Parts of a table-view cell in editing mode Editing control Cell content Reordering control The editing control can be either a deletion control (a red minus sign inside a circle) or an insertion control (a green plus sign inside a circle). The cell’s content is pushed toward the right to make room for the editing control. If the cell object is configured for reordering (that is, relocation within the table view), the reordering control appearsin the rightside of the cell, next to any accessory view specified for editing mode. The reordering control is a stack of horizontal lines; to relocate a row within itstable view, users press on the reordering control and drag the cell. If a cell object isreusable—the typical case—you assign it a reuse identifier (an arbitrary string) in the storyboard. At runtime, the table view stores cell objects in an internal queue. When the table view asks the data source to configure a cell object for display, the data source can access the queued object by sending a dequeueReusableCellWithIdentifier: message to the table view, passing in a reuse identifier. The data source sets the content of the cell and any special properties before returning it. This reuse of cell objects is a performance enhancement because it eliminates the overhead of cell creation. With multiple cell objects in a queue, each with its own identifier, you can have table views constructed from cell objects of different types. For example, some rows of a table view can have content based on the image and text properties of a UITableViewCell in a predefined style, while other rows can be based on a customized UITableViewCell that defines a special format for its content. When providing cells for the table view, there are three general approaches you can take. You can use ready-made cell objects in a range of styles, you can add your own subviews to the cell object’s content view (which can be done in Interface Builder), or you can use cell objects created from a custom subclass of UITableViewCell. Note that the content view is a container of other views and so displays no content itself. A Closer Look at Table View Cells Characteristics of Cell Objects 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 56Using Cell Objects in Predefined Styles Using the UITableViewCell class directly, you can create “off-the-shelf” cell objects in a range of predefined styles. “Standard Styles for Table View Cells” (page 17) describes these standard cells and provides examples of how they look in a table view. These cells are associated with the following enum constants, declared in UITableViewCell.h: typedef enum { UITableViewCellStyleDefault, UITableViewCellStyleValue1, UITableViewCellStyleValue2, UITableViewCellStyleSubtitle } UITableViewCellStyle; These cell objects have two kinds of content: one or more text strings and, in some cases, an image. Figure 5-3 shows the approximate areas for image and text. As an image expands to the right, it pushes the text in the same direction. Figure 5-3 Default cell content in a UITableViewCell object Image Text Cell content Accessory view The UITableViewCell class defines three properties for this cell content: ● textLabel—A label for the title (a UILabel object) ● detailTextLabel—A label for the subtitle if there is additional detail (a UILabel object) ● imageView—An image view for an image (a UIImageView object) Because the first two of these properties are labels, you can set the font, alignment, line-break mode, and color of the associated text through the properties defined by the UILabel class (including the color of text when the row is highlighted). For the image view property, you can also set an alternative image for when the cell is highlighted using the highlightedImage property of the UIImageView class. A Closer Look at Table View Cells Using Cell Objects in Predefined Styles 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 57Figure 5-4 gives an example of a table view whose rows are drawn using a UITableViewCell object in the UITableViewCellStyleSubtitle style; it includes both an image and, for textual content, a title and a subtitle. Figure 5-4 A table view with rows showing both images and text Listing 5-1 showsthe implementation of tableView:cellForRowAtIndexPath: that createsthe table view rows in Figure 5-4 (page 58). The first thing the data source should do is send dequeueReusableCellWithIdentifier: to the table view, passing in a reuse identifier. If a prototype for the cell existsin a storyboard, the table view returns a reusable cell object. Then itsetsthe cell object’s content, both text and image. Listing 5-1 Configuring a UITableViewCell object with both image and text - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"]]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } A Closer Look at Table View Cells Using Cell Objects in Predefined Styles 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 58NSDictionary *item = (NSDictionary *)[self.content objectAtIndex:indexPath.row]; cell.textLabel.text = [item objectForKey:@"mainTitleKey"]; cell.detailTextLabel.text = [item objectForKey:@"secondaryTitleKey"]; NSString *path = [[NSBundle mainBundle] pathForResource:[item objectForKey:@"imageKey"] ofType:@"png"]; UIImage *theImage = [UIImage imageWithContentsOfFile:path]; cell.imageView.image = theImage; return cell; } The table view’s data source implementation of tableView:cellForRowAtIndexPath: should always reset all content when reusing a cell. When you configure a UITableViewCell object, you can also set various other properties, including (but not limited to) the following: ● selectionStyle—Controls the appearance of the cell when selected. ● accessoryType and accessoryView—Allow you to set one of the standard accessory views(disclosure indicator or detail disclosure control) or a custom accessory view for a cell in normal (nonediting) mode. For a custom view, you may provide any UIView object, such as a slider, a switch, or a custom view. ● editingAccessoryType and editingAccessoryView—Allow you to set one of the standard accessory views (disclosure indicator or detail disclosure control) or a custom accessory view for a cell in editing mode. For a custom view, you may provide any UIView object, such as a slider, a switch, or a custom view. ● showsReorderControl—Specifies whether it shows a reordering control when in editing mode. The related but read-only editingStyle property specifies the type of editing control the cell has (if any). The delegate returns the value of the editingStyle property in its implementation of the tableView:editingStyleForRowAtIndexPath: method. ● backgroundView and selectedBackgroundView—Provide a background view (when a cell is unselected and selected) to display behind all other views of the cell. ● indentationLevel and indentationWidth—Specify the indentation level for cell content and the width of each indentation level. Because a table view cell inherits from UIView, you can also affect its appearance and behavior by setting the properties defined by that superclass. For example, to affect a cell’s background color, you could set its backgroundColor property. Listing 5-2 shows how you might use the delegate method tableView:willDisplayCell:forRowAtIndexPath: to alternate the background color of rows(via their backing cells) in a table view. A Closer Look at Table View Cells Using Cell Objects in Predefined Styles 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 59Listing 5-2 Alternating the background color of cells - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row%2 == 0) { UIColor *altCellColor = [UIColor colorWithWhite:0.7 alpha:0.1]; cell.backgroundColor = altCellColor; } } Listing 5-2 also illustrates an important aspect of the table view API. A table view sends a tableView:willDisplayCell:forRowAtIndexPath: message to its delegate just before it draws a row. If the delegate chooses to implement this method, it can make last-minute changes to the cell object before it is displayed. With this method, the delegate should change only state-based properties that were set earlier by the table view, such as selection and background color, and not content. Customizing Cells The four predefined styles of UITableViewCell objects suffice for most of the rows that table views display. With these ready-made cell objects, rows can include one or two styles of text, often an image, and an accessory view of some sort. The application can modify the text in its font, color, and other characteristics, and it can supply an image for the row in its selected state as well as its normal state. Asflexible and useful asthis cell content is, it might notsatisfy the requirements of all applications. For example, the labels permitted by a native UITableViewCell object are pinned to specific locations within a row, and the image must appear on the left side of the row. If you want the cell to have different content components and to have these laid out in different locations, or if you want different behavioral characteristics for the cell, you have two alternatives: ● Add subviews to a cell’s content view. ● Create a custom subclass of UITableViewCell. The following sections discuss both approaches. A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 60Loading Table View Cells from a Storyboard In a storyboard, the cells in a table view are dynamic or static. With dynamic content, the table view is a list with a large (and potentially unbounded) number of rows. With static content, the number of rowsis a finite quantity that’s known at compile time. A table view that presents a detail view of an item is a good candidate for static content. You can design dynamic or static cell content directly inside a table view object. Figure 5-5 shows the master and detail table viewsin a simple storyboard. In this example, the master table view contains dynamic prototype cells, and the detail table view contains static cells. Figure 5-5 Table view cells in a storyboard The following sections demonstrate how to load data into table views that contain custom-configured cells. A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 61The Technique for Dynamic Row Content In this section, you compose a custom prototype cell in a storyboard. At runtime, the data source dequeues cells, prepares them, and gives them to its table view for drawing the rows depicted in Figure 5-6. Figure 5-6 Table view rows drawn with a custom prototype cell The data source can use two different ways to access the subviews of the cells. One approach uses the tag property defined by UIView and the other approach uses outlets. Using tags is convenient, although it makes the code more fragile because it introduces a coupling between the tag numbers in the storyboard and the code. Using outlets requires a little more work because you need to define a custom subclass of UITableViewCell. Both approaches are described here. To create a project that uses a storyboard to load custom table view cells 1. Create a project using the Master-Detail Application template and select the Use Storyboards option. 2. On the storyboard canvas, select the master view controller. 3. In the Identity inspector, verify that Class is set to the custom MasterViewController class. 4. Select the table view inside the master view controller. 5. In the Attributes inspector, verify that the Content pop-up menu is set to Dynamic Prototypes. 6. Select the prototype cell. 7. In the Attributes inspector, choose Custom in the Style pop-up menu. A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 628. Enter a reuse identifier in the Identifier text field. This is the same reuse identifier you send to the table view in the dequeueReusableCellWithIdentifier: message. For an example, see Listing 5-3. 9. Choose Disclosure Indicator in the Accessory pop-up menu. 10. Drag objects from the Library onto the cell. For this example, drag two label objects and position them near the ends of the cell (leaving room for the accessory view). 11. Select the objects and set their attributes, sizes, and autoresizing characteristics. An important attribute to set for the programmatic portion of this procedure is each object’s tag property. Find this property in the View section of the Attributes inspector and assign each object a unique integer. Now write the code you would normally write to obtain the table view’s data. (For this example, the only data you need is the row number of each cell.) Implement the data source method tableView:cellForRowAtIndexPath: to create a new cell from the prototype and populate it with data, in a manner similar to Listing 5-3. Listing 5-3 Adding data to a cell using tags - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; UILabel *label; label = (UILabel *)[cell viewWithTag:1]; label.text = [NSString stringWithFormat:@"%d", indexPath.row]; label = (UILabel *)[cell viewWithTag:2]; label.text = [NSString stringWithFormat:@"%d", NUMBER_OF_ROWS - indexPath.row]; return cell; } A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 63There are a few aspects of this code to note: ● The string identifier you assign to the prototype cell is the same string you pass to the table view in dequeueReusableCellWithIdentifier:. ● Because the prototype cell is defined in a storyboard, the dequeueReusableCellWithIdentifier: method always returns a valid cell. You don’t need to check the return value against nil and create a cell manually. ● The code gets the labels in the cell by calling viewWithTag:, passing in their tag integers. It can then set the textual content of the labels. If you prefer not to use tags, you can use an alternative method for setting the content in the cell. Define a custom UITableViewCell subclass with outlet properties for the objects you want to set. In the storyboard, associate the new class with the prototype cell and connect the outlets to the corresponding objects in the cell. To use outlets for the custom cell content 1. Add an Objective-C class named MyTableViewCell to your project. 2. Add the following code to the interface in MyTableViewCell.h: @interface MyTableViewCell : UITableViewCell @property (nonatomic, weak) IBOutlet UILabel *firstLabel; @property (nonatomic, weak) IBOutlet UILabel *secondLabel; @end 3. Add the following code to the implementation in MyTableViewCell.m: @synthesize firstLabel, secondLabel; 4. Add the following line of code to the source file that implements the data source: #import "MyTableViewCell.h" 5. Use the Identity inspector to set the Class of the prototype cell to MyTableViewCell. A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 646. Use the Connections inspector to connect the two outlets in the prototype cell to their corresponding labels. 7. Implement the data source method tableView:cellForRowAtIndexPath: in a manner similar to Listing 5-4. Listing 5-4 Adding data to a cell using outlets - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; cell.firstLabel.text = [NSString stringWithFormat:@"%d", indexPath.row]; cell.secondLabel.text = [NSString stringWithFormat:@"%d", NUMBER_OF_ROWS - indexPath.row]; return cell; } The code gains access to the labels in the cell using accessor methods (dot notation is used here). The code can then set the textual content of the labels. A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 65The Technique for Static Row Content In this section, you compose several cells in a table view with static content. At runtime, when the table view is loaded from the storyboard, the table view controller has immediate access to these cells and composes the sections and rows of the table view with them, as depicted in Figure 5-7. Figure 5-7 Table view rows drawn with multiple cells As with the procedure for dynamic content, start by adding a subclass of UITableViewController to your project. Define outlet properties for the master row label in the first cell and the slider value label in the last cell, as shown in Listing 5-5. Listing 5-5 Defining outlet properties for static cell objects @interface DetailViewController : UITableViewController @property (strong, nonatomic) id detailItem; @property (weak, nonatomic) IBOutlet UILabel *masterRowLabel; @property (weak, nonatomic) IBOutlet UILabel *sliderValueLabel; @property (weak, nonatomic) IBOutlet UISlider *slider; - (IBAction)logHello; - (IBAction)sliderValueChanged:(UISlider *)slider; A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 66@end In the storyboard, drag a Table View Controller object from the Library onto the canvas. Select the table view and set the following attributes in the Attributes inspector: 1. Set the Content pop-up menu to Static Cells. 2. Set the number of sections to 2. 3. Set the Style pop-up menu to Grouped. For each section in the table view, use the Attributes inspector to enter a string in the Header field. Then for the cells, complete the following steps: 1. Delete two of the three cells in the first table-view section and one cell in the second section. 2. Increase the height of each remaining cell as needed. It isn’t necessary to assign reuse identifiers tof these cells, because you’re not going to implement the data source method tableView:cellForRowAtIndexPath:. 3. Drag objects from the Library to compose the subviews of each cell as depicted in Figure 5-7 (page 66). 4. Set any desired attributes of these objects. The slider in this example has a range of values from 0 to 10 with an initial value of 7.5. A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 67Select the table view controller and display the Connections inspector. Make connections between the three outlets in your table view controller and the corresponding objects, as shown in Figure 5-8. While you’re at it, implement the two action methods declared in Listing 5-5 (page 66) and make target-action connections to the button and the slider. Figure 5-8 Making connections to your static cell content To populate the data in the static cells, implement a method called configureView in the detail view controller. In this example, detailItem is an NSString object passed in by the master view controller in its prepareForSegue:sender: method. The string contains the master row number. Listing 5-6 Setting the data in the user interface - (void)configureView { if (self.detailItem) { self.masterRowLabel.text = [self.detailItem description]; } self.sliderValueLabel.text = [NSString stringWithFormat:@"%1.1f", self.slider.value]; } A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 68The detail view controller calls the configureView method in viewDidLoad and setDetailItem:, as illustrated in the Xcode template Master-Detail Application. Programmatically Adding Subviews to a Cell’s Content View A cell that a table view uses for displaying a row is a view (UITableViewCell inherits from UIView). As a view, a cell has a content view—a superview for cell content—that it exposes as a property. To customize the appearance of rows in a table view, add subviews to the cell’s content view, which is accessible through its contentView property, and lay them out in the desired locations in their superview’s coordinates. You can configure and lay them out programmatically or in Interface Builder. (The approach using Interface Builder is discussed in “Loading Table View Cells from a Storyboard” (page 61).) One advantage of this approach is its relative simplicity; it doesn’t require you to create a custom subclass of UITableViewCell and handle all of the implementation details required for custom views. However, if you do take this approach, avoid making the views transparent, if you can. Transparent subviews affect scrolling performance because of the increased compositing cost. Subviews should be opaque, and typically should have the same background color as the cell. And if the cell is selectable, make sure that the cell content is highlighted appropriately when selected. The content is selected automatically if the subview implements (if appropriate) the accessor methods for the highlighted property. A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 69Suppose you want a cell with text and image content in custom locations. For example, you want the image on the right side of the cell and the title and subtitle of the cell right-aligned against the left side of the image. Figure 5-9 show how a table view with rows drawn with such a cell might look. (This example is for illustration only, and is not intended as a human-interface model.) Figure 5-9 Cells with custom content as subviews The code example in Listing 5-7 illustrates how the data source programmatically composes the cell with which thistable view drawsitsrows. In tableView:cellForRowAtIndexPath:, it first checksto see the table view already has a cell object with the given reuse identifier. If there is no such object, the data source creates two label objects and one image view with specific frames within the coordinate system of their superview (the content view). It also sets attributes of these objects. Having acquired an appropriate cell to use, the data source sets the cell’s content before returning the cell. Listing 5-7 Adding subviews to a cell’s content view #define MAINLABEL_TAG 1 #define SECONDLABEL_TAG 2 #define PHOTO_TAG 3 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 70static NSString *CellIdentifier = @"ImageOnRightCell"; UILabel *mainLabel, *secondLabel; UIImageView *photo; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]]; cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 220.0, 15.0)]]; mainLabel.tag = MAINLABEL_TAG; mainLabel.font = [UIFont systemFontOfSize:14.0]; mainLabel.textAlignment = UITextAlignmentRight; mainLabel.textColor = [UIColor blackColor]; mainLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:mainLabel]; secondLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 20.0, 220.0, 25.0)]]; secondLabel.tag = SECONDLABEL_TAG; secondLabel.font = [UIFont systemFontOfSize:12.0]; secondLabel.textAlignment = UITextAlignmentRight; secondLabel.textColor = [UIColor darkGrayColor]; secondLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:secondLabel]; photo = [[[UIImageView alloc] initWithFrame:CGRectMake(225.0, 0.0, 80.0, 45.0)]]; photo.tag = PHOTO_TAG; photo.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:photo]; } else { A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 71mainLabel = (UILabel *)[cell.contentView viewWithTag:MAINLABEL_TAG]; secondLabel = (UILabel *)[cell.contentView viewWithTag:SECONDLABEL_TAG]; photo = (UIImageView *)[cell.contentView viewWithTag:PHOTO_TAG]; } NSDictionary *aDict = [self.list objectAtIndex:indexPath.row]; mainLabel.text = [aDict objectForKey:@"mainTitleKey"]; secondLabel.text = [aDict objectForKey:@"secondaryTitleKey"]; NSString *imagePath = [[NSBundle mainBundle] pathForResource:[aDict objectForKey:@"imageKey"] ofType:@"png"]; UIImage *theImage = [UIImage imageWithContentsOfFile:imagePath]; photo.image = theImage; return cell; } When the data source creates the cells, it assigns each subview an identifier called a tag. With tags, you can locate a view in its view hierarchy by calling the viewWithTag: method. If the delegate later getsthe designated cell from the table view’s queue, it uses the tags to obtain references to the three subviews prior to assigning them content. This code creates a UITableViewCell object in the predefined default style (UITableViewCellStyleDefault). Because the content properties of the standard cells—textLabel, detailTextLabel, and imageView—are nil until assigned content, you may use any predefined cell as the template for customization. Note: Another approach is to subclass UITableViewCell and create instances in the UITableViewCellStyleSubtitle style. Then override the layoutSubviewsmethod to reposition the textLabel, detailTextLabel, and imageView subviews (after calling super). One way to achieve “attributed string” effects with textual content is to lay out UILabel subviews of the UITableViewCell content view. The text of each label can have its own font, color,size, alignment, and other characteristics. If you want that kind of variation within a label object, create multiple labels and lay them out relative to each other. A Closer Look at Table View Cells Customizing Cells 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 72Cells and Table View Performance The proper use of table view cells, whether off-the-shelf or custom cell objects, is a major factor in the performance of table views. Ensure that your application does the following three things: ● Reuse cells. Object allocation has a performance cost, especially if the allocation hasto happen repeatedly over a short period—say, when the user scrolls a table view. If you reuse cells instead of allocating new ones, you greatly enhance table view performance. ● Avoid relayout of content. When reusing cells with custom subviews, refrain from laying out those subviews each time the table view requests a cell. Lay out the subviews once, when the cell is created. ● Use opaque subviews. When customizing table view cells, make the subviews of the cell opaque, not transparent. A Closer Look at Table View Cells Cells and Table View Performance 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 73When users tap a row of a table view, usually something happens as a result. Another table view could slide into place, the row could display a checkmark, orsome other action could be performed. The following sections describe how to respond to selections and how to make selections programmatically. Selections in Table Views There are a few human-interface guidelines to keep in mind when dealing with cell selection in table views: ● You should never use selection to indicate state. Instead, use check marks and accessory viewsforshowing state. ● When the user selects a cell, you should respond by deselecting the previously selected cell (by calling the deselectRowAtIndexPath:animated: method) as well as by performing any appropriate action, such as displaying a detail view. ● If you respond to the the selection of a cell by pushing a new view controller onto the navigation controller’s stack, you should deselect the cell (with animation) when the view controller is popped off the stack. You can control whether rows are selectable when the table view is in editing mode by setting the allowsSelectionDuringEditing property of UITableView. In addition, beginning with iOS 3.0, you can control whether cells are selectable when editing mode is not in effect by setting the allowsSelection property. Responding to Selections Users tap a row in a table view either to signal to the application that they want to know more about what that row signifies or to select what the row represents. In response to the user tapping a row, an application could do any of the following: ● Show the next level in a data-model hierarchy. ● Show a detail view of an item (that is, a leaf node of the data-model hierarchy). ● Show a checkmark in the row to indicate that the represented item is selected. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 74 Managing Selections● If the touch occurred in a control embedded in the row, it could respond to the action message sent by the control. To handle most selections of rows, the table view’s delegate must implement the tableView:didSelectRowAtIndexPath: method. In sample method implementation shown in Listing 6-1, the delegate first deselectsthe selected row. Then it allocates and initializes an instance of the next table-view controller in the sequence. Itsetsthe data this view controller needsto populate itstable view and then pushes this object onto the stack maintained by the application’s UINavigationController object. Listing 6-1 Responding to a row selection - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:NO]; BATTrailsViewController *trailsController = [[BATTrailsViewController alloc] initWithStyle:UITableViewStylePlain]; trailsController.selectedRegion = [regions objectAtIndex:indexPath.row]; [[self navigationController] pushViewController:trailsController animated:YES]; [trailsController release]; } If a row has a disclosure control—the white chevron over a blue circle—for an accessory view, clicking the control resultsin the delegate receiving a tableView:accessoryButtonTappedForRowWithIndexPath: message (instead of tableView:didSelectRowAtIndexPath:). The delegate responds to this message in the same general way as it does for other kinds of selections. A row can also have a control object as its accessory view, such as a switch or a slider. This control object functions as it would in any other context: Manipulating the object in the proper way results in an action message being sent to a target object. Listing 6-2 illustrates a data source object that adds a UISwitch object as a cell’s accessory view and then responds to the action messages sent when the switch is “flipped.” Listing 6-2 Setting a switch object as an accessory view and responding to its action message - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"CellWithSwitch"]; if (cell == nil) { Managing Selections Responding to Selections 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 75cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CellWithSwitch"] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.font = [UIFont systemFontOfSize:14]; } UISwitch *switchObj = [[UISwitch alloc] initWithFrame:CGRectMake(1.0, 1.0, 20.0, 20.0)]; switchObj.on = YES; [switchObj addTarget:self action:@selector(toggleSoundEffects:) forControlEvents:(UIControlEventValueChanged | UIControlEventTouchDragInside)]; cell.accessoryView = switchObj; [switchObj release]; cell.textLabel.text = @"Sound Effects"; return cell; } - (void)toggleSoundEffects:(id)sender { [self.soundEffectsOn = [(UISwitch *)sender isOn]; [self reset]; } You may also define controls as accessory views of table-view cells created in Interface Builder. Drag a control object (switch, slider, and so on) into a nib document window containing a table-view cell. Then, using the connection window, make the control the accessory view of the cell. “Loading Table View Cells from a Storyboard” (page 61) describes the procedure for creating and configuring table-view cell objects in nib files. Selection management is also important with selection lists. There are two kinds of selection lists: ● Exclusive lists where only one row is permitted the checkmark ● Inclusive lists where more than one row can have a checkmark Listing 6-3 illustrates one approach to managing an exclusive selection list. It first deselects the currently selected row and returns if the same row is selected; otherwise it sets the checkmark accessory type on the newly selected row and removes the checkmark on the previously selected row Managing Selections Responding to Selections 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 76Listing 6-3 Managing a selection list—exclusive list - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:NO]; NSInteger catIndex = [taskCategories indexOfObject:self.currentCategory]; if (catIndex == indexPath.row) { return; } NSIndexPath *oldIndexPath = [NSIndexPath indexPathForRow:catIndex inSection:0]; UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath]; if (newCell.accessoryType == UITableViewCellAccessoryNone) { newCell.accessoryType = UITableViewCellAccessoryCheckmark; self.currentCategory = [taskCategories objectAtIndex:indexPath.row]; } UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:oldIndexPath]; if (oldCell.accessoryType == UITableViewCellAccessoryCheckmark) { oldCell.accessoryType = UITableViewCellAccessoryNone; } } Listing 6-4 illustrates how to manage a inclusive selection list. As the comments in this example indicate, when the delegate adds a checkmark to a row or removes one, it typically also sets or unsets any associated model-object attribute. Listing 6-4 Managing a selection list—inclusive list - (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath { [theTableView deselectRowAtIndexPath:[theTableView indexPathForSelectedRow] animated:NO]; UITableViewCell *cell = [theTableView cellForRowAtIndexPath:newIndexPath]; if (cell.accessoryType == UITableViewCellAccessoryNone) { cell.accessoryType = UITableViewCellAccessoryCheckmark; Managing Selections Responding to Selections 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 77// Reflect selection in data model } else if (cell.accessoryType == UITableViewCellAccessoryCheckmark) { cell.accessoryType = UITableViewCellAccessoryNone; // Reflect deselection in data model } } In tableView:didSelectRowAtIndexPath: you should always deselect the currently selected row. Programmatically Selecting and Scrolling Occasionally the selection of a row originates within the application itself rather than from a tap in a table view. There could be an externally induced change in the data model. For example, the user adds a new person to an address book and then returnsto the list of contacts; the application wantsto scroll thislist to the recently added person. For situations like these, you can use the UITableView methods selectRowAtIndexPath:animated:scrollPosition: and (if the row is already selected) scrollToNearestSelectedRowAtScrollPosition:animated:. You may also call scrollToRowAtIndexPath:atScrollPosition:animated: if you want to scroll to a specific row without selecting it. The code in Listing 6-5 (somewhat whimsically) programmatically selects and scrolls to a row 20 rows away from the just-selected row using the selectRowAtIndexPath:animated:scrollPosition: method. Listing 6-5 Programmatically selecting a row - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath { NSIndexPath *scrollIndexPath; if (newIndexPath.row + 20 < [timeZoneNames count]) { scrollIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row+20 inSection:newIndexPath.section]; } else { scrollIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row-20 inSection:newIndexPath.section]; } [theTableView selectRowAtIndexPath:scrollIndexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle]; Managing Selections Programmatically Selecting and Scrolling 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 78} Managing Selections Programmatically Selecting and Scrolling 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 79A table view has an editing mode as well as its normal (selection) mode. When a table view goes into editing mode, it displays the editing and reordering controls associated with its rows. The editing controls, which are in the left side of the row, allow the user to insert and delete rows in the table view. The editing controls have distinctive appearances: Deletion control Insertion control When a table view enters editing mode and when users click an editing control, the table view sends a series of messages to its data source and delegate, but only if they implement these methods. These methods allow the data source and delegate to refine the appearance and behavior of rows in the table view; the messages also enable them to carry out the deletion or insertion operation. Even if a table view is not in editing mode, you can insert or delete a number of rows or sections as a group and have those operations animated. The first section below shows you how, when a table is in editing mode, to insert new rows and delete existing rows in a table view in response to user actions. The second section, “Batch Insertion, Deletion, and Reloading of Rows and Sections” (page 87), discusses how you can insert and delete multiple sections and rows animated as a group. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 80 Inserting and Deleting Rows and SectionsNote: The procedure for reordering rows when in editing mode is described in “Managing the Reordering of Rows” (page 91). Inserting and Deleting Rows in Editing Mode When a Table View is Edited A table view goes into editing mode when it receives a setEditing:animated: message. Typically (but not necessarily) the message originates as an action message sent when the user taps an Edit button in the navigation bar. In editing mode, a table view displays any editing (and reordering) controls that its delegate has assigned to each row. The delegate assigns the controls as a result of returning the editing style for a row in the tableView:editingStyleForRowAtIndexPath: method. Inserting and Deleting Rows and Sections Inserting and Deleting Rows in Editing Mode 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 81Note: If a UIViewController object is managing the table view, it automatically receives a setEditing:animated: message when the Edit button is tapped. In its implementation of this message, it can update button state or do any other kind of task before invoking the table view’s version of the method. When the table view receives setEditing:animated:, itsendsthe same message to the UITableViewCell object for each visible row. Then it sends a succession of messages to its data source and its delegate (if they implement the methods) as depicted in the diagram in Figure 7-1. Figure 7-1 Calling sequence for inserting or deleting rows in a table view tableView: editingStyleForRowAtIndexPath: tableView: canEditRowAtIndexPath: Client Delegate Data Source Table View User presses Edit button User presses editing control User presses Delete button setEditing:YES animated:YES tableView:commitEditingStyle: forRowAtIndexPath: deleteRowsAtIndexPath: withRowAnimation or insertRowsAtIndexPath: withRowAnimation: After resending setEditing:animated: to the cells corresponding to the visible rows, the sequence of messages is as follows: 1. The table view invokesthe tableView:canEditRowAtIndexPath: method if its data source implements it. This method allows the application to exclude rows in the table view from being edited even when their cell’s editingStyle property indicates otherwise. Most applications do not need to implement this method. 2. The table view invokes the tableView:editingStyleForRowAtIndexPath: method if its delegate implements it. This method allows the application to specify a row’s editing style and thus the editing control that the row displays. Inserting and Deleting Rows and Sections Inserting and Deleting Rows in Editing Mode 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 82At this point, the table view is fully in editing mode. It displays the insertion or deletion control for each eligible row. 3. The user taps an editing control (either the deletion control or the insertion control). If he or she taps a deletion control, a Delete button is displayed on the row. The user then taps that button to confirm the deletion. 4. The table view sends the tableView:commitEditingStyle:forRowAtIndexPath: message to the data source. Although this protocol method is marked as optional, the data source must implement it if it wants to insert or delete a row. It must do two things: ● Send deleteRowsAtIndexPaths:withRowAnimation: or insertRowsAtIndexPaths:withRowAnimation: to the table view to direct it to adjust its presentation. ● Update the corresponding data-model array by either deleting the referenced item from the array or adding an item to the array. When the user swipes across a row to display the Delete button for that row, there is a variation in the calling sequence diagrammed in Figure 7-1 (page 82). When the user swipes a row to delete it, the table view first checks to see if its data source has implemented the tableView:commitEditingStyle:forRowAtIndexPath: method; if that is so, it sends setEditing:animated: to itself and enters editing mode. In this “swipe to delete” mode, the table view does not display the editing and reordering controls. Because this is a user-driven event, it also brackets the messagesto the delegate inside of two other messages: tableView:willBeginEditingRowAtIndexPath: and tableView:didEndEditingRowAtIndexPath:. By implementing these methods, the delegate can update the appearance of the table view appropriately. Note: The data source should not call setEditing:animated: from within its implementation of tableView:commitEditingStyle:forRowAtIndexPath:. If forsome reason it must, itshould invoke it after a delay by using the performSelector:withObject:afterDelay: method. Although you can use an insertion control as the trigger to insert a new row in a table view, an alternative approach is to have an Add (or plus sign) button in the navigation bar. Tapping the button sends an action message to the view controller, which overlays the table view with a modal view for entering the new item. Once the item is entered, the controller adds it to the data-model array and reloads the table. “An Example of Adding a Table-View Row” (page 85) discusses this approach. Inserting and Deleting Rows and Sections Inserting and Deleting Rows in Editing Mode 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 83An Example of Deleting a Table-View Row This section gives a guided tour through the parts of a project that work together to set up a table view for editing mode and delete rowsfrom it. This project usesthe navigation controller and view controller architecture to manage its table views. In its loadView method, the custom view controller creates the table view and sets itself to be the data source and delegate. It also sets the right item of the navigation bar to be the standard Edit button. self.navigationItem.rightBarButtonItem = self.editButtonItem; This button is preconfigured to send setEditing:animated: to the view controller when tapped; it toggles the button title (between Edit and Done) and the Boolean editing parameter on alternating taps. In its implementation of the method, as shown in Listing 7-1, the view controller invokes the superclass invocation of the method, sends the same message to the table view, and updates the enabled state of the other button in the navigation bar (a plus-sign button, for adding items). Listing 7-1 View controller responding to setEditing:animated: - (void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; [tableView setEditing:editing animated:YES]; if (editing) { addButton.enabled = NO; } else { addButton.enabled = YES; } } When its table view enters editing mode, the view controller specifies a deletion control for every row except the last, which has an insertion control. It does this in its implementation of the tableView:editingStyleForRowAtIndexPath: method (Listing 7-2). Listing 7-2 Customizing the editing style of rows - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { SimpleEditableListAppDelegate *controller = (SimpleEditableListAppDelegate *)[[UIApplication sharedApplication] delegate]; if (indexPath.row == [controller countOfList]-1) { Inserting and Deleting Rows and Sections Inserting and Deleting Rows in Editing Mode 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 84return UITableViewCellEditingStyleInsert; } else { return UITableViewCellEditingStyleDelete; } } The user taps the deletion control in a row and the view controller receives a tableView:commitEditingStyle:forRowAtIndexPath: message from the table view. As shown in Listing 7-3, it handles this message by removing the item corresponding to the row from a model array and sending deleteRowsAtIndexPaths:withRowAnimation: to the table view. Listing 7-3 Updating the data-model array and deleting the row - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // If row is deleted, remove it from the list. if (editingStyle == UITableViewCellEditingStyleDelete) { SimpleEditableListAppDelegate *controller = (SimpleEditableListAppDelegate *)[[UIApplication sharedApplication] delegate]; [controller removeObjectFromListAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } } An Example of Adding a Table-View Row This section shows project code that inserts a row in a table view. Instead of using the insertion control as the trigger for inserting a row, it uses an Add button (visually a plus sign) in the navigation bar above the table view. This code also is based on the navigation controller and view controller architecture. In its loadView method implementation, the view controller assigns the Add button as the right-side item of the navigation bar using the code shown in Listing 7-4. Listing 7-4 Adding an Add button to the navigation bar addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addItem:)]; Inserting and Deleting Rows and Sections Inserting and Deleting Rows in Editing Mode 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 85self.navigationItem.rightBarButtonItem = addButton; Note that the view controller sets the control states for the title as well as the action selector and the target object. When the user taps the Add button, the addItem: message is sent to the target (the view controller). It responds as shown in Listing 7-5. It creates a navigation controller with a single view controller whose view is put onscreen modally—it animates upward to overlay the table view. The presentModalViewController:animated: method to do this. Listing 7-5 Responding to a tap on the Add button - (void)addItem:sender { if (itemInputController == nil) { itemInputController = [[ItemInputController alloc] init]; } UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:itemInputController]; [[self navigationController] presentModalViewController:navigationController animated:YES]; [navigationController release]; } The modal, or overlay, view consists of a single custom text field. The user enters text for the new table-view item and then taps a Save button. This button sends a save: action message to its target: the view controller for the modal view. As shown in Listing 7-6, the view controller extracts the string value from the text field and updates the application’s data-model array with it. Listing 7-6 Adding the new item to the data-model array - (void)save:sender { UITextField *textField = [(EditableTableViewTextField *)[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]] textField]; SimpleEditableListAppDelegate *controller = (SimpleEditableListAppDelegate *)[[UIApplication sharedApplication] delegate]; NSString *newItem = textField.text; if (newItem != nil) { [controller insertObject:newItem inListAtIndex:[controller countOfList]]; Inserting and Deleting Rows and Sections Inserting and Deleting Rows in Editing Mode 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 86} [self dismissModalViewControllerAnimated:YES]; } After the modal view is dismissed the table view is reloaded, and it now reflects the added item. Batch Insertion, Deletion, and Reloading of Rows and Sections The UITableView class allows you to insert, delete, and reload a group of rows or sections at one time, animating the operations simultaneously in specified ways. The eight methods shown in Listing 7-7 pertain to batch insertion and deletion. Note that you can call these insertion and deletion methods outside of an animation block (as you do in the data source method tableView:commitEditingStyle:forRowAtIndexPath: as discussed in “Inserting and Deleting Rows in Editing Mode” (page 81)). Listing 7-7 Batch insertion and deletion methods - (void)beginUpdates; - (void)endUpdates; - (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; - (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation: (UITableViewRowAnimation)animation; - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation: (UITableViewRowAnimation)animation; - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation; Inserting and Deleting Rows and Sections Batch Insertion, Deletion, and Reloading of Rows and Sections 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 87Note: The reloadSections:withRowAnimation: and reloadRowsAtIndexPaths:withRowAnimation: methods, which were introduced in iOS 3.0, allow you to request the table view to reload the data for specific sections and rows instead of loading the entire visible table view by calling reloadData. To animate a batch insertion, deletion, and reloading of rows and sections, call the corresponding methods within an animation block defined by successive calls to beginUpdates and endUpdates. If you don’t call the insertion, deletion, and reloading methods within this block, row and section indexes may be invalid. Calls to beginUpdates and endUpdates can be nested; all indexes are treated as if there were only the outer update block. At the conclusion of a block—that is, after endUpdates returns—the table view queries its data source and delegate as usual for row and section data. Thusthe collection objects backing the table view should be updated to reflect the new or removed rows or sections. An Example of Batched Insertion and Deletion Operations To insert and delete a group of rows and sections in a table view, first prepare the array (or arrays) that are the source of data for the sections and rows. After rows and sections are deleted and inserted, the resulting rows and sections are populated from this data store. Next, call the beginUpdates method, followed by invocations of insertRowsAtIndexPaths:withRowAnimation:, deleteRowsAtIndexPaths:withRowAnimation:, insertSections:withRowAnimation:, or deleteSections:withRowAnimation:. Conclude the animation block by calling endUpdates. Listing 7-8 illustrates this procedure. Listing 7-8 Inserting and deleting a block of rows in a table view - (IBAction)insertAndDeleteRows:(id)sender { // original rows: Arizona, California, Delaware, New Jersey, Washington [states removeObjectAtIndex:4]; // Washington [states removeObjectAtIndex:2]; // Delaware [states insertObject:@"Alaska" atIndex:0]; [states insertObject:@"Georgia" atIndex:3]; [states insertObject:@"Virginia" atIndex:5]; NSArray *deleteIndexPaths = [NSArray arrayWithObjects: Inserting and Deleting Rows and Sections Batch Insertion, Deletion, and Reloading of Rows and Sections 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 88[NSIndexPath indexPathForRow:2 inSection:0], [NSIndexPath indexPathForRow:4 inSection:0], nil]; NSArray *insertIndexPaths = [NSArray arrayWithObjects: [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:3 inSection:0], [NSIndexPath indexPathForRow:5 inSection:0], nil]; UITableView *tv = (UITableView *)self.view; [tv beginUpdates]; [tv insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationRight]; [tv deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade]; [tv endUpdates]; // ending rows: Alaska, Arizona, California, Georgia, New Jersey, Virginia } This example removes two strings from an array (and their corresponding rows) and inserts three strings into the array (along with their corresponding rows). The next section, “Ordering of Operations and Index Paths,” explains particular aspects of the row (or section) insertion and deletion behavior. Ordering of Operations and Index Paths You might have noticed something in the code shown in Listing 7-8 that seems peculiar. The code calls the deleteRowsAtIndexPaths:withRowAnimation: method after it calls insertRowsAtIndexPaths:withRowAnimation:. However, this is not the order in which UITableView completes the operations. It defers any insertions of rows or sections until after it has handled the deletions of rows or sections. The table view behaves the same way with reloading methods called inside an update block—the reload takes place with respect to the indexes of rows and sections before the animation block is executed. This behavior happens regardless of the ordering of the insertion, deletion, and reloading method calls. Deletion and reloading operations within an animation block specify which rows and sections in the original table should be removed or reloaded; insertions specify which rows and sections should be added to the resulting table. The index paths used to identify sections and rows follow this model. Inserting or removing Inserting and Deleting Rows and Sections Batch Insertion, Deletion, and Reloading of Rows and Sections 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 89an item in a mutable array, on the other hand, may affect the array index used for the successive insertion or removal operation; for example, if you insert an item at a certain index, the indexes of all subsequent items in the array are incremented. An example is useful here. Say you have a table view with three sections, each with three rows. Then you implement the following animation block: 1. Begin updates. 2. Delete row at index 1 of section at index 0. 3. Delete section at index 1. 4. Insert row at index 1 of section at index 1. 5. End updates. Figure 7-2 illustrates what takes place after the animation block concludes. Figure 7-2 Deletion of section and row and insertion of row Section 1 Section 0 Section 1 Section 2 Section 0 0 New 1 2 0 1 2 0 1 2 3 0 1 0 1 2 x X Inserting and Deleting Rows and Sections Batch Insertion, Deletion, and Reloading of Rows and Sections 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 90A table view has an editing mode as well as its normal (selection) mode. When a table view goes into editing mode, it displays the editing and reordering controls associated with its rows. The reordering control allows the user to move a row to a different location in the table. As shown in Figure 8-1, the reordering control appears on the right side of the row. Figure 8-1 Reordering a row When a table view enters editing mode and when users drag a reordering control, the table view sends a series of messages to its data source and delegate, but only if they implement these methods. These methods allow the data source and delegate to restrict whether and where a row can be moved as well to carry out the actual move operation. The following sections show you how to move rows around in a table view. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 91 Managing the Reordering of RowsWhat Happens When a Row is Relocated A table view goes into editing mode when it receives a setEditing:animated: message. Typically (but not necessarily) the message originates as an action message sent when the user taps an Edit button in the navigation bar. In editing mode, a table view displays any reordering (and editing) controls that its delegate has assigned to each row. The delegate assigns the controls in tableView:cellForRowAtIndexPath: by setting the showsReorderControl property of UITableViewCell objects to YES. Note: If a UIViewController object is managing the table view, it automatically receives a setEditing:animated: message when the Edit button is tapped. UITableViewController, a subclass of UIViewController, implements this method to update button state and invoke the table view’s version of the method. If you are using UIViewController to manage a table view, you need to implement the same behavior. When the table view receives setEditing:animated:, itsendsthe same message to the UITableViewCell object for each visible row. Then it sends a succession of messages to its data source and its delegate (if they implement the methods) as depicted in the diagram in Figure 8-2. Figure 8-2 Calling sequence for reordering a row in a table view tableView: canMoveRowAtIndexPath: Client Delegate Data Source Table View User presses Edit button User drags reordering control setEditing:YES animated:YES tableView: moveRowAtIndexPath: toRowAtIndexPath: tableView: targetIndexPathForMoveFromRowAtIndexPath: toProposedIndexPath: When the table view receives the setEditing:animated: message, it resends the same message to the cell objects corresponding to its visible rows. After that, the sequence of messages is as follows: Managing the Reordering of Rows What Happens When a Row is Relocated 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 921. The table view sends a tableView:canMoveRowAtIndexPath: message to its data source (if it implements the method). In this method the delegate may selectively exclude certain rows from showing the reordering control. 2. The user drags a row by its reordering control up or down the table view. As the dragged row hovers over a part of the table view, the underlying row slides downward to show where the destination would be. 3. Every time the dragged row is over a destination, the table view sends tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: to its delegate (if it implements the method). In this method the delegate may reject the current destination for the dragged row and specify an alternative one. 4. The table view sends tableView:moveRowAtIndexPath:toIndexPath: to its data source (if it implements the method). In this method the data source updates the data-model array that is the source of items for the table view, moving the item to a different location in the array. Examples of Moving a Row Thissection comments on some sample code that illustratesthe reordering steps enumerated in “What Happens When a Row is Relocated” (page 92). Listing 8-1 shows an implementation of tableView:canMoveRowAtIndexPath: that excludes the first row in the table view from being reordered (this row does not have a reordering control). Listing 8-1 Excluding a row from relocation - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) // Don't move the first row return NO; return YES; } When the user finishes dragging a row, it slides into its destination in the table view, which sends tableView:moveRowAtIndexPath:toIndexPath: to its data source. Listing 8-2 shows an implementation of this method. Note that it retains the data item fetched from the array (the item to be relocated) because the item is automatically released when it is removed from the array. Managing the Reordering of Rows Examples of Moving a Row 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 93Listing 8-2 Updating the data-model array for the relocated row - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath { NSString *stringToMove = [[self.reorderingRows objectAtIndex:sourceIndexPath.row] retain]; [self.reorderingRows removeObjectAtIndex:sourceIndexPath.row]; [self.reorderingRows insertObject:stringToMove atIndex:destinationIndexPath.row]; [stringToMove release]; } The delegate can also retarget the proposed destination for a move to another row by implementing the tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: method. The following example restricts rows to relocation in their own group and prevents moves to the last row of a group (which is reserved for the add-item placeholder). Listing 8-3 Retargeting the destination row of a move operation - (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath { NSDictionary *section = [data objectAtIndex:sourceIndexPath.section]; NSUInteger sectionCount = [[section valueForKey:@"content"] count]; if (sourceIndexPath.section != proposedDestinationIndexPath.section) { NSUInteger rowInSourceSection = (sourceIndexPath.section > proposedDestinationIndexPath.section) ? 0 : sectionCount - 1; return [NSIndexPath indexPathForRow:rowInSourceSection inSection:sourceIndexPath.section]; } else if (proposedDestinationIndexPath.row >= sectionCount) { return [NSIndexPath indexPathForRow:sectionCount - 1 inSection:sourceIndexPath.section]; } // Allow the proposed destination. return proposedDestinationIndexPath; } Managing the Reordering of Rows Examples of Moving a Row 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 94This table describes the changes to Table View Programming Guide for iOS . Date Notes 2012-09-19 Added new information for iOS 5. 2011-01-05 Made some minor corrections. 2010-09-14 Made several minor corrections. 2010-08-03 States now that beginUpdates...endUpdates calls can be nested. 2010-07-08 Changed the title from "Table View Programming Guide for iPhone OS." Made many minor corrections in diagrams and text. Added description of reload behavior in batch udpates. 2010-05-20 2010-03-24 Made the introduction more informative. Explained how to set the background color of cells, emphasized purpose of tableView:willDisplayCell:forRowAtIndexPath:, and made minor corrections. 2009-08-19 Updated to describe 3.0 API, especially predefined cell styles and related properties. It also describes the use of nib files with table views and table-view cells and includes an updated chapter on view controllers and design patterns and strategies. 2009-05-28 Warned against calling setEditing:animated: when in tableView:commitEditingStyle:forRowAtIndexPath:. Updated illustration. 2008-10-15 Added section on batch insertions and deletions, added related classes to TOC frame, added guidelines on clearing selection, and made minor corrections. 2008-09-09 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 95 Document Revision HistoryDate Notes 2008-06-25 First version of this document. Document Revision History 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 96Apple Inc. © 2012 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrievalsystem, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Inc., with the following exceptions: Any person is hereby authorized to store documentation on a single computer for personal use only and to print copies of documentation for personal use provided that the documentation contains Apple’s copyright notice. No licenses, express or implied, are granted with respect to any of the technology described in this document. Apple retains all intellectual property rights associated with the technology described in this document. This document is intended to assist application developers to develop applications only for Apple-labeled computers. Apple Inc. 1 Infinite Loop Cupertino, CA 95014 408-996-1010 Apple, the Apple logo, Cocoa, Cocoa Touch, iPad, iPhone, Objective-C, and Xcode are trademarks of Apple Inc., registered in the U.S. and other countries. iOS is a trademark or registered trademark of Cisco in the U.S. and other countries and is used under license. Even though Apple has reviewed this document, APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS DOCUMENT, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.ASARESULT, THISDOCUMENT IS PROVIDED “AS IS,” AND YOU, THE READER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL,OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS DOCUMENT, even if advised of the possibility of such damages. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, or employee is authorized to make any modification, extension, or addition to this warranty. Some states do not allow the exclusion or limitation of implied warranties or liability for incidental or consequential damages, so the above limitation or exclusion may not apply to you. This warranty gives you specific legal rights, and you may also have other rights which vary from state to state. TableView_iPhone.pdf Deux doigts d’astuces Démarrage Requiert un appareil compatible FaceTime et une connexion Wi-Fi, pour l’appelant comme pour l’appelé. Non disponible partout Bienvenue dans l’univers iPhone. Ce guide de démarrage rapide vous présente comment configurer votre iPhone et utiliser ses fonctionnalités principales. Une fois prêt à profiter de votre iPhone, vous pouvez obtenir des renseignements plus détaillés sur www.apple.com/fr/iphone ou www.apple.com/iphone/countries. À vos marques, configurez, partez ! 1. Téléchargement d’iTunes. Rendez-vous sur www.itunes.com/fr/download et téléchargez la dernière version d’iTunes à installer sur votre Mac ou PC. 2. Connexion à votre ordinateur. Connectez votre iPhone au port USB de votre ordinateur. 3. Synchronisation. Lorsque l’iPhone est connecté, iTunes s’ouvre et vous guide dans l’installation. Sélectionnez les contacts, les calendriers, la musique, les vidéos et les photos que vous souhaitez synchroniser, puis cliquez sur Appliquer dans l’angle droit inférieur. Si vous n’avez jamais utilisé iTunes ou que vous souhaitez vous informer sur la synchronisation, vous pouvez consulter un guide d’initiation rapide sur www.apple.com/fr/itunes/tutorials. Bouton Marche/Veille. Pour allumer l’iPhone, appuyez fermement sur le bouton Marche/Veille. Pour l’éteindre ou le redémarrer, maintenez le bouton Marche/Veille enfoncé pendant quelques secondes, puis faites glisser le curseur pour confirmer. Pour mettre l’iPhone en mode veille, appuyez une fois sur le bouton Marche/Veille, ce qui a pour effet d’éteindre l’écran tout en permettant à l’iPhone de recevoir des appels. Pour mettre en silence un appel entrant, appuyez une fois sur ce bouton. Pour envoyer un appel directement vers la messagerie vocale, appuyez deux fois dessus. Accueil. Lorsque vous utilisez une application, appuyez sur le bouton principal pour fermer celle-ci et revenir à son écran d’accueil. Pour accéder rapidement à l’écran d’accueil principal, appuyez sur le bouton principal depuis n’importe quel autre écran d’accueil. À partir de l’écran de verrouillage, double-cliquez sur le bouton d’accueil pour faire apparaître les commandes iPod. Créer des dossiers. Organiser ses applications. Touchez une icône et maintenez le doigt dessus jusqu’à ce qu’elle s’agite. Faites ensuite glisser une icône sur une autre afin de créer un dossier. Les dossiers sont nommés automatiquement par catégorie mais vous pouvez les renommer. Vous pouvez personnaliser votre écran d’accueil en faisant glisser des icônes et dossiers à différents emplacements et sur différents écrans. Une fois que vous avez terminé, il vous suffit d’appuyer sur le bouton principal. Rechercher. Pour effectuer une recherche sur votre iPhone ou sur le Web, allez à l’écran d’accueil et appuyez sur le bouton principal, ou passez le doigt sur l’écran de gauche à droite. Saisissez ce que vous souhaitez rechercher : un nom, une application, un morceau, un artiste, un film ou un mot-clé. L’iPhone propose des suggestions au fur et à mesure que vous écrivez, pour accélérer encore davantage votre recherche. Pour lancer une recherche depuis une application comme Mail, Contacts, Messages ou iPod, touchez la barre d’état. Effectuer un appel. Pour effectuer un appel, touchez un numéro de téléphone dans Contacts, Favoris, un courrier électronique, un SMS ou MMS, ou pratiquement n’importe où sur l’iPhone. Vous pouvez sinon toucher le bouton du clavier numérique afin de composer un numéro manuellement. Pour répondre à un appel alors que vous utilisez les écouteurs de l’iPhone, appuyez une fois sur le bouton central. Appuyez à nouveau dessus pour mettre fin à l’appel. Pour régler le volume, appuyez sur les boutons « + » et « - » situés au-dessus et en dessous du micro. FaceTime. Pour lancer une vidéoconférence lors d’un appel vocal, touchez le bouton FaceTime. Vous pouvez par ailleurs toucher le bouton FaceTime depuis l’application Contacts. Lors d’une vidéoconférence, vous pouvez activer la caméra de derrière et filmer ainsi autour de vous. Pour accéder à votre courrier électronique, Internet ou d’autres applications, appuyez sur le bouton principal. Multitâche. Pendant un appel, vous pouvez accéder à votre courrier électronique, à votre calendrier ou aux autres applications, et même naviguer sur le Web, dans la mesure où vous êtes connecté via Wi-Fi ou 3G. Pour passer rapidement d’une application à l’autre, appuyez deux fois sur le bouton principal pour afficher la liste des applications récemment utilisées. Faites défiler vers la droite pour voir plus d’applications, puis touchez une icône pour relancer l’application correspondante. Faites défiler vers la gauche jusqu’au bout pour accéder aux contrôles de l’iPod ou verrouiller l’orientation de l’écran. Contrôle vocal. Utilisez la fonction de contrôle vocal pour effectuer un appel ou écouter de la musique tout en gardant les mains libres. Pour activer cette fonction, maintenez enfoncé le bouton principal de l’iPhone ou le bouton central des écouteurs jusqu’à ce que l’écran du contrôle vocal apparaisse. Après la tonalité, énoncez une commande telle que « Appeler Emmanuelle » ou « Composer le 06 62 12 98 54 » en épelant chaque chiffre. Vous pouvez aussi demander à l’iPhone de jouer un album spécifique, un artiste ou une liste de lecture ou de « Jouer d’autres titres comme celui-ci ». Vous pouvez même demander à l’iPhone « Quel est ce morceau ? » ou encore « Écouter des morceaux des Rolling Stones ». Sonnerie/ Silencieux Volume Augmenter/ Diminuer Marche/Veille Suspendre/ Réactiver Barre d’état Bouton principal*Requiert une Apple TV de seconde génération. *La messagerie vocale visuelle et les MMS ne sont pas forcément disponibles dans toutes les régions. Pour en savoir plus, contactez votre fournisseur de services sans fil. Certains services et fonctionnalités ne sont pas disponibles partout. © 2010 Apple Inc. Tous droits réservés. Apple, AirPlay, Apple TV, Cover Flow, FaceTime, iPhone, iPod, iTunes, Mac et Safari sont des marques d’Apple Inc., déposées aux États-Unis et dans d’autres pays. AirPrint est une marque d’Apple Inc. iTunes Store est une marque de service d’Apple Inc., déposée aux États-Unis et dans d’autres pays. App Store et iBookstore sont des marques de service d’Apple Inc. Les autres noms de produits et de sociétés mentionnés ici peuvent être des marques de leurs détenteurs respectifs. Designed by Apple in California. Printed in China. F034-5753-A Perfectionner ses connaissances. Vous pouvez perfectionner vos connaissances sur les fonctionnalités de l’iPhone en vous rendant sur la page web www.apple.com/fr/iphone ou www.apple.com/iphone/countries. Pour consulter le Guide de l’utilisateur de l’iPhone sur votre iPhone, téléchargez-le sur l’iBookstore ou cherchez-le sur le site help.apple.com/iphone ou dans les signets de Safari. Pour obtenir des versions téléchargeables du Guide de l’utilisateur de l’iPhone et du Guide d’informations importantes sur le produit, rendez-vous sur support.apple.com/fr_FR/manuals/ iphone. Obtenir de l’assistance. Contactez votre fournisseur de services sans fil pour obtenir une assistance sur les services liés au réseau, y compris la messagerie vocale visuelle et la facturation. * Rendez-vous sur www.apple.com/fr/support/iphone pour obtenir une assistance technique sur l’iPhone et iTunes. Rechercher un lieu. Effectuer des recherches dans les environs. Pour situer où vous vous trouvez sur une carte, touchez le bouton Localisation. Un point bleu apparaît, signalant votre position géographique à cet instant. Pour connaître la direction face à vous, touchez à nouveau le bouton Localisation afin d’activer l’affichage avec orientation. Recherchez des lieux précis dans les alentours en saisissant des mots comme « Starbucks » ou « pizza » dans le champ de recherche. Touchez deux fois l’écran pour effectuer un zoom avant, et une fois avec deux doigts pour un zoom arrière. Vous pouvez également obtenir des indications sur un trajet ou faire apparaître davantage d’options d’affichage en touchant le bouton représentant une page retournée. App Store. Touchez l’icône App Store pour parcourir sans fil des centaines de milliers d’apps dans des catégories telles que jeux, entreprise, voyage ou réseaux sociaux. Parcourez-les par Sélection, Catégories ou Top 25, ou lancez une recherche par nom. Pour acheter et télécharger une application directement sur votre iPhone, touchez Acheter. Beaucoup d’applications sont gratuites. iTunes Store. Vous pouvez accéder à l’iTunes Store sans fil en touchant l’icône d’iTunes. Parcourez le Store pour y rechercher musique, films, séries télévisées, clips vidéo et plus encore. Naviguez, achetez et téléchargez depuis le Store, directement sur votre iPhone. Touchez n’importe quel élément afin d’en écouter ou d’en visionner un extrait. Clavier intelligent. L’iPhone corrige et suggère des mots automatiquement et au fur et à mesure que vous écrivez. Ainsi, si vous saisissez une lettre erronée, continuez à écrire. Pour accepter le mot suggéré, touchez la barre d’espace. Touchez le « x » pour refuser le mot suggéré et permettre à l’iPhone de mémoriser le mot que vous avez saisi. Le clavier insère automatiquement les apostrophes dans les contractions, le cas échéant. Touchez deux fois la barre d’espace pour ajouter un point. Pour activer le clavier numérique et celui des symboles, touchez le bouton « .?123 ». Couper, copier et coller. Touchez le texte que vous souhaitez modifier, ou bien touchez-le en laissant le doigt dessus afin de faire apparaître la loupe, puis faites glisser votre doigt pour déplacer le point d’insertion. Pour sélectionner un mot, touchez-le deux fois rapidement et faites glisser les points de capture pour sélectionner plus ou moins de texte. Ensuite, touchez Couper, Copier ou Coller. Pour copier du texte depuis des pages web, des courriers électroniques ou des SMS ou MMS, touchez le texte à sélectionner et maintenez le doigt dessus. Pour annuler une modification, remuez l’iPhone puis touchez le bouton d’annulation de la modification. Photos. Chargez vos photos favorites sur l’iPhone depuis votre ordinateur via iTunes, ou utilisez l’appareil photo intégré pour prendre des photos. Touchez Photos afin de voir vos photos. Passez le doigt sur l’écran vers la droite ou la gauche pour vous déplacer entre les images. Touchez deux fois l’écran rapidement ou rapprochez vos doigts dessus pour activer le zoom. Touchez une fois l’écran pour afficher les contrôles à l’écran. Touchez le bouton d’action pour envoyer une photo dans un message MMS ou un message électronique. Vous pouvez également utiliser une photo comme fond d’écran, l’affecter à un contact ou l’imprimer sans fil sur une imprimante compatible AirPrint. Vidéo HD. Pour enregistrer de la vidéo en HD, touchez Caméra puis placez le commutateur Photo/Vidéo en position Vidéo. Touchez le bouton Enregistrer afin de commencer l’enregistrement. Touchez à nouveau ce bouton pour l’arrêter. L’option « Toucher pour mettre au point » vous permet de contrôler la mise au point et l’exposition en touchant n’importe quel élément sur l’écran. L’enregistrement peut être effectué en mode paysage ou portrait. Vous pouvez même allumer la lumière de la caméra si vous filmez dans un endroit sombre. Contrôles pour les vidéos et les morceaux. Touchez l’écran pour afficher les contrôles à l’écran. Touchez-le à nouveau pour les masquer. Si vous touchez deux fois une vidéo, vous passez alors d’un affichage grand écran à un affichage plein écran. Lors de l’écoute de musique, tournez l’iPhone pour faire apparaître la pochette de l’album en mode Cover Flow et parcourir vos albums. Touchez un album pour afficher la liste de ses pistes et touchez-en une pour l’écouter. Pour revenir à la pochette de l’album, touchez l’écran à l’extérieur de la liste de pistes. Lors de l’écoute de musique avec les écouteurs de l’iPhone, appuyez sur le bouton central une fois pour mettre en pause ou en lecture, et appuyez rapidement deux fois pour passer au morceau suivant. Touchez le bouton AirPlay pour diffuser votre musique ou votre vidéo vers une Apple TV*. Voir une page web de plus près. Dans Safari, touchez deux fois un élément d’une page web (image ou texte) pour l’agrandir. Touchez à nouveau deux fois pour revenir à la taille normale. Touchez le bouton Multi-page pour feuilleter plusieurs pages web ou en ouvrir une nouvelle. Tournez l’iPhone pour visualiser la page web au format grand écran. Google, le logo Google et Google Maps sont des marques de Google Inc. © 2010. Tous droits réservés. L’App Store est disponible dans certains pays uniquement. L’iTunes Store est disponible dans certains pays uniquement. AirPort Extreme Base Station Setup Guide LL2870.book Page 1 Thursday, October 28, 2004 12:45 PMLL2870.book Page 2 Thursday, October 28, 2004 12:45 PM 3 1 Contents Chapter 1 5 Introduction to AirPort 5 About the AirPort Extreme Base Station 6 The AirPort Extreme Base Station at a Glance 7 AirPort Extreme Base Station Ports 8 About the AirPort Software Chapter 2 9 Setting Up Your AirPort Extreme Base Station 10 Mounting the AirPort Extreme Base Station on a Wall 12 Setup Overview Chapter 3 15 Using Your AirPort Extreme Base Station 15 Configuring the Base Station 16 Monitoring the AirPort Extreme Base Station’s Internet Connection Status 17 Monitoring AirPort Extreme Base Station Communication 17 Connecting to the Internet Via the AirPort Network 18 Connecting Additional Base Stations to Your AirPort Network 18 Connecting Multiple Base Stations to Power Sourcing Equipment (PSE) 18 Extending the Range of Your AirPort Network 19 Controlling the Range of Your AirPort Network 19 More Information About AirPort Chapter 4 21 Basic Network Designs 22 Setting Up a Home Office Network 23 Setting Up a Network at School 25 Connecting AirPort Base Stations Using Power Over Ethernet (PoE) Chapter 5 27 Troubleshooting Appendix 31 AirPort Extreme Base Station Specifications 33 Communications Regulation Information LL2870.book Page 3 Thursday, October 28, 2004 12:45 PM4 Contents LL2870.book Page 4 Thursday, October 28, 2004 12:45 PM1 5 1 Introduction to AirPort AirPort is a simple and fast way to access the Internet from anywhere in your home, classroom, or office without cables, additional phone lines, or complicated networking software. AirPort is a wireless local area network (WLAN) technology that provides highperformance wireless communication between multiple computers and the Internet. When you connect to the Internet using AirPort, you can share a single Internet connection with many computers at the same time and share files among them. To use AirPort to access the Internet, you may need an account with an Internet service provider (fees may apply) and a way to access the Internet—either through a DSL or cable modem, or an Ethernet network. If your base station has an internal modem, and you have a PPP dial-up connection with an ISP, you can connect to the Internet using the base station’s internal modem. Note: This manual includes information for setting up the AirPort Extreme Base Station using Mac OS X and Windows XP and Windows 2000. The screenshots and general instructions are based on Mac OS X. For more detailed Windows XP and Windows 2000 instructions, see AirPort Help in the AirPort Admin Utility on computers using Windows. About the AirPort Extreme Base Station The AirPort Extreme Base Station establishes a wired connection to the Internet or a network and wireless connections to wireless client computers. Once the base station is connected to the network, all wireless client computers can connect to the Internet by joining the AirPort network. Computers connected to the AirPort network by Ethernet can also share the base station’s Internet connection. The base station manages communications between the Internet and the wireless client computers. LL2870.book Page 5 Thursday, October 28, 2004 12:45 PM6 Chapter 1 Introduction to AirPort The AirPort Extreme Base Station has the following ports: • 10/100Base-T Ethernet WAN ( ) port for connecting a DSL or cable modem, or for connecting to an existing Ethernet network with Internet access • 10/100Base-T Ethernet LAN (G) port for high-speed connection to local printers and Ethernet computers that don’t have Internet access • USB port ( ) for connecting a printer to the base station Some models of the base station also have a built-in 56K modem port (W) for dial-up Internet access with a standard telephone line. Some models of the base station can also receive power over Ethernet (PoE). When the base station Ethernet WAN port is connected to IEEE 802.3af-compliant Power Sourcing Equipment (PSE), such as a line-powered Ethernet switch or hub, with a CAT 5 Ethernet cable, it receives power over the Ethernet cable. The AirPort Extreme Base Station at a Glance Status lights Internal modem port Ethernet (LAN) port Power adapter port Security slot Ethernet (WAN) port USB printer port Reset button External antenna port LL2870.book Page 6 Thursday, October 28, 2004 12:45 PMChapter 1 Introduction to AirPort 7 AirPort Extreme Base Station Ports Your AirPort Extreme Base Station may have six ports, depending on which model you purchased. Note: If this AirPort Extreme Base Station did not come with a power adapter and you don’t plan to use PoE, you can purchase a base station power adapter from your Appleauthorized dealer, Apple retail stores, or the Apple Store at www.apple.com/store. If the base station supports PoE, it and its mounting bracket conform to UL Standard 2043, “Fire Test for Heat and Visible Smoke Release for Discrete Products and Their Accessories Installed in Air-Handling Spaces,” for placement in the air-handling space above suspended ceilings. Using PoE allows you to install a base station in places away from a standard electrical outlet. For more information about using PoE, see the document “Designing AirPort Extreme Networks,” or “AirPort Networks for Windows,” that came on the AirPort CD. The documents are also available at www.apple.com/airportextreme. To determine if your base station supports PoE, check the label on the bottom of the base station. Note: To use the base station in an air-handling space above suspended ceilings, you must connect the Ethernet WAN port to an 802.3af-compliant PSE with a plenum-rated Ethernet cable. You cannot use the AC power adapter to power a base station installed in an air-handling space. If you connect an external antenna to a base station mounted in an air-handling space, make sure it is plenum-rated. See the documentation that came with the antenna. 10/100Base-T Ethernet WAN port Connect a DSL or cable modem, or connect to an existing Ethernet network with Internet access. G 10/100Base-T Ethernet LAN port Connect local Ethernet computers (computers without Internet access) and printers, or other Ethernet devices, such as a hub or a switch. W Internal modem port (on some models) Connect one end of a phone cord to the internal modem port and the other end to a standard telephone jack. Universal Serial Bus (USB) printer port Connect a USB printer so that computers connected to the AirPort network can share the printer. External antenna port Connect an Apple-certified external antenna to extend the range of the wireless network. ¯ Power adapter port Connect one end of the AirPort Extreme Base Station power adapter to the port and the other end to an electrical outlet. Security slot You can purchase a security cable and lock to secure your AirPort Extreme Base Station. LL2870.book Page 7 Thursday, October 28, 2004 12:45 PM8 Chapter 1 Introduction to AirPort About the AirPort Software To extend the range of your network, you can use AirPort Admin Utility to set up multiple base stations in your network connected to one another wirelessly, known as a Wireless Distribution System (WDS), or over Ethernet. You can also extend the range of your wireless network by connecting an Apple-certified external antenna to the antenna port. If you connect a USB printer to the base station, computers on the AirPort network can print to it by selecting the printer via Rendezvous in Printer Setup Utility, located in Applications/Utilities on a Macintosh. You must use Mac OS X v10.2.3 or later, or Windows XP or Windows 2000, to print to a USB printer via an AirPort Extreme Base Station. For information about setting up a computer using Windows XP or Windows 2000, see the document “AirPort Networks for Windows,” that came on the AirPort CD. Note: If the base station is set up to receive power over the Ethernet WAN port, do not connect a printer to the USB port. You cannot print to a USB printer if the base station is powered over Ethernet. AirPort Setup Assistant Use the AirPort Setup Assistant to configure the AirPort Extreme Base Station and to set up your computer to use AirPort. The Assistant is located in Applications/Utilities on a computer using Mac OS X. AirPort Admin Utility AirPort Admin Utility is an advanced tool for setting up and managing the AirPort Extreme Base Station. Use AirPort Admin Utility to adjust network, routing, and security settings and other advanced options. AirPort Admin Utility is located in Applications/ Utilities on a computer using Mac OS X, and in Start > All Programs > AirPort on a computer using Windows XP or Windows 2000. AirPort status menu in the menu bar Use the AirPort status menu to switch quickly between AirPort networks, monitor the signal quality of the current network, create a Computer-to-Computer network, and turn AirPort on and off. The AirPort status menu in the menu bar is part of AirPort for Max OS X. If your base station supports Power over Ethernet, the following Mac OS X applications are included on the AirPort Management Tools CD. AirPort Management Utility AirPort Management Utility allows network administrators to set up and manage multiple base stations from a single location. AirPort Client Monitor The AirPort Client monitor application monitors the signal strength and transmit rate of wireless client computers. LL2870.book Page 8 Thursday, October 28, 2004 12:45 PM2 9 2 Setting Up Your AirPort Extreme Base Station Use the information in this chapter to set up your AirPort Extreme Base Station. Before you set up the AirPort Extreme Base Station for Internet access, make sure that: • You have a computer with an AirPort Card or an AirPort Extreme Card, or a compatible Wi-Fi card installed in a computer using Windows XP or Windows 2000. • Your computer has the latest version of the AirPort software installed. For the latest information on AirPort software, check Software Update in System Preferences or the following Apple websites: • Apple AirPort website at www.apple.com/airportextreme • Apple Support website at www.apple.com/support • You have an account with an Internet service provider (fees may apply) or you have Internet access through a network. For more information on using AirPort with your Internet account, contact your Internet service provider (ISP) or go to the Apple Service & Support website at support.apple.com. • You have a suitable location for your AirPort Extreme Base Station. You can place your AirPort Extreme Base Station on a desk, bookcase, or other flat surface, or you can mount it on a wall. Place your base station in the center of your home or office, away from any source of interference or signal blockage, such as a microwave oven or large metal appliances, and close to a power outlet. If the base station supports PoE, it is suitable for use in environmental air-handling spaces (in accordance with section 300.22(C) of the National Electrical Code and 12-010 of the Canadian Electrical Code), and capable of receiving power over Ethernet. You can install it in a ceiling air-handling space, away from a power outlet. If you install the base station in an air-handling space, you need to connect the Ethernet WAN port to 802.3af-compliant Power Sourcing Equipment (PSE) with a plenum-rated Ethernet cable. If you connect the base station power adapter to an outlet, the Ethernet WAN port no longer receives power from a PSE. LL2870.book Page 9 Thursday, October 28, 2004 12:45 PM10 Chapter 2 Setting Up Your AirPort Extreme Base Station If you use an Ethernet LAN for Internet access, such as in a school or office, connect the Ethernet cable to the 10/100Base-T Ethernet LAN (G) port on the AirPort Extreme Base Station. Note: The “Distribute IP address” checkbox in the Network pane of AirPort Admin Utility is deselected for AirPort Extreme Base Stations that support Power over Ethernet. By default the base stations are set to be used as a bridge, rather than to distribute IP addresses to AirPort clients. For more information on AirPort Admin Utility and using the 10/100Base-T Ethernet LAN (G) port, see the document “Designing AirPort Extreme Networks,” or “AirPort Networks for Windows,” located on the AirPort CD or at www.apple.com/airportextreme. You can use the AirPort Extreme Base Station to provide Internet access to non-AirPort computers that are not otherwise connected to the Internet by connecting them to the 10/100Base-T Ethernet LAN (G) port on the AirPort Extreme Base Station. The base station must be connected to the Internet by the 10/100Base-T Ethernet WAN ( ) port. Mounting the AirPort Extreme Base Station on a Wall You can use the mounting bracket provided with your AirPort Extreme Base Station to mount the base station on a wall. Follow these steps: 1 Select a location close to power and a network connection. If the base station is UL rated and certified for use in suspended ceilings and airhandling spaces, the base station can be mounted in a ceiling space, away from a power outlet, and powered over Ethernet. If you mount the base station in an airhandling space, plug the base station into 802.3af-compliant Power Sourcing Equipment with a plenum-rated Ethernet cable. 2 Screw the mounting bracket into a wall stud using the two screws that came with the base station. Mounting bracket LL2870.book Page 10 Thursday, October 28, 2004 12:45 PMChapter 2 Setting Up Your AirPort Extreme Base Station 11 3 Locate the two mounting bracket holes on the bottom of the base station. 4 Feed the cables through the mounting bracket and then connect them to the base station. The base station is designed to mount with the ports on the top (Apple logo right side up), with the cables passing behind it through the mounting bracket as shown. Note: The mounting bracket has enough space for six cables (power, two Ethernet cables, USB printer cable, a telephone cable, and external antenna cable). In most cases, only two or three cables are used. Mounting bracket holes LL2870.book Page 11 Thursday, October 28, 2004 12:45 PM5 Carefully insert the bottom two prongs on the mounting bracket into the mounting bracket holes on the bottom of the base station. Clip the top prongs on the mounting bracket around the bottom lip of the base station. Setup Overview Once you’re ready, you can set up the AirPort Extreme Base Station in a few steps: 1 Plug the AirPort Extreme Base Station in to a power outlet and connect it to your Internet networking interface. 2 Use the AirPort Setup Assistant on a Macintosh, or use AirPort Admin Utility on a Windows XP or Windows 2000 computer. Step 1: Connect the AirPort Extreme Base Station 1 Connect the power adapter to the AirPort Extreme Base Station power adapter port and an electrical outlet. Important: Use only the power adapter that came with your AirPort Extreme Base Station. Adapters for other electronic devices may look similar, but they may damage the base station. The AirPort Extreme Base Station turns on when the power adapter is plugged into an electrical outlet. There is no power switch. When you plug in the base station, the status lights glow while the base station starts up. Only the middle light glows when startup is complete. The startup process takes about 30 seconds. See “Monitoring AirPort Extreme Base Station Communication” on page 17 for a complete explanation of the lights on the AirPort Extreme Base Station. 2 Connect the AirPort Extreme Base Station to your DSL or cable modem, Ethernet network, or, if your base station has an internal modem, a standard phone line. • If you have an Internet account that uses a device such as a DSL or cable modem, connect the device to the 10/100Base-T Ethernet WAN ( ) port on the AirPort Extreme Base Station. • If you use an Ethernet LAN for Internet access, such as in a school or office, connect the Ethernet cable to the 10/100Base-T Ethernet LAN (G) port on the AirPort Extreme Base Station. • If you use a standard modem and analog telephone line (the type of telephone line found in most residences) to access the Internet, connect one end of the phone cord to the internal modem (W) port and the other end to your telephone jack. Important: Do not connect the base station to a digital telephone line, such as a PBX telephone system. LL2870.book Page 12 Thursday, October 28, 2004 12:45 PMChapter 2 Setting Up Your AirPort Extreme Base Station 13 If your base station has a built-in modem and you connect to the Internet using it, the base station can provide Internet access to computers connected to both Ethernet ports (WAN and LAN G). Step 2: Use the AirPort Setup Assistant on a Macintosh computer The AirPort Setup Assistant: • Sets up your AirPort network • Configures your computer to access the AirPort network created by the AirPort Extreme Base Station Note: You can’t use the AirPort Setup Assistant to set up some advanced features. Use AirPort Admin Utility, located in Applications/Utilities. To use the AirPort Setup Assistant to configure the AirPort Extreme Base Station: 1 Make sure you have plugged in the base station and the middle light is on. 2 Open the AirPort Setup Assistant (in Applications/Utilities on a Mac, and follow the onscreen instructions. Use AirPort Admin Utility on a Windows XP or Windows 2000 computer See the document “AirPort Networks for Windows” that came on the AirPort CD for detailed instructions for setting up your AirPort Extreme Base Station using AirPort Admin Utility. LL2870.book Page 13 Thursday, October 28, 2004 12:45 PMLL2870.book Page 14 Thursday, October 28, 2004 12:45 PM3 15 3 Using Your AirPort Extreme Base Station The information in this chapter will help you understand how to use your base station and how to get the most from your AirPort network. Use the information provided in this chapter to: • Configure your base station’s Internet connection • Use AirPort Admin Utility to modify advanced base station settings • Monitor your AirPort Extreme Base Station status • Connect to and disconnect from the AirPort network • Connect additional base stations to your AirPort network • Extend the range of your AirPort network Configuring the Base Station The AirPort Setup Assistant provides complete configuration options for most AirPort networks. For advanced settings, you can use AirPort Admin Utility (in Applications/Utilities) to configure your AirPort Extreme Base Station. You can use AirPort Admin Utility to do the following: • Configure your AirPort network, including changing the network name and password and specifying whether users need a password to join your network. • Change the AirPort Extreme Base Station name and password. • Set advanced security settings, like Wi-Fi Protected Access (WPA). • Enter the TCP/IP settings for your AirPort Extreme Base Station. • Set up the way Internet access is provided to computers on the AirPort network. • Set up multiple base stations on a single AirPort network. Note: If your base station does not support PoE, by default it is set to use the Internet Dynamic Host Configuration Protocol (DHCP) and Network Address Translation (NAT) to share a single IP address. If your base station supports PoE, by default it is set up as a bridge, and the “Distribute IP address” checkbox is deselected in the Network pane of AirPort Admin Utility. LL2870.book Page 15 Thursday, October 28, 2004 12:45 PM16 Chapter 3 Using Your AirPort Extreme Base Station Important: If you use AirPort Admin Utility instead of the AirPort Setup Assistant to configure your base station for the first time, you may be asked for a password. The initial password for the AirPort Extreme Base Station is public. See the document “Designing AirPort Extreme Networks,” or “AirPort Networks for Windows,” located on the AirPort CD and at www.apple.com/airportextreme, for indepth information on designing and setting up your AirPort network using the AirPort Setup Assistant and AirPort Admin Utility. If you are setting up larger AirPort Extreme networks with base stations that support PoE, you can also use AirPort Management Utility and AirPort Client Monitor (on the Management Tools CD) to set up and manage multiple base stations. See the document “Managing AirPort Extreme Networks,” located on the Management Tools CD, and at www.apple.com/airportextreme, for information and instructions for setting up, managing, and monitoring larger AirPort Extreme networks. Monitoring the AirPort Extreme Base Station’s Internet Connection Status Use the Internet Connect application, located in the Applications folder on a Macintosh, to monitor the wireless signal level and status of your AirPort Extreme Base Station’s Internet connection, as shown below. Use the Wireless Connection Status menu on a Windows XP or Windows 2000 computer to monitor the wireless signal level. LL2870.book Page 16 Thursday, October 28, 2004 12:45 PMChapter 3 Using Your AirPort Extreme Base Station 17 Monitoring AirPort Extreme Base Station Communication The following table explains the AirPort Extreme Base Station indicator lights. For more information about the base station’s indicator lights, see “Designing AirPort Extreme Networks,” or AirPort Networks for Windows,” located on the AirPort CD, or at www.apple.com/airportextreme. Connecting to the Internet Via the AirPort Network If your computer is connected to an AirPort network that has continuous Internet access via Ethernet, DSL, or a cable modem, you may already be connected to the Internet and can open and use any application that requires an Internet connection, such as a web browser or email application. If you are not connected, open Internet Connect, located in the Applications folder, click AirPort in the toolbar, and click Connect. Light number Indicator Status 1 Flashing The AirPort Extreme Base Station is communicating via AirPort. 2 Steady glow The AirPort Extreme Base Station is receiving power and is in normal operating mode. 3 Flashing The AirPort Extreme Base Station is communicating via the LAN port. 1 2 3 LL2870.book Page 17 Thursday, October 28, 2004 12:45 PM18 Chapter 3 Using Your AirPort Extreme Base Station Connecting Additional Base Stations to Your AirPort Network You can connect additional AirPort Extreme Base Stations to extend the range of your wireless network. You can connect the base stations wirelessly or using Ethernet. A network with base stations connected using Ethernet is known as a roaming network. Connecting base stations wirelessly creates what is known as a Wireless Distribution System (WDS). See the document “Designing AirPort Extreme Networks,” or “AirPort Networks for Windows” for more information about setting up a roaming network or extending your network with WDS. Connecting Multiple Base Stations to Power Sourcing Equipment (PSE) If your base stations support PoE, you can connect multiple base stations to an 802.3afcompliant Ethernet device (known as a PSE), and send power and a network or Internet connection over category 5 Ethernet cables. Receiving power over the base station’s Ethernet connection eliminates extra cables and the need to locate the base station near a power outlet. Base stations that support PoE meet flammability classification standards and are UL listed for use above suspended ceilings and in air-handling spaces. The US National Electric Code (NEC) and the Canadian Electrical Code (CEC) require that you use plenum-rated Ethernet cables in air-handling spaces. Extending the Range of Your AirPort Network In addition to adding base stations to your network, you can attach an Apple-certified external antenna to the base station to extend your network’s range. External antennas are available from your Apple-authorized dealer, Apple retail stores, or the Apple Store at store.apple.com. External antennas may not be permitted in some regions outside the US. If your base station supports PoE and is mounted in an air-handling space and receives power over the Ethernet WAN port, do not connect an external antenna unless it is plenum-rated and conforms to UL Standard 2043. Note: Before connecting or disconnecting an external antenna, you must unplug the base station’s power adapter, connect or disconnect the antenna, and then plug the base station back in to its power source. LL2870.book Page 18 Thursday, October 28, 2004 12:45 PMChapter 3 Using Your AirPort Extreme Base Station 19 Controlling the Range of Your AirPort Network You can also shorten the range of your AirPort network by adjusting the power transmitted to the radio in the base station. This might be useful if you want to control access to the network by restricting the range to a single room, for example. To shorten the range of your AirPort network: 1 Open AirPort Admin Utility, in Applications/Utilities on a Macintosh and in Start > All Programs > AirPort on a Windows XP or Windows 2000 computer. 2 Select your base station and click Configure. 3 On a Macintosh, click Wireless Options. On a Windows XP or Windows 2000 computer, click AirPort. 4 Choose a percentage from the Transmitter Power slider. More Information About AirPort You can find more information about AirPort in the following locations: • AirPort Help Look in AirPort Help for information on setting up an AirPort network, using an AirPort Base Station, editing base station settings, avoiding sources of interference, locating additional information on the Internet, and more. Choose Help > Mac Help, and then choose Library > AirPort Help. • “Designing AirPort Extreme Networks” For in-depth information on configuring AirPort networks, see the “Designing AirPort Extreme Networks” document, located at www.apple.com/airportextreme. • “Managing AirPort Extreme Networks” For in-depth information on setting up and managing multiple base stations in AirPort networks, see the “Managing AirPort Extreme Networks” document, located at www.apple.com/support/airportextreme. • “AirPort Networks for Windows” For in-depth information on configuring AirPort networks from a Microsoft Windows computer, see the “AirPort Networks for Windows” document, located at www.apple.com/airportextreme. • AirPort website www.apple.com/airportextreme • Apple Support website www.apple.com/support LL2870.book Page 19 Thursday, October 28, 2004 12:45 PMLL2870.book Page 20 Thursday, October 28, 2004 12:45 PM4 21 4 Basic Network Designs You can set up your AirPort Extreme Base Station just about anywhere and use it for Internet access and wireless networking. You need only a connection to the Internet and a computer with wireless capabilities. You can even add non-wireless computers to the network by connecting them to the base station through the built-in Ethernet LAN (G) port. Connect a USB printer to the base station, and all the computers on the network using Mac OS X v10.2.3 or later, both wired and wireless, can share the printer. If you want to extend the range of your AirPort network, connect an Apple-certified external antenna to the base station antenna port. Apple-certified external antennas for the AirPort Extreme Base Station are available from your Apple-authorized dealer, Apple retail stores, or the Apple Store at store.apple.com. Note: External antennas may not be permitted in some regions. Do not connect an external antenna to a base station that supports PoE and is mounted in the air space above a ceiling. This chapter explains how to set up your base station: • In your home or small office with an Ethernet or dial-up connection to the Internet • In school, where you might have both a broadband and an Ethernet connection • In a business or school using Power over Ethernet LL2870.book Page 21 Thursday, October 28, 2004 12:45 PM22 Chapter 4 Basic Network Designs Setting Up a Home Office Network If you are setting up an AirPort network in your home or small office and you have a broadband DSL or cable modem connection to the Internet, and an existing Ethernet network, you may need the following items: • An AirPort Extreme Base Station or multiple base stations • A DSL or cable modem with Internet access • AirPort- or other wireless-equipped computers • An optional Ethernet network The following illustration is an example of an AirPort network in an office. The AirPort Extreme Base station is connected by the Ethernet WAN ( ) port to the DSL or cable modem (if your base station came with a built-in modem, you can use it to connect). The base station shares its Internet connection with the AirPort-equipped computers wirelessly and with computers connected to the Ethernet LAN (G) port. For more information on AirPort Extreme network designs, see “Designing AirPort Extreme Networks,” located at www.apple.com/airport. For information on managing larger AirPort Extreme networks, see “Managing AirPort Extreme Networks,” located at www.apple.com/support/airport. To the Internet To Ethernet (LAN) To USB printer Power adapter USB LL2870.book Page 22 Thursday, October 28, 2004 12:45 PMChapter 4 Basic Network Designs 23 Setting Up a Network at School If you are setting up a network at school, and have a broadband DSL or cable modem connection to the Internet, and an existing Ethernet network, you may need the following items: • An AirPort Extreme Base Station or multiple base stations • A DSL or cable modem with Internet access • AirPort- or other wireless-equipped computers • An optional Apple-certified external antenna The following illustration is an example of an AirPort network in a school with multiple rooms or buildings. The AirPort Extreme Base Stations are set up as a Wireless Distribution System (WDS), with the main base station connected by the Ethernet WAN ( ) port to the DSL or cable modem. The main base station shares its Internet connection with the wireless computers in the room, or with computers connected to the main base station’s Ethernet LAN (G) port. The main base station also shares the Internet connection with the relay base station in the other room or building. The relay base station transfers the Internet connection to a remote base station set up in a third building. The relay and remote base stations can be set up to share the Internet connection with wireless computers in the room, or computers connected to the base station’s Ethernet LAN (G) port. LL2870.book Page 23 Thursday, October 28, 2004 12:45 PM24 Chapter 4 Basic Network Designs USB Main To the Internet To Ethernet (LAN) Power adapter To USB printer Remote Relay LL2870.book Page 24 Thursday, October 28, 2004 12:45 PMChapter 4 Basic Network Designs 25 Connecting AirPort Base Stations Using Power Over Ethernet (PoE) You can connect multiple base stations that support PoE to 802.3af-compliant Power Sourcing Equipment (PSE), and send power and a network or Internet connection over Ethernet cables. Receiving power over the Ethernet connection eliminates extra cables and the need to locate the base station near a power outlet. The following illustration is an example of an AirPort network in a business or school with multiple rooms or buildings. Plenum-rated Ethernet cables connect to the Ethernet WAN ( ) ports on the base stations and to an 802.3af-compliant PSE. The base stations are mounted in the ceiling air-handling space, and are secure and out of sight. When the base stations receive power and a network connection over the WAN port, the USB port is disabled. You can connect the Ethernet LAN port to a computer or other Ethernet device, but power does not travel to the Ethernet LAN port. Important: Do not connect an external antenna to a base station mounted in an airhandling space above a suspended ceiling unless it is plenum-rated and conforms to UL Standard 2043. LL2870.book Page 25 Thursday, October 28, 2004 12:45 PM26 Chapter 4 Basic Network Designs To 802.3af-compliant PSE Base stations mounted in air-handling space 802.3af-compliant Power Sourcing Equipment (PSE) connected to a network Plenum-rated Ethernet cables AC power outlet Plenum-rated Ethernet cables Base stations mounted in air-handling space LL2870.book Page 26 Thursday, October 28, 2004 12:45 PM5 27 5 Troubleshooting Use the information in this chapter if you are having trouble setting up your AirPort Extreme Base Station. If the AirPort Setup Assistant can’t detect the proper AirPort hardware Make sure that the computer you are using has an AirPort Card or an AirPort Extreme Card installed. If you recently installed the card, shut down your computer and make sure the card is properly installed. Make sure that the AirPort antenna cable is securely connected to the card (you should hear a click when the antenna is connected securely). Make sure that the other end of the card is firmly inserted into the connector in the AirPort Card slot. If you forget your AirPort network or base station password You can clear the AirPort network or base station password by resetting the base station. Follow these steps: 1 On a Mac, open Network preferences. Choose AirPort from the Show pop-up menu and choose Using DHCP from the Configure pop-up menu. On a computer using Windows XP or Windows 2000, open Control Panel from the Start menu, right-click Wireless Network Connection and choose Properties. Click Internet Protocol (TCP/IP) and click Properties. Make sure “Obtain an IP address automatically” is selected. 2 Press and hold the reset button for one full second. Reset button LL2870.book Page 27 Thursday, October 28, 2004 12:45 PM28 Chapter 5 Troubleshooting The middle light flashes, indicating that the base station is in reset mode. The base station remains in reset mode for five minutes. If you do not make your changes within five minutes of pressing the reset button, you must reset it again. 3 Use the AirPort status menu in the menu bar to select the network created by the base station (the network name does not change). 4 Open AirPort Admin Utility (in Applications/Utilities on a Mac, and in Start > All Programs > AirPort on a Windows computer). 5 Select your base station and click Configure. 6 In the dialog that appears, make the following changes: • Reset the AirPort Extreme Base Station password. • Turn encryption on to activate password protection for your AirPort network. If you turn on encryption, enter a new password for your AirPort network. 7 Click OK. The base station restarts to load the new settings. Note: While the base station is in reset mode, access control and RADIUS settings are temporarily interrupted. All of the base station settings will be available after the base station has restarted. If your base station isn’t responding Try unplugging the base station and plugging it back in to a power outlet. If power is supplied over Ethernet, make sure the cables are properly connected and the PSE is plugged in and working correctly. If your base station stops responding completely, you may need to reset it to the factory default settings. This erases all of the settings you’ve made and resets them to the settings that came with the base station. To return the base station to the factory settings: m Press and hold the reset button for five full seconds. The base station restarts with the following settings: • The base station receives its IP address using DHCP. • The network name reverts to Apple Network XXXXXX (where X is a letter or number). • The base station password returns to public. Important: Resetting the base station to factory defaults erases all the settings you have entered for the base station, including access control and RADIUS settings. LL2870.book Page 28 Thursday, October 28, 2004 12:45 PMChapter 5 Troubleshooting 29 If you move your AirPort Extreme Base Station to a location on your network with a different subnet and lose communication with the base station Your AirPort Extreme Base Station may have an invalid IP address. 1 Make sure that your computer is set to access the network from the new location (where you moved the AirPort Extreme Base Station) and that it is in range of the base station. 2 Make sure that the computer is set to use AirPort. 3 Use the AirPort Setup Assistant to reconfigure the base station. Important: You cannot use the AirPort Setup Assistant if you have used AirPort Admin Utility to turn off Internet sharing for your base station. If Internet sharing is turned off, you need to reset your base station and enter a new IP address. See “If you forget your AirPort network or base station password” on page 27. If your printer isn’t responding If you connected a printer to the USB port on the base station and the computers on the AirPort network can’t print, try doing the following: 1 Make sure the printer is plugged in and turned on. 2 Make sure the cables are securely connected to the printer and to the base station’s USB port. 3 Make sure the printer is selected in the Printer List on client computers. To do this: a Open Printer Setup Utility, located in Applications/Utilities. b If the printer is not in the list, click Add. c Choose Rendezvous from the pop-up menu. d Select the printer and click Add. Note: If the base station is set up to receive power over Ethernet, the USB port is disabled. You cannot print to a USB printer connected to the USB port if the base station is powered over Ethernet. LL2870.book Page 29 Thursday, October 28, 2004 12:45 PMLL2870.book Page 30 Thursday, October 28, 2004 12:45 PM 31 Appendix AirPort Extreme Base Station Specifications AirPort Specifications • Wireless Data Rate: Up to 54 megabits per second (Mbps) • Range: Up to 150 feet (45 meters) in typical use (varies with building) • Frequency Band: 2.4 gigahertz (GHz) • Radio Output Power: 15 dBm (nominal) • Standards: Compliant with 802.11 HR Direct Sequence Spread Spectrum (DSSS) 11 Mbps standard, 802.11 DSSS 1 and 2 Mbps standard, and 802.11g specification Interfaces • RJ-45 Ethernet WAN connector for built-in 10/100Base-T ( ). The WAN port may accept power as a Class 0 IEEE 802.3af-compliant Powered Device (PD). • RJ-45 Ethernet LAN connector for built-in 10/100Base-T (G) • Universal Serial Bus (USB) printing ( ) • AirPort Environmental Specifications • Operating Temperature: 32° F to 95° F (0° C to 35° C) • Storage Temperature: –13° F to 140° F (–25° C to 60° C) • Relative Humidity (Operational): 20% to 80% relative humidity • Relative Humidity (Storage): 10% to 90% relative humidity, noncondensing • Operating Altitude: 0 to 10,000 feet (0 to 3048 m) • Maximum Storage Altitude: 15,000 feet (4572 m) Size and Weight • Diameter: 6.9 inches (175 mm) • Height: 3.2 inches (80 mm) • Weight: 1.25 pounds (565 grams) not including the mounting bracket LL2870.book Page 31 Thursday, October 28, 2004 12:45 PM32 Appendix AirPort Extreme Base Station Specifications Base Station LED Sequences The following table explains the base station’s light sequences and what they indicate. Left Center Right Status/description Off Off Off The base station is unplugged or has failed. If the base station is plugged in and all lights are off, contact your Apple-authorized service provider. On On On The base station is in self-check mode. Rapid sequenced flashing, right-to-left The base station is starting up. Slowly flashing Slowly flashing Slowly flashing The base station has failed the power-on self-test. Contact your Apple-authorized service provider. Off Flashing slowly Off The base station is being reset. The network and base station passwords are reset to public. Off Flashing three times Off The base station is being reset, and all settings are returned to their factory defaults. Off/Flashing On Off/Flashing Left and right flashing indicates normal network activity. The left LED flashing indicates AirPort wireless activity and the right LED flashing indicates Ethernet or network activity. LL2870.book Page 32 Thursday, October 28, 2004 12:45 PM 33 Communications Regulation Information FCC Declaration of Conformity This device complies with part 15 of the FCC rules. Operation is subject to the following two conditions: (1) This device may not cause harmful interference, and (2) this device must accept any interference received, including interference that may cause undesired operation. See instructions if interference to radio or television reception is suspected. Radio and Television Interference The equipment described in this manual generates, uses, and can radiate radio-frequency energy. If it is not installed and used properly—that is, in strict accordance with Apple’s instructions—it may cause interference with radio and television reception. This equipment has been tested and found to comply with the limits for a Class B digital device in accordance with the specifications in Part 15 of FCC rules. These specifications are designed to provide reasonable protection against such interference in a residential installation. However, there is no guarantee that interference will not occur in a particular installation. You can determine whether your computer system is causing interference by turning it off. If the interference stops, it was probably caused by the computer or one of the peripheral devices. If your computer system does cause interference to radio or television reception, try to correct the interference by using one or more of the following measures: • Turn the television or radio antenna until the interference stops. • Move the computer to one side or the other of the television or radio. • Move the computer farther away from the television or radio. • Plug the computer into an outlet that is on a different circuit from the television or radio. (That is, make certain the computer and the television or radio are on circuits controlled by different circuit breakers or fuses.) If necessary, consult an Apple-authorized service provider or Apple. See the service and support information that came with your Apple product. Or, consult an experienced radio/television technician for additional suggestions. Important: Changes or modifications to this product not authorized by Apple Computer, Inc., could void the FCC Certification and negate your authority to operate the product. This product was tested for FCC compliance under conditions that included the use of Apple peripheral devices and Apple shielded cables and connectors between system components. It is important that you use Apple peripheral devices and shielded cables and connectors between system components to reduce the possibility of causing interference to radios, television sets, and other electronic devices. You can obtain Apple peripheral devices and the proper shielded cables and connectors through an Apple-authorized dealer. For non-Apple peripheral devices, contact the manufacturer or dealer for assistance. Responsible party (contact for FCC matters only): Apple Computer, Inc., Product Compliance, 1 Infinite Loop M/S 26-A, Cupertino, CA 95014-2084, 408-974-2000. Use in Air-Handling Spaces This device has been designed and tested for use in environmental air handling spaces, in accordance with Section 300.22(C) of the National Electrical Code, and Sections 2-128, 12-010(3), and 12-100 of the Canadian Electrical Code, Part 1, C22.1. Peut étre utilisé dans des gaines transportant de l’air traité, coonformément à la section 300.22(C) du National Electrical Code et aux articles 2-128, 12- 010(3) et 12-100 du Code Canadien de l’électricité, Premiére partie C22.1. Industry Canada Statement This Class B device meets all requirements of the Canadian interference-causing equipment regulations. Cet appareil numérique de la Class B respecte toutes les exigences du Règlement sur le matériel brouilleur du Canada. LL2870.book Page 33 Thursday, October 28, 2004 12:45 PM34 VCCI Class B Statement Europe — EU Declaration of Conformity Complies with European Directives 72/23/EEC, 89/336/EEC, 1999/5/EC See http://www.apple.com/euro/compliance/ © 2004 Apple Computer, Inc. All rights reserved. Apple, the Apple logo, AirPort, AppleTalk, Mac, and Mac OS are trademarks of Apple Computer, Inc., registered in the U.S. and other countries. Rendezvous is a trademark of Apple Computer, Inc. AppleCare and AppleStore are service marks of Apple Computer, Inc., registered in the U.S. and other countries. Wi-Fi is a registered certification mark, and Wi-Fi Protected Access is a certification mark of the Wi-Fi Alliance. LL2870.book Page 34 Thursday, October 28, 2004 12:45 PMLL2870.book Page 35 Thursday, October 28, 2004 12:45 PMwww.apple.com/airport www.apple.com/support/airport 034-2870-A Printed in XXXX LL2870.book Page 36 Thursday, October 28, 2004 12:45 PM LiveType 2 User ManualK Apple Inc. Copyright © 2005 Apple Inc. All rights reserved. Your rights to the software are governed by the accompanying software license agreement. The owner or authorized user of a valid copy of Final Cut Studio software may reproduce this publication for the purpose of learning to use such software. No part of this publication may be reproduced or transmitted for commercial purposes, such as selling copies of this publication or for providing paid for support services. The Apple logo is a trademark of Apple Inc., registered in the U.S. and other countries. Use of the “keyboard” Apple logo (Shift-Option-K) for commercial purposes without the prior written consent of Apple may constitute trademark infringement and unfair competition in violation of federal and state laws. Every effort has been made to ensure that the information in this manual is accurate. Apple is not responsible for printing or clerical errors. Note: Because Apple frequently releases new versions and updates to its system software, applications, and Internet sites, images shown in this book may be slightly different from what you see on your screen. Apple Inc. 1 Infinite Loop Cupertino, CA 95014–2084 408-996-1010 www.apple.com Apple, the Apple logo, AppleWorks, Final Cut, Final Cut Pro, Final Cut Studio, FireWire, Keynote, LiveType, Mac, Macintosh, and QuickTime are trademarks of Apple Inc., registered in the U.S. and other countries. Finder is a trademark of Apple Inc. AppleCare is a service mark of Apple Inc., registered in the U.S. and other countries. Helvetica is a registered trademark of Heidelberger Druckmaschinen AG, available from Linotype Library GmbH. Other company and product names mentioned herein are trademarks of their respective companies. Mention of third-party products is for informational purposes only and constitutes neither an endorsement nor a recommendation. Apple assumes no responsibility with regard to the performance or use of these products. 3 1 Contents Preface 7 An Introduction to LiveType 7 How Does Titling Work? 8 A Realm of Creative Possibilities 9 Workflow for Creating Titles 10 About This Manual 10 LiveType Onscreen User Manual 11 Apple Websites Chapter 1 13 The LiveType Interface 14 Canvas 20 Inspector 25 Media Browser 26 Timeline 28 LiveType Media Files Chapter 2 31 Setting Up a Project 31 Templates 33 Starting a New Project and Setting Defaults 34 Setting Project Properties Chapter 3 41 Adding a Background 41 Setting a Background Color 42 Adding a Background Texture 43 Importing a Background Movie or Still Image 45 Considerations for Rendering the Background Chapter 4 47 Working With Tracks 48 Positioning Tracks in the Canvas 49 Creating Angles and Curves 51 Linking Endpoints 52 Adding, Copying, and Deleting Tracks 53 Working With Tracks in the Timeline4 Contents Chapter 5 57 Working With Text 57 Inserting Text 60 Adjusting the Timing of LiveFonts 62 Formatting Text 68 Enhancing Text With Styles 72 Creating a Matte 77 Modifying Individual Characters 78 Disabling Fonts in Mac OS X Chapter 6 79 Working With Objects, Textures, and Imported Elements 80 Working With LiveType Objects 81 Working With LiveType Textures 82 Importing Graphics, Images, and Movies 83 Transforming Objects, Textures, and Imported Elements Chapter 7 87 Working With Effects and Keyframe Animation 88 Preset Effects 88 Applying Preset Effects 90 Adjusting the Timing of an Effect 93 Changing the Order of Effects 93 Duplicating Effects and Tracks 93 Modifying a Preset Effect 103 Creating a New Effect From Scratch Chapter 8 109 Previewing and Fully Rendering Your Titling Movie 109 Previewing Your Work 112 Optimizing Preview Performance 113 Rendering, Saving, and Exporting Your Titling Movie Chapter 9 117 Advanced Design Techniques 117 Words Within Words 119 Warping Shadows and Glows 121 Track Curves 123 Creative Use of Special Characters 126 LiveFonts and Layers 128 Creating Scrolls and Crawls UP01103TOC.fm Page 4 Monday, March 7, 2005 7:23 PMContents 5 Appendix A 131 Solutions to Common Problems and Customer Support 131 Frequently Asked Questions 133 Apple Applications Page for Pro Apps Developers 134 Calling AppleCare Support Appendix B 135 Creating and Editing EffectScripts 135 Header 135 Default Timing 136 Keyframes 140 Sample EffectScripts Glossary 143 Index 149 UP01103TOC.fm Page 5 Monday, March 7, 2005 7:23 PMUP01103TOC.fm Page 6 Monday, March 7, 2005 5:05 PM 7 Preface An Introduction to LiveType Welcome to LiveType, a special-effects titling application that’s powerful, easy to use, and completely versatile— whether you’re creating movie titles and credits, broadcast ads, or web banners. Producing dynamic video titles—titles that really pop—can be a painstaking process, fraught with manual adjustments and keyframe stacks daunting even to experienced animators. With LiveType, you can create phenomenal results, in the output format you require, with a fraction of the effort. How Does Titling Work? Traditionally, titling was the term for adding text to film. The evolution of digital graphics and video technologies has expanded the definition, which now includes just about any combination of text and images you want to add to a movie. Titling is the process of creating a digital overlay, which is added to edited footage in your nonlinear editor (NLE), or compositing program. LiveType is the design studio where you generate titles to import into Final Cut Pro. Alpha channel technology is the basis of titling. Most compositing and animation programs allow you to create art with an alpha channel. In addition, most NLEs use alpha channels they detect in an image or movie to properly lay the element over video. An alpha channel represents eight bits of grayscale pixel information in a 32-bit file. The eight grayscale bits determine which portions of the image to superimpose over other layers. White alpha-channel pixels make the superimposed image completely opaque, while black pixels make the overlay completely transparent, or invisible. Gray levels represent varying levels of opacity. LiveType automatically creates an alpha channel for your project when you render it with a transparent background.8 Preface An Introduction to LiveType A Realm of Creative Possibilities LiveType has revolutionized titling in two major ways. First, it introduced 32-bit LiveFonts, a new approach to text animation in which every character of a font is a separate, animated movie. Second, LiveType handles effects and animation with greater ease than any other titling application. Animated Fonts, Objects, and Textures Three types of animated media are included in LiveType:  LiveType objects are animated graphics.  LiveType textures are moving images used to fill backgrounds, text, or objects.  LiveFonts are complete, animated character sets. All of these elements move inherently, even before you apply motion paths and special effects to them. LiveType comes with dozens of LiveFonts and hundreds of objects and textures. What’s more, you can create your own animated fonts using the LiveType FontMaker utility, building characters using virtually any graphical object—from 3D animations and images created in Photoshop to video clips—and apply effects to them, just as you would to words. Effects Handling Effects in LiveType are handled as separate entities—“packages” encompassing movement, transformation, and timing parameters—that can be applied to any number of elements in the Canvas. You can take advantage of more than 100 customizable effects that come with LiveType, including fades, zooms, rotations, and motion paths. Or you can create your own styles by adjusting existing effects or building them from scratch. From an animation standpoint, LiveType is easier to work with than other titling applications, since one keyframe marker contains all the parameters for an element at a point in time, eliminating the complexity of long keyframe stacks. And powerful timing features allow you to control every aspect of your animation. In addition to basic functions such as loop, speed, and duration, LiveType allows you to sequence your effects. Sequencing lets you animate characters in a line of text individually, with their own timing elements, so you’re not constrained to blocks of text that fly around the screen as a unit. Whether you’re combining prebuilt elements or generating all the pieces yourself, you can create wholly original, eye-catching compositions with surprisingly little effort.Preface An Introduction to LiveType 9 Workflow for Creating Titles Video production is typically approached in layers from back to front, starting with shooting and editing the footage, then building in effects, then applying titles and sound. Likewise, your approach to title creation should be loosely approached from back to front. Of course, because the design process is fluid, there is no hard-and-fast prescription, but the following steps give you a sense of what’s involved for a typical project. Step 1: Configure the working environment  Set the output resolution, frame rate, and other project properties.  Set up the grid, guides, and rulers in the Canvas, according to your working preferences. Step 2: Apply a background, if any Step 3: Create elements (text or objects) in the Canvas, one by one  Position and shape a track for the element.  Add an element to the track.  Select a font.  Adjust attributes and apply styles to the element. Step 4: Animate the elements  Define the movie duration.  Apply effects and adjust the timing.  Customize the animation with keyframe adjustments. Step 5: Preview and fine-tune the movie Step 6: Render the final movie for compositing into your video Step 7: Export the movie to an alternative format, if needed You may be able to save considerable time by taking advantage of LiveType templates—project files provided with the software that offer many examples of titling formats. One might suit your needs with few changes, or you may find that certain elements within a template are useful, which you can copy into your own project. More about templates can be found in Chapter 2, “Setting Up a Project,” on page 31.10 Preface An Introduction to LiveType About This Manual Because LiveType is a creative tool, documentation can only go so far in describing its potential. This manual provides a detailed description of the LiveType interface, features, and functionality, and introduces you to the built-in resources and templates to give you a sense of the versatility of this product. In the end, you are limited only by your own creative vision, and the way to push the limits of LiveType is to jump in and start creating. This manual begins with a description of the interface, followed by a series of chapters that explain the tasks you’ll need to perform, as well as advanced techniques. Note: This user manual is written for people with a rudimentary understanding of film or video production. Experienced users will be quite familiar with all such terminology herein. Others will find that most terms are defined in context, and the glossary at the end of this manual may be helpful as well. LiveType Onscreen User Manual The LiveType onscreen user manual allows you to access information directly onscreen while you’re working in LiveType. To view the onscreen user manual, choose Help > LiveType User Manual. The onscreen user manual is a fully hyperlinked version of the user manual, enhanced with many features that make locating information quick and easy.  The home page provides quick access to various features, including Late-Breaking News, the index, and the LiveType website.  A comprehensive bookmark list allows you to quickly choose what you want to see and takes you there as soon as you click the link. In addition to these navigational tools, the onscreen user manual gives you other means to locate information quickly:  All cross-references in the text are linked. You can click any cross-reference and jump immediately to that location. Then, you can use the navigation bar’s Back button to return to where you were before you clicked the cross-reference.  The table of contents and index are also linked. If you click an entry in either of these sections, you jump directly to that section of the user manual.  You can also use the Find dialog to search the text for specific words or a phrase. LiveType Help also contains information about issues with third-party software and known bugs. This information is found in the Late-Breaking News section of LiveType Help.Preface An Introduction to LiveType 11 To access Late-Breaking News: m Choose Help > Late-Breaking News. Note: You must be connected to the Internet to download the Late-Breaking News file. Additionally, LiveType Help contains a link to the Creating LiveFonts PDF file. This document details the process of creating custom LiveFonts for use with LiveType. To access the Creating LiveFonts PDF file: m Choose Help > Creating LiveFonts. Apple Websites There are a variety of discussion boards, forums, and educational resources related to LiveType on the web. LiveType Website For general information and updates, as well as the latest news on LiveType, go to:  http://www.apple.com/finalcutpro/livetype.html Apple Service and Support Website For software updates and answers to the most frequently asked questions for all Apple products, including LiveType, go to:  http://www.apple.com/support You’ll also have access to product specifications, reference documentation, and Apple and third-party product technical articles. For LiveType support information, go to:  http://www.apple.com/support/livetype/index.html Other Apple Websites Start at the Apple homepage to find the latest and greatest information about Apple products:  http://www.apple.com QuickTime is industry-standard technology for handling video, sound, animation, graphics, text, music, and 360-degree virtual reality (VR) scenes. QuickTime provides a high level of performance, compatibility, and quality for delivering digital video. Go to the QuickTime website for information on the types of media supported, a tour of the QuickTime interface, specifications, and more:  http://www.apple.com/quicktime12 Preface An Introduction to LiveType FireWire is one of the fastest peripheral standards ever developed, which makes it great for use with multimedia peripherals, such as video camcorders and the latest highspeed hard disk drives. Visit this website for information about FireWire technology and available third-party FireWire products:  http://www.apple.com/firewire For information about seminars, events, and third-party tools used in web publishing, design and print, music and audio, desktop movies, digital imaging, and the media arts, go to:  http://www.apple.com/pro For resources, stories, and information about projects developed by users in education using Apple software, including LiveType, go to:  http://www.apple.com/education Go to the Apple Store to buy software, hardware, and accessories direct from Apple and to find special promotions and deals that include third-party hardware and software products:  http://www.apple.com/store1 13 1 The LiveType Interface The LiveType interface consists of four primary windows—the Canvas, the Inspector, the Media Browser, and the Timeline.  Canvas: This is where projects take shape. You use it to position text and objects, create motion paths, and view the results as you design.  Inspector: A toolbox of settings and parameters, including virtually every option for building and customizing your titling creations.  Media Browser: This area provides access to all the fonts, textures, objects, and effects you’ll use to create your titles.  Timeline: This is where you manage the frame-by-frame action of your titling projects. Animation keyframes are created and adjusted in the Timeline, allowing you to orchestrate the movement of your titling elements. Canvas Inspector Media Browser Timeline14 Chapter 1 The LiveType Interface The four windows float freely, and can be moved and resized to suit your working preferences. To restore the default layout of LiveType: m Choose Window > Apply Default Layout. Canvas The Canvas is your creative working environment, reflecting the output dimensions you configure in the Project Properties dialog. (See “Setting Project Properties” on page 34.) Whether you are working in HDTV, NTSC, PAL, or any other format, the Canvas is designed to help you lay out and view your titling project easily. About the Canvas Interface There are various interface elements and controls in the Canvas, outlined below. Background When you first open LiveType, the default checkerboard pattern in the Canvas represents a transparent background, allowing alpha channel titles to overlay video footage when composited in a nonlinear editor (NLE) such as Final Cut Pro. You can set the background as any combination of the following:  Transparent  Solid color  Animated texture or object  Still image  Movie Background (transparent) Action safe guidelines Track, showing multiple lines of text on one track Zoom pop-up menu Title safe guidelines Transport controlsChapter 1 The LiveType Interface 15 Backgrounds often cover the entire Canvas. However, when used with the matte feature in the Attributes tab of the Inspector, an element can appear to “punch through” an underlying element to reveal the background color, image, or movie. See “Creating a Matte” on page 72 for more about creating mattes. Tracks The dark blue horizontal line that appears in the default Canvas is a track. Tracks are the foundation of any LiveType composition. Every element of a project resides on a track. Tracks define:  The position of text and objects in the Canvas  The layering of elements  In some cases, the path taken by moving elements Tracks have two endpoints, and can have any number of “control points,” which are nodes that create angles and curves in the track. When more than one track is in the Canvas, only the endpoints of the selected, or active, track are visible. This identification is helpful when you’re applying attributes to a track. Action Safe and Title Safe Guidelines The green hairline boxes in the Canvas represent the “action safe” and “title safe” areas. The action safe area, defined by the outer line, is the extent of the screen where the image is readily visible, given the curvature of the cathode-ray tube (CRT). The title safe area, represented by the inner line, is the boundary beyond which text is not easily read. To turn the action safe and title safe guidelines off or on: m Choose View > Title Safe.16 Chapter 1 The LiveType Interface Canvas Zoom Pop-up Menu At the bottom of the Canvas is a pop-up menu for changing the magnification of the Canvas. To change the Canvas zoom, do one of the following: m Open the Canvas zoom pop-up menu at the bottom of the Canvas and choose one of the magnification options. m Choose Fit to Window from the Canvas Zoom pop-up menu, then resize the Canvas window to a new magnification. m Choose View > Zoom In or Zoom Out. m With the Canvas active, use the Command-Z keyboard shortcut for Fit to Window. m With the Canvas active, use the Command-+ or Command-– keyboard shortcut to zoom in or out. Transport Controls The transport controls allow you to generate a RAM preview of your project so you can preview your titling movie right in the Canvas. When you click the Play button, LiveType renders each frame into RAM memory. This feature is referred to as a RAM preview. Canvas Zoom pop-up menu Previous frame Play Next Frame LoopChapter 1 The LiveType Interface 17 To render a RAM preview of your project in the Canvas: 1 Click the Play button (or press the Space bar when the Canvas or Timeline is active). The preview renders each frame, then runs through the preview in real time. 2 Stop the preview by clicking anywhere in the Canvas. The Play icon turns into a Pause icon when the RAM preview is playing. The Loop button is a toggle that gives you the choice of a single run-through or repeating the preview in a continuous loop. See Chapter 8, “Previewing and Fully Rendering Your Titling Movie,” on page 109 for more about previewing your work. Customizing the Canvas Most Canvas settings can be customized from the View menu, allowing you to configure guidelines and magnification, and choose which elements appear in the Canvas. The grid, rulers, and guides are helpful for precisely aligning and positioning elements in the Canvas. To show the rulers or the grid: m Choose View > Rulers. m Choose View > Grid. You can set the number of pixels between each grid line in the Project Properties dialog. Grid Ruler for vertical guides Ruler for horizontal guides18 Chapter 1 The LiveType Interface To customize the grid: 1 Choose Edit > Project Properties. 2 In the Ruler and Grid Settings area at the bottom, enter a new value in the Grid Width field. To add a guide to the Canvas: m Click inside one of the rulers to insert a guide marked by its horizontal or vertical pixel position. To add crosshairs to the Canvas: m Click inside one of the rulers and drag the pointer onto the Canvas. To remove guides from the Canvas, do one of the following: m Drag guide markers off either end of the ruler. m Choose View > Clear Guides, which removes all guides. You can isolate a single track and display all other elements as bounding boxes— rectangles that roughly show the size, position, and orientation of an element. This option is useful for cleaning up the Canvas as you work on a single track, and it saves preview-rendering time, because only one item of your composition is being rendered. Guide marker showing pixel position Crosshair guideChapter 1 The LiveType Interface 19 To isolate a single track in the Canvas: m Select the track you want to continue working on, then choose View > Selected Only. Revert to the normal view by choosing View > Selected Only again. The Proxy Frame Only option in the View menu–which applies only when you’re using installed LiveType media—renders LiveFonts, textures, and objects as proxy frames in the Canvas, essentially freezing their inherent animation. Particularly when the animated element has highly variable content from frame to frame (such as Particles objects, which contain few if any pixels in the beginning and ending frames), the proxy frame is easier to work with, because it shows a more representative shape of the object regardless of the playhead position. Bounding boxes show the size and position of deselected elements. Choose View > Selected Only to view only the contents of the selected track.20 Chapter 1 The LiveType Interface Inspector The Inspector is your toolbox for transforming elements—text, objects, or images. There are unlimited combinations of parameters and attributes you can use to make your titles dynamic and original. The Inspector consists of a text-entry box and Live Wireframe Preview at the top of the window, and five tabs of parameters. Inspector settings always apply to the track, character, or effect that is currently selected in the Canvas or Timeline. Text-Entry Boxes There are two areas in the Inspector where you can add text to a track. One of these is in the upper-left corner of the Inspector. Because this text-entry box is visible no matter which Inspector tab is selected, it is a convenient way to identify the active track, as well as to add or change the text on a track, as you can type directly into it. The textentry box at the bottom of the Text tab is larger, making it easier to insert and edit larger amounts of text. The text-entry boxes also allow you to select individual letters or words on a track. When you highlight text in the text-entry box, those characters are selected in the Canvas. This is particularly useful when the text you want to modify is obscured in the Canvas by other elements. Text-entry box Live Wireframe Preview Inspector tabs Text-entry box (in the Text tab only)Chapter 1 The LiveType Interface 21 Live Wireframe Preview In the upper-right corner of the Inspector, the Live Wireframe Preview continually plays your titling movie, with small bounding boxes indicating the movement of each character or object. This feature gives you a quick indication of how your adjustments have changed the overall animation, without rendering a full preview with every change you make. To freeze or unfreeze the Live Wireframe Preview: m Click inside the preview area. Inspector Tabs There are five tabs in the Inspector.  Text tab: This is where you enter text and adjust the size, alignment, and spacing of text on the active track. Preview playhead Small bounding boxes depict the movement of the Canvas elements. Click to turn the preview on or off. Text tab settings22 Chapter 1 The LiveType Interface  Style tab: This tab provides options for the Shadow, Glow, Outline, and Extrude treatments, which can be applied to text or objects. These are often used to add depth and highlight the text or object, although a wide variety of graphical outcomes are possible.  Effects tab: This tab lists the effects that have been applied to the active track, and is used to view and change effect parameters at any point in your titling movie. Effects are combinations of movement and transformation that can be applied to any track. The On column of the Effects tab allows you to turn an effect off or on for individual characters on the track. Style tab settings Effects tabChapter 1 The LiveType Interface 23  Timing tab: Timing parameters for tracks and effects are controlled in this tab. While the Timeline provides a frame-by-frame diagram of tracks and effects with their associated keyframes, the Timing tab is a single pane that allows you to adjust the overall timing and modify the parameters of your animation. Some timing adjustments are made more easily by moving elements in the Timeline, rather than entering values in the Timing tab. However, the Timing tab gives you access to the full range of timing variables, as well as effect parameters that let you fine-tune your animation, creating exactly the look you want. Timing tab24 Chapter 1 The LiveType Interface  Attributes: This is where you assign a variety of attributes—opacity, blur, scale, offset, rotation, and color—to elements in the Canvas. Attributes can be applied to entire tracks or individual characters on a track. The Attributes tab also contains options for creating a matte effect, in which an element appears as a cut-out window that reveals the element below it. A simple line of text, for example, can be matted to a movie clip, which essentially “fills” the text. The Matte to Texture option lets you fill track contents—even individual characters—with an animated texture, without having to add the texture to your project as a separate element. Matte settings are variables for creating cutouts and textured fills. Glyph settings include attributes such as the shape, color, and position of text and objects. Attributes tab in the Matte pane Attributes tab in the Glyph paneChapter 1 The LiveType Interface 25 Media Browser Most of the installed resources available for your titling projects are available through the Media Browser—except for LiveType templates and images and movies you import from other sources. There are various tabs representing different elements installed on your computer: LiveFonts, system fonts, textures, objects, and effects. Using the Media Browser, you can scroll through and view representations of all these elements before you apply them to your project. The Media Browser preview is the only way to see how LiveType media—LiveFonts, textures, and objects—move and transform until you install the full data file onto your computer. When you first apply one of these elements to the Canvas, a single representative frame is displayed, not the entire animated sequence. Installing the data component allows you to see a true representation of the LiveFont in each frame of your movie. See “LiveType Media Files” on page 28 for more about LiveType file management. Browser preview Tabs of media and effects26 Chapter 1 The LiveType Interface Timeline The Timeline depicts the frame-by-frame orchestration of your titling project, and provides many tools for designing the movement and timing of your titles. The Timeline allows you to do the following:  Set the timing and duration of tracks and effects  Manage the track order, or layers  Group tracks to maintain their relative position  Enable and disable tracks and effects  Work with keyframes to customize your animation  Select specific frames to view or adjust  Set markers to render only a portion of your movie for previews or final output About the Timeline Interface The following are the interface elements and controls in the Timeline. Project Tabs Tabs at the upper-left corner of the Timeline indicate which projects are currently open, and which one is active. Playhead, Timecode, and Frame Ruler The playhead and timecode on the frame ruler indicate which frame is showing in the Canvas. The playhead moves along the frame ruler when you play your project, and it can be dragged to any given frame. To view a specific frame, do one of the following: m Drag the playhead to the desired frame. m Click a frame in the frame ruler. The Canvas always reflects the frame under the playhead. Playhead Timeline zoom slider Project tab Grouping buttons Keyframe Background bar Timecode Enable/Disable buttons Track Effect Frame ruler Render Selection Out pointChapter 1 The LiveType Interface 27 Render Selection Markers The In Point and Out Point markers in the frame ruler allow you to determine the portion of your movie you want to render. Using these markers, you can:  Save time rendering previews when you don’t need to see the entire movie  Choose the precise number of frames you want to include in your final output To change the render selection, do one of the following: m Drag the In Point and Out Point markers in the frame ruler. m Position the playhead and press the I key on your keyboard to set the Render Selection In Point, or the O key to set the Render Selection Out Point. The Timeline must be active for these hot keys to work. As you constrain the range of frames to be rendered, the information box in the upperleft corner of the Timeline reflects the modified duration and number of frames. Note: To quickly locate the Out Point marker when it is beyond the end of the visible Timeline, move the Timeline zoom slider all the way to the right. Tracks and Effects Tracks are numbered according to their layer position in the left column of the Timeline, and Track 1 is always the top layer. Effects are depicted as separate bars underneath the track they apply to. An effect may extend for the entire duration of the track, or only a portion of it. One track may have several effects applied to it, in sequence or overlapping. Background Bar Any item that falls below the background bar is a background element. You can drag the background bar up or down to any position between tracks in the Timeline. For more information, see “About the Background Bar” on page 43. Keyframes The basis of most digital animation, keyframes contain the parameters that elements in the Canvas reflect at a specific point in time. When a movie is rendered, LiveType interpolates the movement of the elements in between keyframes for smooth, continuous motion. When an effect is increased in duration, or stretched, the keyframes spread out with it, and the effect takes longer to complete. See Chapter 7, “Working With Effects and Keyframe Animation,” on page 87 to learn more about keyframes. Grouping Buttons Grouping buttons let you group tracks together in the Canvas, locking their relative position while allowing you to move the group as a unit.28 Chapter 1 The LiveType Interface Enable/Disable Buttons The Enable/Disable buttons turn tracks and effects off or on. When a track is disabled, its contents are removed from the Canvas, although the blue track line remains. Disabled tracks are not rendered in previews or movies. Similarly, effects can be disabled. Timeline Zoom Controls Typically you use the zoom controls to adjust the amount of time represented in the Timeline window. This is helpful to do while working with timing a long or complex composition. The main zoom control is the Timeline zoom slider, which zooms in and out around the playhead as you drag. You can also use the Command-+ or Command-– keyboard shortcut to zoom in or zoom out on the playhead when the Timeline is active. Another helpful command is Shift-Z, which adjusts the Timeline to show the entire project at once. LiveType Media Files LiveType includes hundreds of media and effects files, which are the resources available to you within the Media and Template Browsers. Animated files include LiveFonts, objects and textures. Preset effects and templates, as well as various other LiveType resources, are also included with the application. These files are collectively known as LiveType media files. LiveType now uses a single file format for media such as LiveFonts, textures, and objects, but media using the earlier “pair format” is still supported. Shortcuts and Hot Keys The LiveType interface includes numerous menu items and shortcuts to help you use the application easily and efficiently. It’s important to note that the function of these options depends on which LiveType window is active. For example, when the Canvas is active, the arrow keys nudge the active track in small increments. However, when the Timeline is active, the right and left arrow keys advance the playhead or move it back one frame.Chapter 1 The LiveType Interface 29 Locating LiveType Media Files When you install LiveType, a folder hierarchy is placed in the following location: Library Application Support/LiveType/. This is where LiveType looks first for media files such as LiveFonts, objects, textures, effects, images, movies and templates. LiveType media files can also be installed on other hard disks including a network server. You can assign any location for media files from the Preferences dialog. About Installing LiveType Media Files The LiveType installation process allows you to install LiveType media files in any location. For more details concerning installing LiveType and the LiveType media files, see the Installing Your Software document that is enclosed with the installation discs. Managing LiveType Media Files Any element in the LiveFonts, Textures, Objects, and Effects tabs of the Media Browser has a corresponding media file, which contains the components needed to work with LiveType. Once these media files are installed in the /Library/Application Support/ LiveType folder, you can move them to a different disk. To use LiveType media that is located outside the application support folder: m Assign the location of the media files from within LiveType using the Preferences dialog. Choose LiveType > Preferences. Note: To use LiveType media that is located outside the application support folder, assign its location from within LiveType using the Preferences dialog. If you have media installed from a previous version of LiveType, the Media Browser reads “Yes” or “No” in the Installed column for that media which indicates whether or not the media files are installed. This convention only applies to earlier “file pair” formats. New content comes in the form of media files that appear in the Media Browser with a double dash in the Installed column indicating they are installed. The Install and Uninstall buttons in the lower-left corner of the Media Browser do not apply to the newer content, only to LiveType media files from previous versions of the application. Media file types Media filenames Media file contents Effects LTFX Contains effects files and sample movies for each effect. LiveFonts LTLF Animated font characters Objects .LTOB Pre-rendered animations with an alpha channel Templates LTTM LiveType projects Textures LTTX Full screen animated backgrounds. These animations can also be matted to any font character or element on the LiveType Canvas.30 Chapter 1 The LiveType Interface Creating Custom Categories for LiveType Media files You can create custom categories for LiveType Media by simply creating a new folder within the Media folder, such as LiveFont/My folder/My font. LiveType only recognizes one folder level after the original media category. You can move “file pair” media files from previous versions of LiveType to another disk, but they must be in the same folder hierarchy that they were previously located in. Using Imported Files When you use graphics or movies from other sources in your project, LiveType needs to refer to the source files for these external elements. Therefore, once you’ve placed an image or movie, it’s best not to move or rename the source file. The Images folder in the LiveType folder hierarchy is a convenient place to store images associated with your projects.2 31 2 Setting Up a Project The most important step as you begin any LiveType project is to configure the project properties. As tempting as it may be to jump right in and start designing, you should define your output parameters and save the project to disk at the outset, to be sure your titles are generated at the size and resolution you need. If you go ahead and generate a titling movie without initially configuring the project, you’re bound to run into trouble. Although these settings can be changed at any time, a titling composition created for standard broadcast, for example, will fill only a portion of the screen if it’s changed to high definition format after the fact. First, you need to open a new project. You have two options:  Start with a LiveType template.  Start with an existing LiveType project you’ve already created. Templates LiveType includes dozens of templates, which are LiveType project files organized by category. You can use templates in several ways:  As the starting point for your own creations  As repositories of preconfigured elements you can paste into your own projects  As a resource for sparking ideas and seeing what’s possible with LiveType The templates comprise many types of prebuilt projects, all of which you can revise for your own purposes.32 Chapter 2 Setting Up a Project To open a template: 1 Choose File > Open Template. 2 Browse the categories of templates in the Template Browser. 3 In the Template Browser, choose NTSC, PAL, or HD from the Format pop-up menu. 4 Choose a template, then click OK. Whenever you open a template, make sure to set your project properties immediately. See “Setting Project Properties” on page 34. You can save your own projects as templates, so they’re accessible through the Template Browser. To save your project as a template: 1 Place the project file (.ipr) in a folder in this location: /Library/Application Support/ LiveType/Templates. 2 Generate a short QuickTime movie of the project (with the same name but an appropriate movie extension, such as .mov or .mp4). Once you do this, the template will appear in the preview window of the Template Browser. The Template BrowserChapter 2 Setting Up a Project 33 Starting a New Project and Setting Defaults When you open LiveType, an untitled default project appears in the interface. If you want to start a new project when LiveType is already open, you need to open a new default project. To open a new project: m Choose File > New. A new project with an empty Canvas appears and an “Untitled” project tab is added to the Timeline. Note: At least one LiveType project must be open at any time, so if you close the only open project, a new default project automatically opens. You can configure your LiveType interface and save your settings as the default. Default settings include project properties, font and media choices, Canvas options, the tabs that are revealed, and various other settings. This is particularly useful for saving your preferred output format, so you don’t have to reconfigure the project properties each time you open a project. To save your default settings: 1 Set up a LiveType project with the settings and configuration you want. 2 Choose LiveType > Settings > Remember Settings. Every time you subsequently open a new project or open LiveType, the current default settings apply. Content elements in the original project are not saved as part of the default project. It is possible to find yourself with a default configuration that’s undesirable and difficult to get out of. You can easily wipe clean your settings and revert to the original LiveType settings. To erase your project settings: m Choose LiveType > Settings > Clear Settings.34 Chapter 2 Setting Up a Project Setting Project Properties Once you’ve opened a new project and saved it to disk, you need to define the output you want to create. All of the essential project settings are accessed through the Project Properties dialog. To open the Project Properties dialog: 1 Choose Edit > Project Properties. 2 Make the desired changes, then click OK. For detailed information, see the next section, “Settings in the Project Properties Dialog.” The Project Properties dialogChapter 2 Setting Up a Project 35 Settings in the Project Properties Dialog There are various pop-up menus, colors, and settings you can select when specifying the properties for your project. Presets Presets establish the width, height, frame rate, and pixel aspect defined by the selected standard.  Presets: This pop-up menu lists the most common output formats. After you select a different preset, you’ll notice how the settings change. You can also see how selecting different presets affects the shape and size of the Canvas. If none of the presets conform to your project, you can configure the dimensions and frame rate manually. “Custom” will then automatically appear in the Presets field. Note: Web banner and multimedia options are included among the presets, since LiveType is effective for building animations for the web or for Keynote, for example, which imports QuickTime movies directly. Keep in mind that web banners are typically created in GIF format. To create a GIF, you need to use another program to translate your LiveType output.  Width: This is the width, in pixels and inches.  Height: This is the height, in pixels and inches.  Frame Rate: This is the frame rate, in frames per second. Preset properties automatically set the project resolution, frame rate, and so on, for the most common output formats.36 Chapter 2 Setting Up a Project  Field Dominance: When your project is intended for interlaced video output, choose either Upper (Odd) or Lower (Even) for the smoothest animation. After the proper option is chosen, LiveType renders fields with either the upper or the lower field first. Choose None for footage that is non-interlaced. DV footage is typically Lower Field First, while certain video capture cards may need to be rendered with the Upper (Odd) option chosen. In all cases, use the fielding option that matches your video system settings. For more about this, see “Choosing a Field Order” on page 38.  Pixel Aspect: The ratio of width to height of a single pixel, or pixel aspect, can differ from format to format. The pixel aspect is set by preset properties, or you can enter a custom pixel aspect value.  Start Time: You can map the start time of your project to a precise point in your edited video, making it easy to overlay your video at the compositing stage. Start Time units reflect the time format entered in the field to the right.  Time Format: This setting defines how the position of audio or video is marked in time. There are several choices—Frames, SMPTE, and SMPTE Drop. Description Field The description field is a useful place to store notes about the project, as well as a description of any nonstandard output parameters you’ve configured, for future reference. Quality Settings Quality settings can have a big impact on the amount of time you invest in a project. As you design your titling animation and try out different effects, you will preview your movie many times. And each time, your system has to render the movie, frame by frame. Time Format options Quality options for the Canvas, movie renders, and preview moviesChapter 2 Setting Up a Project 37 These settings in this area allow you to configure the quality of three different items:  Canvas: A RAM preview in the Canvas  Movie Render: A full movie render  Preview: A standard preview accessed via the File menu How you preview your movie depends on where you are in the design process. You may find yourself changing these settings several times as you design your titles, particularly if it’s a complex composition that takes considerable time to render. A Wireframe preview, which displays rectangular bounding boxes representing each character, renders very quickly. When you’re focusing on the motion of your Canvas elements, not their visual attributes, previewing in Wireframe mode is highly efficient. The Wireframe, Draft, and Normal settings render your project at increasing resolution levels. Background Settings These settings allow you to select a Canvas color and its opacity level.  Color: This allows you to choose a background color in the Canvas.  Opacity: This setting reflects the opacity of the color selected above. An opacity level of 0 equates to no background color, and the Canvas shows the checkerboard pattern indicating a transparent background.  Render Background: When this checkbox is selected, any background color, as well as other background elements, render in previews or final movies. Important: The Render Background checkbox applies to all elements that fall below the background bar in the Timeline, as well as the background color, which is not represented in the Timeline. If the checkbox is not selected, the background color and other background elements are not rendered in previews or final movie renders. For more information, see Chapter 3, “Adding a Background,” on page 41 which presents a complete explanation of working with backgrounds in LiveType. Ruler and Grid Settings You can display or hide the Canvas rulers and grid, and set the space between gridlines at the bottom of the Project Properties dialog. See “Customizing the Canvas” on page 17 for more about the rulers and grid. The gridline frequency, or grid width, is set in the Project Properties dialog.38 Chapter 2 Setting Up a Project Choosing a Field Order You can run a simple test to determine the proper field order for your system. When you make a movie, the rendering order (upper field first or lower field first) should correspond to the method used by your equipment, or your movie will appear distorted. Note: The field order with which you record to video equipment can be altered by changes in the hardware or software of your production setup. For example, changing your video board, device control software, or VCR after setting the field order can reverse your fields. Therefore, any time you make a change to your setup, you should run this test for field rendering order. To test your system, render two LiveType projects, one rendered with upper field first and one with lower field first. Important: You may need to familiarize yourself with the basic functions of LiveType before you go through these steps. To test the field rendering order: 1 Start a new LiveType project. 2 Choose Edit > Project Properties. 3 In the Project Properties dialog, do the following: a Choose an NTSC or PAL setting from the Presets pop-up menu. b Choose Lower (Even) from the Field Dominance pop-up menu. Do not choose Upper (Odd). In this case, you are rendering the lower field first. 4 In the Inspector, do the following: a Type a capital “O” in a system font on Track 1. b Increase its size to fill most of the Canvas. c Color the letter red, then choose black as your background color. 5 Apply a fast-moving effect to the track, such as Jumpy, in the Caricature effect category in the Media Browser. 6 In the Timing tab, set the speed of the effect to 100 percent. 7 Choose File > Render Movie. 8 Enter lower.mov as the filename in the Save As field, then click Save. The movie renders to your chosen location. 9 Now change the color of the capital “O” to blue. Select Upper (Odd) in the Project Properties dialog. 10 Save the file, naming it upper.mov. 11 Render the second movie.Chapter 2 Setting Up a Project 39 12 Import the rendered files into Final Cut Pro, then play back both movies on an NTSC monitor. One of the two movies will look distorted; the other movie will play correctly, with sharply defined edges. Whenever you render a LiveType movie for that system, use the settings you used for the undistorted output.3 41 3 Adding a Background Backgrounds in LiveType generally serve one of two purposes: Either they are an integral part of the titling composition, or they are used as an aid to position elements and key the timing of the titling movie. Although anything can be a background, a background is usually a uniform color, animated texture, still image, or movie that fills the Canvas. While background images, movies, and textures tend to fill the Canvas and aren’t extensively manipulated, they can be sized, positioned, and transformed in many ways. For more information, see Chapter 6, “Working With Objects, Textures, and Imported Elements,” on page 79. Setting a Background Color The most basic kind of background is a background color, which covers the Canvas and cannot be manipulated except for its opacity level. It’s best to think of the background color as a project property, not an element that can be moved or changed. The default background has an opacity of 0 percent, which means the Canvas displays a transparent background, represented by the white and gray checkerboard pattern. Background settings in the Project Properties dialog42 Chapter 3 Adding a Background To choose a background color: 1 Choose Edit > Project Properties. 2 Click the Color button in the Project Properties dialog. 3 In the Colors window, choose a color, then close the window. Note: Make sure you always close this window after you have selected a color. 4 Drag the opacity slider or enter a value in the field greater than 0 percent. Click OK. The background color appears in the Canvas. Adding a Background Texture LiveType textures make vibrant, animated backgrounds. They are also frequently used with the matte feature, which allows you to apply a textured fill to text or an object. See Chapter 5, “Working With Text,” on page 57 for information about creating a matte. To create a textured background: 1 Click the Textures tab in the Media Browser. 2 Browse the texture categories and select a texture. 3 Click the Apply To New Track button. The texture fills the Canvas and appears as a background track in the Timeline. Selected texture Category pop-up menu Background texture (colored and lightened)Chapter 3 Adding a Background 43 Importing a Background Movie or Still Image You can import images or movies from other sources and use them as backgrounds for your titling project. For any given project, you might choose to use the following:  A single frame or movie clip as a temporary background, to accurately position and time the action of your titles  A movie to embed as part of your titles  A static image or graphic LiveType can import background elements in a variety of formats:  AVI  BMP  DV  GIF  JPEG  MPEG-2 and MPEG-4  Photoshop  PICS  PICT  PLS About the Background Bar The background color is different from background elements in your project. Background elements are represented in the Timeline and can be manipulated in various ways. A project can have many background elements, or none. The only definitive way to distinguish a background element, be it a LiveType object or texture, a movie, or an image, is that it falls below the background bar in the Timeline. You can drag the background bar up or down to any position between tracks in the Timeline. Any element below the background bar is subject to the Render Background checkbox in the Project Properties dialog. Background bar Background texture44 Chapter 3 Adding a Background  PNG  QuickTime image file  QuickTime movie  SGI  Targa  TIFF To import a background movie: 1 Choose File > Place Background Movie. 2 Locate the movie file you want to place, then click Open. Note: When you import a background movie, the project dimensions and frame rate adjust automatically to conform. It’s a good idea to review your project properties when you import a new background movie. To import a background image: 1 Choose File > Place. 2 Locate the file you want to place in the Canvas, then click Open. 3 In the Timeline, do one of the following:  Drag the image track below the background bar.  Drag the background bar above the image track. Note: Placing an image or movie using File > Place does not affect the resolution or frame rate of the project. That is, the image or movie conforms to the project settings. Placed background movieChapter 3 Adding a Background 45 Importing a Background Movie With Timing Markers Final Cut Pro allows you to save movies that include timing markers, which can be useful when setting the precise timing of your titles. When you place a Final Cut Pro movie in LiveType, the markers appear in the frame ruler of the Timeline. Markers cannot be repositioned in the Timeline. Clicking them, however, moves the playhead to the marked frame. Considerations for Rendering the Background You have the option of rendering or not rendering the background in your project. The background settings in the Project Properties dialog—Color, Opacity, and Render Background—provide several options that affect your working environment and the final result of your project. If you’re creating a standalone animation, web banner, or multimedia component, for example, you might want to include a full background as part of your movie output. If you’re creating a titling overlay, you won’t want to render the background in most cases. Consider these options:  To include a background image, movie, or animated texture in your final output, leave the background color opacity at 0 percent and select the Render Background checkbox.  If you want an opaque or semitransparent solid color background in your final output, choose a color and opacity level, and select the Render Background checkbox.  If you don’t want background elements in your final output, deselect the Render Background checkbox. This option allows you to do the following:  Import a background movie or image for placement and timing reference only, without incorporating it into your titling output.  Define a Canvas color other than the default checkerboard pattern, according to your working preferences. Marker imported as part of a Final Cut Pro movie4 47 4 Working With Tracks To create anything in LiveType, you need to be familiar with tracks. Every element of a titling composition is part of a track, and each track can contain one or more lines of text, an image, a movie, or an animated object or texture. Tracks are “containers” of content, represented by dark blue lines in the Canvas with corresponding bars in the Timeline. A track comprises all of the information about its content:  Position, shape, and baseline  Attributes such as color, shadow, font, and spacing  Effects and timing This chapter explains how tracks are moved and shaped in the Canvas, and how they can be manipulated in the Timeline. The next three chapters describe in detail how to apply text, objects, and effects to tracks to assemble your composition. Empty track48 Chapter 4 Working With Tracks Positioning Tracks in the Canvas When you first open LiveType, the default Canvas contains a single empty track with two endpoints. The shape of a track defines the default baseline on which its contents sit. Tracks can be manipulated at any time, whether or not they contain an element. If you’re creating a track along which to slide text, or if you want your text to conform to a specific shape, you might want to shape and position the track before you add text to it. To position a track: m Drag a track to move it anywhere in the Canvas, or partially off the Canvas. Tracks can extend beyond the boundaries of the Canvas, allowing elements to slide in and out of the viewable area. To create a sloping track or to resize it: m Drag one of the track’s endpoints. Note: Hold down the Shift key when you position an item in the Canvas to constrain its horizontal, diagonal, or vertical position. This applies to tracks, endpoints, objects, and characters. Active track, extending off the Canvas Endpoint Title safe boundary Action safe boundary White Canvas background Canvas Zoom pop-up menu set to 50 percent TracksChapter 4 Working With Tracks 49 Creating Angles and Curves Tracks can take any linear path. You can even link the endpoints of a track so that an element can flow around it in a continuous loop. To add an angle to a track, you must add a control point to it. A track can have any number of control points. To create an angle on a track: 1 Hold down the Control key and click the track anywhere between the endpoints, then choose Add Control Point from the shortcut menu. 2 Drag the new control point and the endpoints to create the angle you want. Control points are also necessary for creating curves. If you’re familiar with Bezier curves, this will be a snap. If not, it may take a bit of experimentation.50 Chapter 4 Working With Tracks To create a curved track: 1 Follow steps 1–2 above to create an angle on a track. 2 Hold down the Control key and click the control point, then choose Curve In from the shortcut menu. 3 Drag the Bezier handle to adjust the curve. 4 Hold down the Control key and click the same control point, then choose Curve Out from the shortcut menu. Another Bezier handle appears, and the curve is smooth at the control point. A Bezier handle appears as a small point on the track near the control point.Chapter 4 Working With Tracks 51 Note: You can apply a curve to an endpoint as well, but clicking an endpoint brings up only the Curve In or Curve Out option—not both—since the track extends in only one direction away from the endpoint. Linking Endpoints The Slide parameter, used in several preset effects, allows text to move along a track. If the endpoints are linked, the text can move around the track on a continuous path. See Chapter 7, “Working With Effects and Keyframe Animation,” on page 87 for more about effects and motion paths. To create a motion path that is a continuous loop, you need to link the endpoints of a track. The endpoints do not need to overlap. In fact, they can be positioned at opposite ends of the Canvas, and still be linked. Linking the endpoints allows text or objects to loop immediately from the end to the beginning of the track when an effect using the Slide parameter is applied to them. To link the endpoints of a track: m Control-click one of the endpoints of any track, then choose Link Endpoints from the shortcut menu. You can unlink endpoints using the same method.52 Chapter 4 Working With Tracks Adding, Copying, and Deleting Tracks There are numerous ways to add a track to the Canvas. To add a new, empty track, do one of the following: m Choose Track > New Text Track (or press Command-T). m Choose a font in the Media Browser, then select Apply To New Track. Sometimes it’s useful to create a duplicate track, with the identical position, shape, contents, timing, and effects as a track you’ve already built. To duplicate a track: 1 Select the track you want to duplicate. 2 Choose Track > Duplicate Track (or press Command-D). The duplicate overlays the original track precisely, so at first, you can only tell that a duplicate has been made by the addition of a new track in the Timeline. Overlaying tracks with identical elements but different effects and parameters is a great way to produce sophisticated title animations. Drag the duplicate off the original to see both tracks. To delete a track: 1 Select the track you want to delete. 2 Do one of the following:  Choose Track > Delete Track.  Press the Delete key. You can also copy a track from another project, such as a LiveType template or a project you’ve created previously, into your current project. To copy a track from one project to another: 1 Open both the source and destination projects. A tab for each of the projects appears in the Timeline. 2 In the source project, select the track you want to copy, then choose Edit > Copy. 3 Click the tab of the destination project in the Timeline, then choose Edit > Paste.Chapter 4 Working With Tracks 53 Working With Tracks in the Timeline As you add tracks to the Canvas, they appear as numbered bars in the Timeline. As you apply effects to each track, they appear as unnumbered bars below the track. Adjusting the Timing of a Track When you add a track to the Canvas, by default it begins at the frame indicated by the playhead. The duration of a track varies, depending on its contents. A track containing text in a system font or a static image defaults to a duration of two seconds. The duration of a track containing LiveType media or any imported movie depends on the length of the movie. These basic timing parameters are easily changed in the Timeline window by stretching and moving the track bars. Delay and duration can also be defined in the Timing tab of the Inspector, as can many other timing parameters. Track 2 Track 1 Track 1 Track 254 Chapter 4 Working With Tracks To adjust the duration of a track, do one of the following: m Drag either edge of the track bar to the right or left. Note: Changing the duration of tracks that contain movies or LiveType media changes the speed at which the movie plays. If you shorten the duration of a LiveFont track, for instance, it plays faster. m Select the track and do one of the following:  For static content, adjust the Duration parameter in the Timing tab of the Inspector.  For movies and animated content, adjust the Speed parameter in the Timing tab. If you like, you can make the track contents appear later than the first frame. To delay the appearance of a track, do one of the following: m Click inside the track bar and drag it to the right. m Select the track and adjust the Delay slider in the Timing tab of the Inspector. You can also reposition more than one track at the same time, which is a useful way to maintain the relative position of tracks as you change their delay times. This is known as a ripple drag. To move two or more tracks in the Timeline at once: m Press the Option key, and drag the left-most track (the track with the earliest starting time) of the group you want to move. All tracks to the right of the selected track (tracks with later starting times), including their associated effects, move as a block with the selected track. Playhead Drag either end of a track to adjust its duration or speed. Drag a track to adjust its starting time.Chapter 4 Working With Tracks 55 Layers and Track Order Elements in the Canvas invariably overlap, which is why it’s important to manage track layers. When you create a new track, it is always the top layer. Any content you add to that track is in front of all other elements in the Canvas. Note: In the Timeline, tracks are displayed in front-to-back order, with Track 1 in front. To change a track’s front-to-back position, do one of the following: m Click inside the track bar in the Timeline and drag it up or down, to a new position. m Select the track you want to move, either in the Canvas or in the Timeline, then choose one of the options from the Layout menu: Bring to Front, Send to Back, Bring Forward [one layer], and Send Backward. The tracks renumber to accommodate the new order. Disabling Tracks You can disable tracks, as well as effects applied to tracks, in the Timeline window. This can be useful in reducing clutter in the Canvas, and it saves preview-rendering time when you only need to preview one or a few elements. Deactivating elements is also useful for comparing different design choices. To disable a track or effect: m Click the Enable/Disable button immediately to the left of a track or effect in the Timeline. While the blue baseline of a disabled track remains in the Canvas, its contents no longer appear in the Canvas, are not represented in the Inspector’s Live Wireframe Preview, and do not render when you generate a preview or final movie. Track 1 (top layer) Enable/Disable buttons56 Chapter 4 Working With Tracks Grouping Tracks It is often useful to group two or more tracks together, to maintain their relative position in the Canvas. Grouped tracks can be moved in the Canvas, but they stay together as a group. When tracks are stacked on top of each other, grouping is the only way to move the stack as a unit. For example, you might want to create a two-layer effect where a word fades out to nothing, revealing the same word underneath with an animated texture applied to it. To do this, you have to create a track that precisely overlays the original using the Duplicate Track command in the Track menu. Now, if you want to reposition the tracks in the Canvas, you need to group them together. To group two or more tracks: 1 Make sure you have more than one track in the Canvas. 2 Select a track in the Canvas or Timeline. This is now the active track, and the grouping button to the far left of the track bar is dimmed. 3 Click the grouping button of a different track. The link icon appears, indicating that the track is grouped with the active track (the track you selected in Step 2). 4 In the Canvas, move either of the grouped tracks, and notice that they move together. 5 In the Timeline, click the grouping button of a third track. Now three tracks are grouped together. To ungroup tracks: m Select one of the grouped tracks, then click the grouping button of the track you want to ungroup. The link icon disappears, and the tracks can now be moved independently. Note: Grouped tracks maintain their relative position, but their contents can still be altered and moved. If you drag a grouped track, other tracks belonging to the group move too. However, if you drag a glyph that resides on one of the grouped tracks, the glyph moves independently. Its Offset parameter is being changed while the track itself stays put. Active track Grouping button5 57 5 Working With Text Titles can incorporate all kinds of visual elements, but their traditional function is to display text. This chapter describes how to insert and format text, including manipulating individual characters on the same track. Adding movement to text—that is, beyond the inherent animation of LiveFonts—is covered in Chapter 7, “Working With Effects and Keyframe Animation,” on page 87. Inserting Text Like any Canvas element, text must reside on a track. There are three approaches to adding text, in a particular font, to the Canvas:  Create a track, select a font, and then add text to the track.  Create a track, add text to it, and then apply a font.  Choose a font first, click the Apply To New Track button in the Media Browser, and type in the text.58 Chapter 5 Working With Text The steps below describe the first approach. To add text to the Canvas: 1 Create a new track by choosing Track > New Text Track (or press Command-T). Note: A corresponding track in the Timeline appears. 2 Choose a font: a Click either the LiveFonts or Fonts tab in the Media Browser. LiveType comes with a variety of LiveFonts. Click the Category pop-up menu to access different sets of LiveFonts, including third-party and custom LiveFonts that you can create. b Select a system font or LiveFont. c Click the Apply button. 3 Enter text onto the active track by doing one of the following:  Type into one of the text-entry boxes in the Inspector.  Cut and paste text from another application into a text-entry box. (Formatting from other applications does not carry over into LiveType.) Note: If you add text to a track before selecting a font, the new text appears in the Canvas in the default font, size, color, and spacing. LiveFonts tab System Fonts tab Options for applying fonts UP01103TXT Page 58 Tuesday, March 8, 2005 1:55 PMChapter 5 Working With Text 59 To change the font of an existing text track: 1 Select the text track. 2 Choose a font from the LiveFonts or Fonts tab of the Media Browser. 3 Do one of the following:  Click the Apply button.  Double-click the font name. Note: The Apply option does not cross genres of track content. That is, you cannot apply a texture or object to a track that already has text on it. Likewise, you cannot apply a font to a track that contains a texture, object, image, or movie. Multiple lines of text can exist on a single track. This enables you to create a long text element governed by one set of parameters. If you’re designing credits, for example, you can generate the copy in another program, cut and paste it into the text-entry box, and apply the font and attributes along with a scrolling effect. LiveFonts vs. System Fonts The two kinds of fonts available in LiveType are very different. LiveFonts have more “life” to them, because they are fully designed animations. System fonts, on the other hand, are more like blank slates you can modify to achieve a wide range of appearances. Both kinds of fonts can be transformed using all the parameters described in this chapter, but keep in mind that some parameters will not make much visual sense when applied to LiveFonts. Note: The Use LiveFont Defaults button in the Text tab of the Inspector restores the original attributes of LiveFonts, objects, and textures, including timing, color, and other characteristics. This can be a valuable way to revert to the original design of these LiveType elements when you’re experimenting with different formatting combinations. LiveFonts and system fonts also have several practical differences in LiveType:  You can apply two or more system fonts to the same track, while only one LiveFont can be applied to a track.  LiveFonts are digital movies, and therefore have timing options you can control through the Timing tab of the Inspector. See “Adjusting the Timing of LiveFonts” on page 60.  System fonts are always vector-based, while LiveFonts can either be raster-based or vector-based. So it is possible to use LiveFonts at such a large size (in excess of 500 point) that the edges begin to degrade.  LiveFonts have a much greater impact on previewing and rendering time.60 Chapter 5 Working With Text To apply a second system font to text on a track: 1 Create a text track with one or two words on it, in a system font. 2 Select one or more characters on the track by highlighting them in the text-entry box or selecting them in the Canvas. 3 In the Fonts tab of the Media Browser, choose a system font different from the one you’ve already used. 4 Click the Apply button at the bottom of the Fonts tab. LiveFont Character Set The LiveFonts included in LiveType consist of 127 characters, which include all standard English, French, German, and Spanish characters: To access characters that aren’t represented on your keyboard, use the Keyboard Viewer feature, which you can select in the Input Menu pane in the International pane of System Preferences. Adjusting the Timing of LiveFonts When you create a system font track, its default duration is always two seconds. LiveFonts, on the other hand, have various durations, as shown in the middle column in the LiveFonts tab of the Media Browser. Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz ! # $ % & ( ) , . < > @ + = : ; _ - ? “ ‘/ * 0 1 2 3 4 5 6 7 8 9 Áá Àà Ââ Ää Çç Èè Éé Êê Ëë Îî Íí Ïï Ññ Ôô Öö Óó ß Üü Úú Ùù Ûû €Chapter 5 Working With Text 61 Because they are movies, LiveFonts are subject to several timing parameters, available in the Timing tab of the Inspector. Settings for LiveFonts in the Timing Tab  Random and Sequence: Let you apply the LiveFont movie to each character on the track in a different order, with a variable delay between each letter.  Speed: Allows you to play the LiveFont movie more quickly or slowly. Notice that as you change the speed, the duration of the track in the Timeline increases or decreases. Likewise, if you change the duration of the track in the Timeline, the speed parameter changes in the Timing tab.  Delay: Allows you to set the starting time of the track.  Loop: Determines how many times the LiveFont movie plays through. The default setting is 1, meaning that the LiveFont plays one time. A value of 2 means that it plays through twice. The duration of the track doubles with a Loop value of 2, in most cases. Note: Several LiveFonts, including Burn Barrel, Cool, and Gutter, take advantage of “segmented animation,” which defines beginning, middle, and ending segments of the movie. When you adjust the Loop parameter for these fonts, only the middle segment of the animation is looped.  Duration: Does not apply to LiveFont tracks.  Hold First and Hold Last: Allow you to have the first frame of the LiveFont appear for a designated amount of time before the movie begins to play. Likewise, Hold Last perpetuates the last frame. Settings in the Timing tab62 Chapter 5 Working With Text Formatting Text After you’ve selected the font, you have countless formatting options, available through the Inspector, to change the appearance of the text. As you adjust formatting parameters, the contents of the active track change dynamically in the Canvas, making it easy to see what you’re doing. These options can apply to the entire track or to one or more individual characters on a track. To format any element in the Canvas, you must first select its track. To select the entire track, do one of the following: m Click the blue track line in the Canvas. m Click the corresponding track in the Timeline. Note: If you click the text itself, a bounding box appears around the character you clicked, and your modifications affect only that character. See “Modifying Individual Characters” on page 77. After you have selected the track you want to format, use the Text, Style, and Attributes tabs of the Inspector to specify options such as alignment, size, tracking, leading, and color. Alignment, Size, Tracking, and Leading In the Text tab of the Inspector, you can adjust the size, tracking, and leading of a text track, as well as its horizontal and vertical alignment. Size values are in points, and tracking and leading values are percentages of the font’s default spacing. Formatting options in the Text tab of the InspectorChapter 5 Working With Text 63  Alignment: With the alignment options, text can be set to run horizontally as well as vertically on a track. The Left, Center, and Right Alignment buttons apply to both text orientations. The position of the track itself is not affected by alignment settings. The alignment options are also important to position text appropriately when the track is used with an effect that uses the Slide parameter. For example, if you want to slide text onto the screen from left to right, create a track that begins to the left of the Canvas. The text should be left-aligned, so that it starts from the left end of the track, off the Canvas. Then apply the Slide Right effect from the Motion Path category.  Size: Text size is adjusted by dragging the slider, clicking within the slider track, or entering a value in the box to the right of the slider. Note: Because LiveFonts are raster images made up of pixels, their edges will start to degrade at very large sizes, usually 500 point and larger. System fonts are vectorbased, and therefore retain their integrity at any size.  Tracking: Character spacing is adjusted with the tracking setting. The value for normal character spacing is 100 percent. A setting of 110 percent adds a modest amount of space between letters. When tracking is set to 0 percent, all characters overlay each other.  Leading: Leading sets the amount of space between the baseline of one line of text and the next. This setting only applies to tracks with more than one line of text, not to the spacing between different tracks. The default leading value is 100 percent. At 0 percent, all lines of text on a track overlay each other.64 Chapter 5 Working With Text Color Color options are in the Glyph pane of the Inspector’s Attributes tab. The lower portion of the tab contains the color controls.  Color: The Color parameter replaces existing pixels of color in the selected element with the color indicated in the Color box, while keeping the luminosity values intact. A setting of 100 percent completely replaces the existing colors, whereas a Color setting of 20 percent combines some of the new color with the original. Click the Color box to choose a different color. Note: Once you have selected a color, close the Colors window. You need to reopen the Colors window to make any subsequent color choices.  Hue, Saturation, and Lightness (HSL): These three sliders work together to establish the color of the selected element. Hue defines the shift in color value, in degrees, on a 360-degree spectrum. Saturation defines the intensity or vividness of the color, in percentage points. Lightness defines the intensity along the black and white axis, in percentage points. The default color of a system font is black, which renders the Hue, Saturation, and Lightness sliders ineffective. HSL and Color are useful for adjusting raster-based elements such as LiveFonts while, as a rule of thumb, system fonts and other vectorbased elements should be colored using the Color feature.  Alpha pop-up menu: When you have a clip or imported graphic in a LiveType composition, you can choose a type of alpha channel from this menu. Choose from Premultiply White, Premultiply Black, or Straight. Color settings in the Glyph pane of the Attributes tabChapter 5 Working With Text 65 To change the color of a system font: 1 Select a track that contains a black system font. 2 In the Attributes tab, in the Glyph pane, click inside the Color box and choose a color from the Colors window (preferably a bright, primary color). 3 Set Color to 100 percent. The contents of the track change to this color. LiveFonts are typically built using primary colors, which means that the Hue, Saturation, and Lightness sliders can be used effectively, in addition to the Color parameter. Transforming Text Beyond basic text formatting, LiveType gives you many additional treatments with which to stretch, blur, fade, reposition, and rotate your text. These features are all in the Glyph pane of the Attributes tab.  Opacity: Opacity defines how much of the underlying content shows through. An opacity setting of 0 makes text completely transparent and, in most instances, a setting of 100 makes it opaque. When the blur attribute is off (set to 0), a 50 percent opaque character has sharp edges and is somewhat transparent. Note: LiveType allows opacity values to be higher than 100 percent. This can be desirable when you’re working with glow parameters (Style tab), or LiveFonts and elements that are blurred or partially transparent. For example, the Charge LiveFont still reveals some of the background at 100 percent opacity. At 150 percent (which you must enter in the opacity field), the font reveals very little background. Glyph parameters in the Attributes tab of the Inspector66 Chapter 5 Working With Text  Blur: The blur attribute is similar to opacity, but it fades and expands the outer edges as if the text is out of focus. Blur can be applied equally to the X and Y axes or unequally, for different outcomes. A blur setting of 0 is off, with no blurring effect. The maximum blur setting is 25.  Scale: Scale stretches or squeezes text on the X and Y axes, with 100 being the same size as the original text. Note that scale parameters are applied independently to each character around its pivot point, not to the entire track as a unit. Note: Unlike the Scale parameter, the Size parameter in the Text tab scales text from the baseline, and also takes text tracking into consideration.  Offset: Offset repositions the text relative to its original position on the track. An offset of 0 indicates no position shift on that axis.  Rotate: With the rotation dial, you can position an element not only in the 360 degree range, but configure any number of revolutions in the context of an effect. A glyph sized using the Size parameter keeps its original baseline and tracks with adjacent characters. A glyph sized using the Scale parameter expands around its pivot point without affecting the position of other glyphs on the track.Chapter 5 Working With Text 67 For example, you can set an early keyframe at 45 degrees and set a later keyframe at four revolutions plus 180 degrees. When you play the movie, the element spins clockwise four times plus an additional 135 degrees between those two keyframes. Positive values reflect clockwise motion, and negative values reflect counterclockwise motion. Working with keyframes is defined fully in Chapter 7, “Working With Effects and Keyframe Animation.” Text example set at 35 percent opacity in the Attributes tab Text example using the blur and scale options in the Attributes tab Text example with the default shadow Solid background color68 Chapter 5 Working With Text Enhancing Text With Styles The Style tab in the Inspector offers four options for enhancing your text. Styles allow you to add depth and emphasis to text—as well as to objects—mostly by altering the space around each character. The Shadow, Glow, Outline, and Extrude buttons in the Style tab each reveal the settings applicable to that treatment. Shadow and Glow The Shadow and Glow styles are essentially two “flavors” of the same style, using identical parameters to create quite different looks.  Character: The character setting allows you to make the original element invisible, isolating the style treatment in the Canvas. This can be a helpful way to eliminate clutter as you compose your treatment, or you may choose to leave the original element invisible in the finished product.  Enable: The Enable checkbox allows you to turn a style on or off, without affecting the settings you’ve established. Again, this is a helpful tool for eliminating clutter as you design, or as you compare different styles and combinations of styles.  Layer: The Layer pop-up menu allows you to place the shadow or glow treatment in front of or behind the original element. The In Front Only setting restricts the shadow or glow effect to the boundaries of the original element, without extending beyond the edges of the letters or object. Shadow parameters in the Style tab of the Inspector Reset all Reset Warp parametersChapter 5 Working With Text 69  Opacity: Opacity sets the intensity of the shadow or glow. An opacity setting of 0 makes the shadow or glow completely transparent, that is, invisible, and completely opaque at 100, with no background showing through. If blur is turned off (set to 0), a 50 percent opaque shadow has sharp edges that match the original element, but whatever lies behind the shadow shows through it.  Blur: The blur parameter is similar to the opacity setting, but fades and expands the outer edges as if the glow or shadow is out of focus. A blur setting of 0 is off, with no blurring effect. The maximum blur setting is 25. Blur can be applied independently to the x and y axes. A y-direction blur creates the look of an up and down motion, even in a static image.  Scale: Scale stretches or squeezes the glow or shadow on the X and Y axes, with 100 being the same size as the original element. Note that scale parameters are applied independently to each character of text on a track, not to the entire shadow or glow as a unit.  Offset: Offset repositions the shadow or glow relative to the original element. An offset of 0 indicates no position shift on that axis.  Color: The Color box lets you select the color of the shadow or glow.  Warp: The warp area allows you to stretch and reshape the shadow or glow by dragging the four corner points, or inserting x and y coordinates for each corner. A simple application of the warp feature is to stretch shadows to represent different lighting situations. Text example using glow options in the Style tab Text example with an outline and an enlarged, offset shadow Text example using the Extrude style Solid background color70 Chapter 5 Working With Text Outline This style adds an outline to the contents of any track. See the preceding section for a definition of the opacity, blur, color, and warp parameters. Click the Outline button at the top of the tab to adjust the outline settings.  Weight: The weight value, which defines the thickness of the outline, is set in pixels.  Show Outline Only: Show Outline Only eliminates the original element, creating an outline effect that allows the background to show through. Note: The Show Outline Only setting is used with the character parameter set to Visible. Otherwise, the outline will be rendered invisible along with the character itself. Outline parameters in the Style tab of the InspectorChapter 5 Working With Text 71  Outline Extrusion: When the text has been extruded (see below), selecting this checkbox extends the outline around the extrusion. Extrude Extrude settings consist of direction, length, and color. The direction setting determines which way to “pull” the extrusion and the length determines how far to pull it.  Length: The length value is set in pixels.  Direction: The direction value is set in degrees, from 0 to 360.  Color: The Color box lets you select the color of the extrusion. Text example using the Show Outline Only and Outline Extrusion options in the Style tab Text example using X and Y scaling options in the Attributes tab, with an outline Text example using the invisible character option with the Shadow and Glow styles in the Style tab Solid background color72 Chapter 5 Working With Text Creating a Matte The matte feature in LiveType allows you to reveal a background element in the area defined by a foreground element, seemingly cutting a hole through any layers in between. When you create a matte, every pixel of the foreground element is replaced by a corresponding pixel in the background element. In other words, a matte acts as a window into another layer. In LiveType, you have three options for creating mattes, available in the Matte pane of the Attributes tab in the Inspector. The first option—Matte to Background—allows you either to fill the foreground element with a background element, or to create an empty window, which can remain transparent when you render your titling movie. To create a matte with two project elements: 1 Create the background element by placing a texture, image, movie, or object as the bottom layer reflected in the Timeline. See Chapter 3, “Adding a Background,” on page 41 and Chapter 6, “Working With Objects, Textures, and Imported Elements,” on page 79 for information about placing these kinds of elements in the Canvas. 2 Make sure the background is beneath the background bar in the Timeline, and that no other elements are below the background bar. 3 Create a texture or any other element that obscures the background. 4 Create a foreground element, that is, the text or object you want the background to “fill.” 5 With the foreground track selected, click the Matte button in the Attributes tab of the Inspector. Background bar Background textureChapter 5 Working With Text 73 6 Choose Background from the “Matte to” pop-up menu. The background image appears to fill the foreground element. To create a window into a transparent background: 1 Create a texture or any combination of elements that covers the Canvas. For information about placing textures and other elements in the Canvas, see Chapter 3, “Adding a Background,” on page 41 and Chapter 6, “Working With Objects, Textures, and Imported Elements,” on page 79. 2 Create a foreground element, that is, the text or object that defines the shape of your window. 3 If any elements are below the background bar in the Timeline, drag the bar below all elements. 4 With the foreground track selected, click the Attributes tab of the Inspector, then click the Matte button. 5 Choose Background from the “Matte to” pop-up menu. 74 Chapter 5 Working With Text The transparent Canvas (or background color if defined in the Project Properties dialog) appears to fill the foreground element. The other two matte options, Matte to Movie or Image and Matte to Texture, differ because the background doesn’t appear as a discrete project element that’s reflected in the Timeline. And, there’s no need for a layer that the matte has to “punch through.” Instead, the track contents are simply filled with the designated image. These two matte alternatives have scale, speed, and sequencing options in the Matte pane. Scale adjusts the size of the background image, speed adjusts the speed of the background movie or texture, and sequencing allows you to offset the timing of the background for each letter residing on the foreground track. Note: When you matte a word to a movie or image, LiveType calculates which portion of the image “underlies” each letter, imitating a true window into a lower layer. When you reposition the letters on the track, they retain the same image content. This feature can create an interesting look as you apply movement to the text, particularly when the matte is with a movie. Texture scaled down on the y axis Transparent Canvas background Text track matted to the transparent backgroundChapter 5 Working With Text 75 To fill the track contents with an image or movie: 1 Select a track that contains the text or object you want to fill with an image or movie. 2 Click the Attributes tab of the Inspector. 3 In the Matte pane, choose Movie or Image from the “Matte to” pop-up menu. 4 Locate the file in the Choose Movie or Image dialog, then click Open. The track contents fill with the background movie or image. Note: If you want to reveal a specific portion of the image or movie within your foreground element, you may find that this matte option is not appropriate, since you cannot adjust the relative position of the image and your foreground element. If this is the case, you must use the Matte to Background option described above, which allows you to position the two components independently. Text track matted to a movie76 Chapter 5 Working With Text To fill the track contents with a texture: 1 Select a track that contains the text or object you want to fill with a texture. 2 Choose a texture from the Media Browser, then click the Apply to Matte button. The default texture fills the contents of the active track. Note: A variety of mattes is available for use in the Objects tab of the Media Browser from the Category pop-up menu. The blue areas of a LiveType matte define the area where the texture will play back. Text or glyphs from the character palette may also be used as mattes. Note: Individual characters on the same track can be matted to different textures, movies, or images. See “Modifying Individual Characters,” next. You can get a nice effect by combining the matte function with the outline style. To fill an invisible element’s outline: 1 Create or select a text track. 2 In the Style tab of the Inspector, click the Visible button. 3 In this case, make sure the Enable checkbox is deselected for the Shadow, Glow, and Extrude styles. 4 Click the Outline button in the Style tab, and select the Enable checkbox. 5 Select the Show Outline Only checkbox, and increase the weight of the outline, so it’s fairly thick. 6 Choose a texture to fill the outline, then click the Apply to Matte button. The outline is now filled with the texture.Chapter 5 Working With Text 77 Modifying Individual Characters You can also assign attributes to individual characters on a track. All of the attributes discussed in this chapter can apply to only one, or more than one, character on the same track. This is a powerful option in LiveType, particularly because it allows you to reposition individual characters, or glyphs, without breaking their relationship to the track. For example, with individual character adjustments, you could make one word in a phrase float above the track, expand and glow, and then return to the track. This would take only a few moments to animate. Or you could make a series of characters do similar transformations, one after the other. To modify one or more characters on a track, try the following steps: 1 Select or create a track that contains some text. 2 Select one or more letters by doing one of the following:  Select one of the letters in the Canvas and, to modify more than one character at a time, hold down the Shift key while selecting additional, contiguous letters. A bounding box appears around the selected letter(s), with a handle in each of the upper corners.  Highlight one or more letters in one of the text-entry areas of the Inspector. Bounding boxes appear around the selected letters in the Canvas.  Marquis-select one or more letters in the Canvas by dragging a box with the cursor. Any letter that touches the marquis area is selected, and reveals its bounding box. 3 Click inside the bounding box and drag the letter anywhere in the Canvas. 4 Drag the upper-left handle to rotate the letter. Rotation handle Sizing handle All of the characters reside on a single track. Glyph bounding box78 Chapter 5 Working With Text 5 Drag the upper-right handle to change the letter’s size. Note: You can restore a letter to its original size and placement by choosing Layout > Reset Position. 6 Change the letter’s attributes in the Attributes tab or the Style tab of the Inspector. 7 Click in the Canvas away from the track. The bounding box around the character disappears, but the track is still selected. 8 Reposition the track in the Canvas and modify its attributes. Note: These adjustments affect the entire track, including the letter you’ve just modified. Disabling Fonts in Mac OS X In Mac OS X v10.3, you can use the Font Book application to disable fonts. However, LiveType requires that certain fonts—Geneva and Helvetica—are always available, so these two fonts should not be disabled. If you disable these fonts, you may experience unpredictable behavior in LiveType. 6 79 6 Working With Objects, Textures, and Imported Elements Titling compositions often center around words, but all kinds of additional elements are used to frame, enhance, and accompany them. For the purpose of this manual, these elements fall into three categories:  Objects included with LiveType  Textures included with LiveType  Static images and movies originating from other sources All of these elements are modified and moved around in the Canvas in the same way. They do not rest on a linear track, as text does, unless you add multiple, identical objects to a track (see “Creating Strings or Stacks of Elements” on page 84). Instead, when selected, they display a bounding box, like a single character selected on a text track. At the upper-right and upper-left corners of the bounding box are scale and rotation handles. 80 Chapter 6 Working With Objects, Textures, and Imported Elements Working With LiveType Objects Objects in LiveType are graphical elements with an alpha channel, designed to frame or emphasize text. Most of them are animated and, much like LiveFonts, can be sized, rotated, colored, and stretched. You can add a shadow, glow, or an extrusion. And you can apply effects to them. Objects placed in the Canvas are represented as tracks in the Timeline, like any other titling element. To add a LiveType object to the Canvas: 1 Click the Objects tab in the Media Browser. 2 Browse the categories of objects displayed in the Category pop-up menu, and select an object in the Name column of the Objects tab. 3 Click the Apply To New Track button. The object appears in the Canvas, and a corresponding track appears in the Timeline. LiveType objects available in the Media BrowserChapter 6 Working With Objects, Textures, and Imported Elements 81 Working With LiveType Textures Textures in LiveType are colorful animated patterns that can be used as full-screen or partial backgrounds, or as animated fills when used with the matte function, described in Chapter 5, “Working With Text,” on page 57. Textures are versatile, and can be transformed in the same ways an object is transformed, particularly if the texture is reduced in size to take up only a portion of the Canvas. To add a texture to the Canvas: 1 Click the Textures tab in the Media Browser. 2 Browse the categories of textures displayed in the Category pop-up menu, and select a texture in the Name column of the Textures tab. 3 Click the Apply To New Track button at the bottom of the Textures tab. The texture fills the Canvas, and a track appears in the Timeline, just above the background bar. Textures available in the Media Browser82 Chapter 6 Working With Objects, Textures, and Imported Elements Importing Graphics, Images, and Movies Graphical elements in a wide range of formats can be incorporated into a LiveType project. Scanned images, photos, and illustrations, as well as movies and animations, can be used as part of your titling composition. And, like objects and textures, they can be modified and placed in numerous ways. LiveType can import elements in a variety of formats. To import a graphic, image, or movie: 1 Choose File > Place. 2 Locate the file, then click Open. The element appears in the Canvas, and a corresponding track appears in the Timeline. LiveType import formats AVI JPEG PICT QuickTime movie BMP MPEG-2 and MPEG-4 PLS SGI DV Photoshop PNG Targa GIF PICS QuickTime image file TIFF Imported movie, scaled and rotated LiveType texture, scaled and rotatedChapter 6 Working With Objects, Textures, and Imported Elements 83 Transforming Objects, Textures, and Imported Elements Imported elements can be positioned, changed, and animated as easily as text. A photo can be made to bounce around the Canvas, fade in and out, grow and shrink, or take on a purple hue, for example. Sizing and Positioning Objects, Textures, and Imported Elements When you first place a movie or texture in the Canvas, its position is locked by default. These types of elements are frequently used as full-screen background elements that don’t need to be sized or moved. However, you can unlock them easily. To unlock the position of a texture or imported movie: 1 Select the track you want to unlock. (Sometimes this is easiest to do in the Timeline.) 2 Choose Layout > Lock Position. The checkmark next to Lock Position disappears, and the bounding box handles on the element are now active. When you select a non-text element in the Canvas, a bounding box appears around it, the same as an individual character on a text track. If you select a full-screen element, it’s easier to see the bounding box if you zoom out in the Canvas. To resize, rotate, and reposition a non-text element in the Canvas: m Drag the bounding box and its upper-left and upper-right handles. Non-text elements can also be transformed with any of the attributes available to text characters: shadow, color, blur, and so on.84 Chapter 6 Working With Objects, Textures, and Imported Elements Creating Strings or Stacks of Elements In a way, LiveType looks at textures, objects, and imported elements as special kinds of glyphs, or text characters. More to the point, individual elements are treated like fonts whose character set consists of only one glyph. This allows you to do an unusual thing in LiveType: You can create strings, or multiple copies, of these elements on what, for all intents and purposes, amounts to a text track. Anything you can do with one letter of a text font, you can do with objects, textures, and imported elements. Note: Objects cannot, however, be formatted as multiple lines on one track. To create a string of elements on one track: 1 Add an object, texture, or imported element to the Canvas. 2 Make the object a reasonably small size to duplicate in the Canvas: a Click the Attributes tab of the Inspector, then click the Glyph button. b Make sure the lock icon next to the Scale sliders is closed, or locked, for proportional scaling. If it appears to be unlocked, click the icon to lock it. c Adjust the Scale sliders, or enter a value in one of the Scale fields. 3 Click inside the text-entry box in the upper-left corner of the Inspector. Note that a single bullet is in the window, representing the object as a single glyph. One imported graphic duplicated on one trackChapter 6 Working With Objects, Textures, and Imported Elements 85 4 With the blinking cursor in the text-entry box, press the Space bar or type any key. A second bullet appears in the text-entry box, and now two identical objects are on a linear track in the Canvas. Add as many objects as you like. 5 Adjust the tracking and alignment in the Text tab of the Inspector, and any other attributes that you might apply to a string of letters, including formatting individual elements on the track separately. Changing Attributes and Styles Just as non-text elements can be treated as glyphs, they can take on all of the same styles and attributes available to text. Chapter 5, “Working With Text,” on page 57 describes all the transformations available in the Inspector. You might want to try the following for a digital image or movie:  Reduce the size of the image, position it in the Canvas, and rotate it 20 degrees, using the Scale, Offset, and Rotate controls in the Glyph pane of the Attributes tab in the Inspector.  Add a shadow, outline, or extrusion to the image, using Style functions.  Shift the color of the image using the Color controls in the Glyph pane of the Attributes tab in the Inspector.  Apply a preset effect to the image, or animate it yourself by building your own effect. Chapter 7, “Working With Effects and Keyframe Animation,” on page 87 explains how to do this. Other imported elements—logos, line art, or simple graphical elements—are even more versatile. They might lend themselves to a matte treatment, glow or blur, or an outline with the original element rendered invisible. There’s no end to the possibilities. Replacing Media in a Track You can easily replace any movie or image in a track on the Timeline at any time. To replace any movie or image with new content: 1 Control-click the chosen track, then choose > Reconnect Media from the shortcut menu. 2 Navigate to the new file in the Open dialog, then click Open. The existing media is replaced with a new movie or image.7 87 7 Working With Effects and Keyframe Animation Effects are what make your Canvas elements move and transform. They are “packages” of animation, encapsulating the parameters that govern motion and timing, as well as an element’s attributes in any given frame. The key ideas about effects are as follows:  All motion and transformations built into your titling movie are controlled by effects, whether you create your own or take advantage of the preconfigured effects in LiveType.  Effects are applied to tracks. They appear in the Timeline as bars underneath the track they’re applied to.  More than one effect can be applied to the same track, even at the same time.  You can change an effect once it is applied to a track, and you can save the modified effect so it’s available to use on other tracks and in other projects.  When a track and an effect have conflicting parameters, the effect parameter overrides the track parameter. For example, if an effect specifically turns the Glow style off, the track’s glow settings are irrelevant.  When a track and an effect have complementary parameters, the two values are combined. For example, if a track has an opacity of 50 percent, applying an effect with 50 percent opacity will result in an opacity of 25 percent in the Canvas, or half of the track’s 50 percent opacity.  You can edit or build an effect outside of the LiveType interface. Instructions for writing EffectScript code are in Appendix B, “Creating and Editing EffectScripts,” on page 135.  Effects can be applied to individual characters on a track and managed from the Effects tab in the Inspector.88 Chapter 7 Working With Effects and Keyframe Animation Preset Effects Following is a table listing all of the 41 available preset effects found in LiveType. These effects are located in the Effects tab of the Media Browser. Applying Preset Effects The preset effects in LiveType add personality to your titles and can be used to set the tone of your composition. Browse through the available effects in the Media Browser to get a sense of what they can do. To apply a preset effect to a track: 1 Create a track that contains text or any other kind of element. Make sure it is the active track. 2 Click the Effects tab in the Media Browser. The Category pop-up menu reveals the categories of installed effects, corresponding to the subfolders on your computer located at /Library/Application Support/LiveType/Effects. LiveType effects Caricature  Baffle  Bounce Track  Bounce  Bouncy  Elastica  Quick Twist Fades  Cluster  Foreground  Pile Up Fantasy  Chatter Out  Dispersion  Expand  Ideas  Invent  Send Off  Z Space Glows  Blue Light  Combustible  Exhale  Follower  Impression  Light Beam In  Light Beam Out  Morph  Peace  Rising Sun  Slider  Spectral  Zapper Grunge  Text Static Mechanical  Assembly  Buzz Saw  TV Off Motion Path  Departing  Escape  Parting  Random Drop  Slide Hang  Vent Shadows  Pit Stop Zooms  ViewpointChapter 7 Working With Effects and Keyframe Animation 89 3 Choose an effect in the Name column of the Effects tab. The Browser preview depicts how the effect works, the Duration column shows the default effect length, and the Description field contains notes about how best to apply the effect. 4 Do one of the following:  Select the effect name and click Apply.  Double-click the effect.  Drag the effect into the Effects tab of the Inspector. When you apply an effect, a bar appears under the active track in the Timeline, labeled with the effect name. If the effect includes motion, you immediately see the movement reflected in the Live Wireframe Preview in the Inspector. Depending on the position of the playhead in the Timeline, the Canvas itself may or may not change noticeably. Move the playhead to see how the track elements change at different points in time, or click the Play button in the Canvas to view a RAM render. The effect also appears in the Effects tab of the Inspector. The Effects tab shows a list of the effects that have been applied to a track. The stack order does not affect the sequence, or timing, of any effect. To disable an effect: m Click the Enable/Disable button in the Timeline next to the effect. The Effects tab of the Media Browser90 Chapter 7 Working With Effects and Keyframe Animation To disable an effect for one or more glyphs on a track: 1 Select the track. 2 Select the character(s) that you don’t want the effect to apply to, either by highlighting them in the text-entry box or selecting them in the Canvas. Because you cannot select noncontiguous characters at the same time, you may have to do these steps more than once. 3 In the Effects tab of the Inspector, deselect the checkbox next to the effect you want to turn off for the selected characters. Adjusting the Timing of an Effect All of the timing parameters applicable to tracks that contain LiveType media elements also apply to effects. Just as you can drag a track in the Timeline to adjust its starting point and duration, you can do the same with an effect. Settings in the Timing tab of the Inspector determine how an effect is applied to each letter on a track, how fast it runs, and how many times the effect repeats. The Timing tab includes an array of options that allow you to orchestrate the movement of your Canvas elements. Timing tab settings apply to the effect that is selected in the Timeline. Canvas elements reflect the current frame, as determined by the playhead position. The Effects tab of the Inspector shows the effects applied to the active track. Preset effects are applied from the Effects tab of the Media Browser. Playhead Effects TrackChapter 7 Working With Effects and Keyframe Animation 91 To adjust an effect’s timing parameters: 1 In the Timeline, select an effect that has been applied to a track. 2 Click the Timing tab in the Inspector. The current timing parameters for the selected effect are reflected. The Timing tab contains the following timing options:  Random: A randomized effect treats each character on a track separately, as opposed to applying the effect parameters to the entire track at once. With this setting, the effect transforms each character in a random order, separated by the designated number of frames or seconds. The Seed field allows you to select alternative random orders, up to 255, if the order doesn’t look quite right.  Sequence: A sequenced effect starts by transforming one character, then moves to the next adjacent character, and so on. A sequence value of 0 indicates that the effect plays simultaneously for all characters. With a value of 25, the effect begins to transform the first character, then when the effect is 25 percent into the transformation, it begins to transform the next character, and so on. The Start pop-up menu below the Sequence slider defines the direction from which the sequence begins.  Speed: You can change the speed of an effect, as a percentage of its default speed. Increasing an effect’s speed decreases its duration. The Start pop-up menu below the Speed slider allows you to run the effect in reverse.  Delay: The delay setting sets the start or end time of the effect in relation to the beginning or endpoint of the track. Using this setting is an alternative to positioning an effect directly in the Timeline. The Timing tab of the Inspector92 Chapter 7 Working With Effects and Keyframe Animation  Loop: The loop setting determines how many times the effect will repeat. A loop value of two doubles the duration of the effect. The To End checkbox makes the effect loop continuously for the duration of the track.  Duration: This setting governs the duration of a track containing system font text or any other static element. The duration of effects, as well as tracks containing dynamic elements such as a movie clip or LiveFont, is adjusted with the Speed slider.  Hold First: With this option, the parameters for the first frame of an effect are maintained for the designated period of time before the effect kicks in. For example, if you want a track to fade in after two seconds, you can choose Hold First for two seconds, during which time the track is invisible (or 0 percent opaque), before the Fade In effect begins.  Hold Last: This works the same way as Hold First, but at the end of the effect, to extend the final-frame parameters of the effect for a designated amount of time. To adjust the timing of an effect in the Timeline, do one of the following:  Drag in the middle of the effect bar (but not on a keyframe) to position the effect without changing its speed. This affects the effect’s Delay value, as seen in the Timing tab of the Inspector. Note: You can position an effect so that it extends beyond the boundaries of the track, in which case the extraneous effect parameters aren’t used.  Drag either edge of the effect to adjust its speed. An effect that is shorter in duration runs through its motions more quickly. Resizing from the left edge of an effect whose Delay Start value is set “From Start” changes the effect’s speed and delay. The same is true when resizing the right edge of a “From End” effect. Repositioning Groups of Effects Within a Track to Adjust Timing If you have multiple effects in a single track, you can move them in unison to adjust their timing. To reposition groups of effects within a track: m In a track with multiple effects, hold down the Option key as you drag any single effect. The effects move up and down the Timeline in unison. All effects in the track maintain their relative positions but occur at an earlier or later point in time.Chapter 7 Working With Effects and Keyframe Animation 93 Changing the Order of Effects In a track with more than one effect, you can change the order (precedence) of an effect by dragging it vertically. If the effect has timing information, its position in the new track may be adjusted. To change the order an effect: m Drag the effect up or down within the track. The order of the effects has now been changed. Duplicating Effects and Tracks You can easily duplicate effects and tracks, including duplicating an effect from one track to another. To duplicate an effect or track: In the Timeline, Option-drag an effect or track to the new location or track. Holding down the Option key while dragging an effect makes a copy of the effect in a new effects track. Modifying a Preset Effect In addition to adjusting the timing parameters of an effect, you can change what the effect actually does; that is, how it transforms the track it’s applied to. Altering an effect used in your project does not alter the original preset effect. Once you have applied the effect, you are free to adjust it, and the changes you make are saved as part of your project.94 Chapter 7 Working With Effects and Keyframe Animation Keyframes and Sequencing Markers Computer animation is based on the concept of keyframes. Animators define a graphical element’s parameters—position, color, size, shape, and so on—at periodic intervals, and the software interpolates the parameters for each frame in between. Keyframes are represented in the Timeline as diamond-shaped markers in effects. When you select a keyframe, the playhead moves to that frame, and the Canvas reveals the state of the project elements at that point in time. To view the parameters defined by a keyframe: 1 Select the keyframe in the Timeline. 2 Click the Effects tab in the Inspector. The parameters defined by that keyframe appear in the Active Parameters window. The Clockwise effect, for example, only has one active parameter for its keyframes. Regardless of the track attributes or other effects that may affect the track, the Clockwise effect is concerned only with making the letters on the track spin. The sequence timing parameter for the effect applies the rotation to each character on the track one after the other, from left to right. Sequencing markers, vertical lines in the light purple area of an effect bar, show when each glyph starts to be acted on by the effect. The number of sequencing markers, including the first frame of the effect and the beginning keyframe of the effect (depicted by half diamonds), always equals the number of glyphs on the track. Note: Not all effects are sequenced or randomized; therefore, not all effects have sequencing markers. Sequencing marker KeyframeChapter 7 Working With Effects and Keyframe Animation 95 Adjusting Keyframe Parameters To change what an effect does, you have to alter its keyframes. While you can change an effect’s parameters through the Effects tab by entering numeric values, it is usually easier to make changes in a more visual way, using the full LiveType interface. To adjust a keyframe by changing parameters in the Inspector: 1 Select a keyframe in the Timeline. The playhead moves over the keyframe and the Canvas reflects the appearance of the composition at that frame. Note: If you change an effect parameter when the playhead is not over a keyframe, a new keyframe is added at the current playhead position. 2 Adjust the attributes of the track. The LED indicators in the Inspector indicate which attributes can be changed in the context of an effect—they are all in the Text, Style, and Attributes tabs of the Inspector. 3 Click the Play button in the Canvas to see the results of your modification. LED indicators appear when an effect is selected.96 Chapter 7 Working With Effects and Keyframe Animation To adjust a keyframe by changing parameters in the Canvas: 1 Select a keyframe in the Timeline. 2 Click a letter or the object to reveal its bounding box. 3 Manipulate the selected glyph to change its position, rotation, or scale. When you drag the glyph, the entire word moves with it, and a motion path with small incremental dots appears. Each dot on the motion path represents the pivot point of the selected letter at every frame of the movie. Notice that if you select a different letter, a slightly different motion path appears, representing the center position of that letter for each frame. 4 Click the Play button in the Canvas to see the results of your modification. LED Indicators in the Inspector When you select an effect or keyframe, the Text, Style, and Attributes tabs in the Inspector reveal small round lights, or LEDs, to the left of all attributes that can be modified in an effect. The LEDs serve three purposes:  They indicate which parameters in the tab are active in the selected effect, allowing you to see the pertinent values at a glance.  They allow you to activate a new parameter for an effect.  They let you apply an attribute evenly across all keyframes in the effect. This is a very useful feature, as it lets you make global changes to an effect without having to select and modify each keyframe. To apply an attribute evenly across all keyframes in an effect: 1 Select the effect. 2 Change an attribute in the Text, Style, or Attributes tab. 3 Hold down the Option key and click the LED indicator next to the attribute you just changed.Chapter 7 Working With Effects and Keyframe Animation 97 Active Parameters The Active Parameters area of the Effects tab of the Inspector is a valuable resource for identifying which parameters are active in an effect, and what their values are at any point in time, as defined by the playhead position. Active parameters are displayed with the values associated with the current frame. Parameter variables are further described in Appendix B, “Creating and Editing EffectScripts,” on page 135. To change a parameter value in the Effects tab: 1 Select a keyframe. 2 Double-click a parameter in the Active Parameters stack. 3 Enter a value in the parameter dialog, then click OK. Note: If you change a parameter when the playhead is not at a keyframe, a keyframe is added to the effect at the playhead position. The Parameter pop-up menu lists all of the keyframe parameters. To add a new parameter to the Active Parameters stack of an effect: 1 Select the effect. 2 Do one of the following:  Click the LED next to the parameter in the Text, Style, or Attributes tab of the Inspector. The selected LED illuminates.  In the Effects tab of the Inspector, make a selection from the Parameter pop-up menu and click the + button. The parameter appears in the Active Parameters stack.  Change the parameter for one keyframe in the Text, Style, or Attributes tab of the Inspector.  Add Offset, Rotation, or Scale to the stack by modifying a glyph of the active track using the bounding box handles or dragging the glyph to a new position.98 Chapter 7 Working With Effects and Keyframe Animation Example: Modifying an Effect The following example shows how easy it is to change an effect and create a dramatically different look. In this case, you want to add motion to the Fade In effect. 1 Set up a new project as follows: a Choose File > New. b Type “Adventure” into one of the text-entry boxes in the Inspector to add the word to the track. c Apply any system font to the track, for simplicity. d Set the Render Selection Out Point by positioning the playhead at one second, then pressing the O key. 2 Apply the Fade In effect to the track, which is in the Fades category in the Effects tab of the Media Browser. Notice the following changes:  The effect is immediately represented in the Live Wireframe Preview of the Inspector.  If your playhead is on the first frame, the text disappeared in the Canvas when you applied the effect. That’s because the Fade In effect begins with an opacity of 0. 3 If your playhead is not at the first frame, move it there. For this example, start with a simple text track in a system font.Chapter 7 Working With Effects and Keyframe Animation 99 4 In the text-entry box of the Inspector, highlight the “A” of Adventure. Even though the text is invisible in the Canvas, a bounding box appears, allowing you to adjust the glyph. Notice also that the first keyframe of the effect is now at the first frame, with the sequencing markers behind, representing the other letters in the word. 5 Modify the glyph in the Canvas as follows, and watch the results in the Live Wireframe Preview as you go: a Drag the sizing handle in the upper-right corner of the bounding box to make the glyph quite large, about one-third of the width of the Canvas. b Using the rotation handle in the upper-left corner of the bounding box, tilt the glyph about 45 degrees counterclockwise. c Drag the glyph so its pivot point is in the lower-left corner of the Canvas, allowing part of the glyph to extend off the Canvas. Make sure the playhead is on the first frame. Position the Render Selection Out Point at one second. Sequencing markers representing the end of the effect for each remaining letter in the word. Duration of the Fade In effect on the “A” glyph Resize, rotate, and reposition the bounding box of the “A” glyph. UP01103EFF Page 99 Tuesday, March 8, 2005 1:56 PM100 Chapter 7 Working With Effects and Keyframe Animation The stack (in the Effects tab of the Inspector) has been changed automatically. The Scale, Rotate, and Offset parameters now apply to this effect, in addition to the original Opacity parameter. 6 Click the Play button in the Canvas or press the Space bar to play a RAM preview. Moving, Deleting, Adding, and Copying Keyframes The more you experiment with effects, the more you’ll want to create and change them to suit your own tastes. For example, you can change the placement of keyframes in an effect to make it play out differently. Or you can add or delete a keyframe entirely. To move the position of a keyframe in the Timeline: m Drag the keyframe marker left or right within the effect bar. To delete a keyframe: 1 Select the keyframe you want to remove. 2 Choose Track > Delete Keyframe. Note: If you select a keyframe and press the Delete key, the entire effect is deleted.Chapter 7 Working With Effects and Keyframe Animation 101 To add a keyframe to an effect: 1 Select the effect you want to add a keyframe to. 2 Drag the playhead to the frame where you want to insert a keyframe, or click that frame’s position in the frame ruler. 3 Do one of the following:  With the playhead in position and the effect selected, choose Track > Add Keyframe (or press Command-K).  Change any parameter in the Text, Style, or Attributes tab of the Inspector, or adjust a glyph of the active track using the bounding box handles or dragging the glyph to a new position. A keyframe marker appears in the effect bar. To copy a keyframe: 1 Select the keyframe you want to copy, then choose Edit > Copy. 2 Position the playhead over the frame where you want to insert the duplicate keyframe, then choose Edit > Paste. You can copy and paste keyframes from other effects, even in other projects. Copying and Pasting Keyframes, Effects, and Tracks Between Projects You can easily copy and paste keyframes, effects, and tracks from one project to another. To copy and paste a keyframe between projects: 1 Open the project you want to copy the keyframe from. 2 In the Timeline, do one of the following:  Select a keyframe, then choose Edit > Copy Keyframe (or press Command-C).  Control-click the keyframe, then choose Copy Track, Copy Effect, or Copy Keyframe from the shortcut menu. 3 Open the second project, and in the Timeline, position the playhead where you want the new keyframe to appear. 4 Do one of the following:  Choose Edit > Paste (or press Command-V).  Control-click the track, then choose Paste from the shortcut menu. The keyframe is copied into the second project.102 Chapter 7 Working With Effects and Keyframe Animation To copy and paste effects or tracks between projects: 1 Open the project you want to copy from. 2 In the Timeline, do one of the following:  Select the effect or track, then choose Edit > Copy (or press Command-C).  Control-click the effect or track, then choose Copy Track or Copy Effect from the shortcut menu. 3 Open the second project, click in the Timeline, then do one of the following:  Choose Edit > Paste (or press Command-V).  Control-click a track, then choose Paste from the shortcut menu. The new effect or track is copied into the second project. Renaming and Saving Modified Effects When you change an effect in a LiveType project, it no longer has the same attributes as the preset effect accessed through the Media Browser. You might even use different versions of the same preset effect in one project. There are two ways to keep track of these changes: rename effects within your project to distinguish them from the original preset effects, or save them as new effects you can use any time. To rename an effect within a project: 1 Select the effect or the track it’s applied to. 2 Click the Effects tab of the Inspector. 3 Select the effect whose name you want to change, and edit the name. The new name is reflected in the Timeline. To save a new or modified effect: 1 Select the effect. 2 Choose Track > Save Effect. 3 In the Save Effect dialog, name the effect and select the category you want to save it into, or create a new category. The effect appears in the Effects tab of the Media Browser. Note: For the Media Browser to display a preview of the saved effect, you must create a preview clip at 160 x 120 pixels, and give it the same name as the effect with the appropriate extension. Preview clips can be in any QuickTime format, but if you’re planning to create a lot of these, MPEG-4 is a good format choice, as it saves considerable disk space. Save preview clips into the Effects folder located at /Library/ Application Support/LiveType, where saved effects are stored.Chapter 7 Working With Effects and Keyframe Animation 103 Creating a New Effect From Scratch Sometimes the most efficient way to create the effect you want is to start from scratch, as opposed to changing an existing one. The workflow goes like this: 1 Decide, roughly, what you want to animate and how you want it to move and transform. 2 Create a track that contains the element you want to animate, preferably in its firstframe state. 3 Configure the timing of the track—its starting frame and duration. 4 Add a new, blank effect to the track. 5 Add keyframes to the effect, and adjust the parameters for each. 6 Save the effect, if desired, for use with other tracks or in other projects. To add a new, blank effect to a track: 1 Select the track you want to add the effect to. 2 Choose Track > New Effect (or press Command-E). A new effect appears in the Timeline below the active track. 3 Name the new effect, if you want, by double-clicking the New Effect name in the Effects tab of the Inspector.104 Chapter 7 Working With Effects and Keyframe Animation Example: Creating a New Effect The following example demonstrates how to build a new effect. In this case, part of the text on a single track will bounce around the Canvas. This example highlights how motion paths are built into an effect. 1 Start a new default project, and add a few words of text to the empty track in any font. One of these words is going to move around the screen, independent of the other word(s) on the track. 2 Position the track in the Canvas as you like. This will not affect the movement of the bouncing word. 3 Set the duration of the track by dragging its right edge in the Timeline. Two or three seconds is plenty. 4 Create a new, blank effect, which enables you to apply movement to the text. Make the effect duration match the track duration in the Timeline. 5 Now, even before you build the effect, make it apply to only one word on the track. That is, turn off the effect, as described in “Preset Effects” on page 88, for the words that won’t be moving. 6 Add the first of three or four keyframes spaced evenly across the effect. a Click in the frame ruler to position the playhead. b With the playhead in position and the effect selected, choose Track > Add Keyframe (or press Command-K).Chapter 7 Working With Effects and Keyframe Animation 105 7 The next step is to position the word at the point of its first “bounce.” You’re adding x and y offset parameters to the effect. a With the keyframe selected, select one of the letters you want to move. A bounding box appears around it. b Drag the letter to a new position in the Canvas. The entire word, or all the letters that the effect applies to in this case, moves with the selected letter. Notice that the motion path appears. c If you like, change the size, color, or any other attribute of the text for this keyframe. 8 Create a second keyframe, and drag the text to another location. Now the motion path is a triangle. Create a few more “bounces” for the word. Motion paths can also be curves. The process is similar to creating curved tracks as described in Chapter 4, “Working With Tracks,” on page 47. 9 Add curves to your motion path by doing the following: a With the effect selected in the Timeline, click a keyframe, or move the playhead over a keyframe. b Select one glyph in the “bouncing” word. c Hold down the Control key and drag the pivot point of the glyph, which is over the keyframe point in the motion path. Keyframe point Motion path of the “u” glyph106 Chapter 7 Working With Effects and Keyframe Animation d Bezier handles extend away from the point, allowing you to adjust the curve. 10 Click Play in the Canvas, or press the Space bar, to see the results. Creating Effects for Individual Glyphs A unique and powerful feature of LiveType lies in the ability to instantly assign an effect to individual or selected groups of glyphs, or characters, on a track. This method can be used with new effects, as well as preset effects. To assign an effect to individual characters: m Select the character or characters you want to apply the effect to, then do one of the following:  Choose a preset effect from the Effects tab of the Media Browser, then click Apply.  Create your own effect by choosing Track > New Effect, then applying effects from the parameter menu in the Effects tab of the Inspector. The selected effect is automatically turned off for all characters that are deselected. If the track is selected and no characters are selected, the effect is applied to the entire group of characters on the track. You can reassign all characters to a single effect at any time. Hold down the Option key and drag a keyframe point to pull out Bezier handles, creating a curved motion path.Chapter 7 Working With Effects and Keyframe Animation 107 Finding Effects and Media Using the Timeline You can quickly find effects, movies, and images from the Timeline using a shortcut menu. To find effects and media using the Timeline: m In the Timeline, Control-click a track, then do one of the following:  To find effects, choose Reveal in Media Browser from the shortcut menu.  To find movies or images, choose Reveal in Finder from the shortcut menu. The effect is selected in the appropriate tab in the Media Browser, or a Finder window appears with the movie or image selected.8 109 8 Previewing and Fully Rendering Your Titling Movie As your project progresses, you’ll want to view the results of your changes every step of the way, until you’re ready to generate the final output. LiveType offers several modes and choices for managing the time it takes to render previews. Previewing Your Work Viewing a frame of your titling movie is as simple as moving the playhead in the Timeline to any frame marker and looking at the Canvas elements. Obviously, you also need to be able to see the action of your movie. LiveType offers several ways to do this. Live Wireframe Preview The Live Wireframe Preview window in the upper-right corner of the Inspector continually scrolls through your animation, with small bounding boxes indicating the movement of each character or object. This feature gives you an indication of your project’s motion and timing at any moment. To freeze or unfreeze the Live Wireframe Preview: m Click inside the Live Wireframe Preview window in the Inspector. Live Wireframe Preview in the Inspector110 Chapter 8 Previewing and Fully Rendering Your Titling Movie RAM Preview in the Canvas The transport controls at the bottom of the Canvas allow you to play a preview of your titling movie right in your working environment. A RAM preview displays all elements that are visible and enabled in the Canvas, as well as the Canvas guides, rulers, and so on. Thus, it differs from a preview movie, which reflects the final movie output more closely. To play a RAM preview, do one of the following: m Click the Play button in the transport controls at the bottom of the Canvas. m Press the Space bar. At first, the frames are rendered and loaded into memory one by one; then the preview plays in real time. The Pause button is displayed during this process. The right-most transport control, the Loop button, is a toggle that sets the RAM preview to either play once through or continually loop through the movie. When the Loop button is activated, or blue, the RAM preview loops until you click anywhere in the LiveType interface. To stop a looping RAM preview: m Click anywhere in the LiveType interface. To pause a RAM preview: m Click the Pause button at any time during a RAM preview. The Play button appears and the RAM preview stops. The RAM preview resumes when you click the Play button once more. Transport controlsChapter 8 Previewing and Fully Rendering Your Titling Movie 111 Preview Movie A preview movie is basically a limited render of your titling movie. To render a preview movie: 1 Choose File > Render Preview, then choose Wireframe or Normal. The Normal setting renders your preview at the level defined in the Project Properties dialog. LiveType looks for the .afd files in your /Library/Application Support/LiveType/ LiveType Data folder if you have used any LiveType media in your composition. If the data files have not yet been installed, the Missing AFD dialog appears, giving you the option to install the full data files or to use proxy frames (from the corresponding .afp files) in the preview. 2 Do one of the following:  Select “Install missing LiveType Data now.” This allows you to install the .afd files at a location other than the LiveType Data folder, but still access them to render previews and final movies. See “Managing LiveType Media Files” on page 29 for instructions.  Select “Use Poster Frames for Tracks with missing Data.” The preview appears in a separate window. You can save a preview movie by choosing File > Save As. Otherwise, LiveType deletes the preview movie when you close the window.112 Chapter 8 Previewing and Fully Rendering Your Titling Movie Optimizing Preview Performance LiveType works with bitmapped elements that consist of pixels of information, as opposed to vector-based data. While this format is what makes possible the wide range of effects offered in LiveType, file sizes are inevitably large, and the time it takes to render a preview can become lengthy. Rendering time is affected by each layer of complexity added to a project, including the number and file size of project elements, the number of effects applied to each element, and the duration of the movie (that is, the number of frames to render). Quality Settings for Previews and Movie Output LiveType offers four levels of rendering quality, set in the Project Properties dialog, to help you manage the amount of time you spend generating previews. Naturally, a lower-quality preview takes less time to render. A wireframe-quality preview represents each element as an empty bounding box, much like the small Live Wireframe Preview in the Inspector. Draft, Normal, and High Quality settings differ only in the resolution of the preview. A draft-quality Canvas appears slightly grainy at 100 percent zoom. A draft-quality preview movie appears small on the screen. You may find that, as you build your project, it is useful to adjust the quality settings several times, to suit your preferences. To adjust the quality settings for viewing the Canvas, generating preview movies, and rendering a final movie: 1 Choose Edit > Project Properties. 2 In the Quality area of the dialog, choose the quality level for each of the three modes.Chapter 8 Previewing and Fully Rendering Your Titling Movie 113 Strategies for Improving Render Times In addition to the quality settings, LiveType offers numerous strategies to avoid excessive waiting for frames and previews to render:  The Render Selection markers in the frames ruler of the Timeline limit the number of frames that are rendered in preview movies and in the final output.  The Selected Only option in the View menu reveals only the contents of the active track in the Canvas, in preview movies, and in final movie output. This can be useful when you’re focusing on the movement of a single element.  The Enable/Disable buttons in the Timeline allow you to temporarily disable effects and remove tracks from the Canvas. This is another way to reduce complexity when you only require a partial preview.  The file size of imported elements affects system performance. For example, instead of importing a large movie as a background for keying titles, consider importing a single frame or small clip. If an imported element is to be used in your final output, generate the original file at or near the needed resolution, as opposed to bringing in a large image and shrinking it down in LiveType.  The amount of RAM memory on your system may be a factor. If saving time is critical, you may want to consider increasing your available RAM. Rendering, Saving, and Exporting Your Titling Movie There are a couple of different ways to handle rendering, saving, and exporting your LiveType project once you have completed it. The most practical method to choose largely depends on whether you are going to work with your project within Final Cut Pro or in another application.  If you are working with Final Cut Pro, import the LiveType project directly into Final Cut Pro for final rendering.  If you are working with another application, render within LiveType first, then import the rendered movie to the application. Importing a LiveType Project Into Final Cut Pro for Rendering Typically, a saved LiveType project file is imported into Final Cut Pro for rendering. This saves time as, unlike third-party applications, you do not have to render the file in LiveType prior to importing it. To import a LiveType project into Final Cut Pro for rendering: 1 Choose File > Import > Files (or press Command-I), select the LiveType project file, then click Choose. The LiveType movie is imported into Final Cut Pro, appearing as a clip. 2 Edit the clip into a Final Cut Pro sequence. 3 Render the movie as you would any other clip.114 Chapter 8 Previewing and Fully Rendering Your Titling Movie Making Changes to a LiveType Movie from Final Cut Pro If you have imported a LiveType movie into Final Cut Pro and need to make a change, you can make the change in LiveType and have it update in Final Cut Pro. To make changes to a LiveType movie already imported into Final Cut Pro: 1 Select the LiveType clip in the Final Cut Pro Timeline. 2 Control-click the clip, then choose > Open in Editor from the shortcut menu. LiveType opens with the movie ready for adjustment. 3 In LiveType, make any changes you want, then choose File > Save. The change immediately updates in Final Cut Pro. Note: You will have to re-render any changes that you have made within Final Cut Pro. Rendering a LiveType Movie for Export When working with a third-party application, you will need to render your movie within LiveType prior to importing it. To render a full-resolution movie of your project for export: 1 Choose File > Render Movie. 2 Choose a filename and location in the Save dialog, then click “Create new movie file.” 3 Just as with preview movies, LiveType requests that you install any missing LiveType Data files. Do one of the following:  Select “Install missing LiveType Data now.” This allows you to install LiveType media files to a location other than the LiveType Data folder, but still access them to render previews and final movies. See “Managing LiveType Media Files” on page 29 for instructions.  Select “Use Poster Frames for Tracks with missing Data.” Note: By default, a QuickTime movie with an alpha channel is created in the Animation codec. If another codec is preferred, use the options from File > Export Movie instead.Chapter 8 Previewing and Fully Rendering Your Titling Movie 115 Once LiveType has finished rendering your project, it appears in a new window. LiveType Export Formats LiveType natively generates QuickTime movies with the Animation 32-bit codec for proper keying to your video. If your NLE or compositing program imports QuickTime 4 or later movies, you should be able to import these movies directly. You can also export to a variety of motion and still-image formats. Keep in mind, however, that if you want to retain the alpha channel, you must use a format that supports the 32-bit format, such as Photoshop, Targa, TIFF, and AVI. Your rendered movie appears in a separate viewer. (In this example, the background movie was rendered with the titles.) QuickTime codecs QuickTime codecs (cont.) Image sequence formats Other formats Animation Motion JPEGA BMP AVI BMP Motion JPEGB JPEG DV Stream Cinepak None (No compression) JPEG 2000 Image FLC Component Video PhotoJPEG MacPaint Heuris MPEG DV/DVCPRO-NTSC Planar RGB Photoshop MPEG-2 DVCPRO-PAL PNG PICT MPEG-4 Graphics Sorenson Video PNG H.261 Sorenson Video 3 QuickTime image H.263 TGA SGI image Intel Indeo Video r3.2 TIFF TGA Intel Raw Video TIFF116 Chapter 8 Previewing and Fully Rendering Your Titling Movie To export a rendered LiveType movie to a new format: 1 Open your movie output so it appears in the viewer window. If you just rendered your project, the QuickTime movie will be open already. If you previously rendered and saved the movie, open it using File > Open. 2 Choose File > Export Movie. The dialog prompts you for a new name and file location, and offers a variety of file formats to export to. 3 In the Export pop-up menu, choose the category of output you want to create. 4 In the Use pop-up menu, choose the appropriate file format or protocol. 5 Click the Options button to reveal additional settings pertinent to the format you selected.9 117 9 Advanced Design Techniques The key to designing great titles is to combine the capabilities and media in LiveType in creative ways. A few “recipes” for interesting looks are included in this chapter. The following examples assume a general familiarity with the basic functions of LiveType. Because each step is not explained in great detail, you may need to refer to earlier chapters to perform some of the tasks. Words Within Words The Matte to Background option can be used to create some very interesting titling compositions. Unlike Matte to Texture and Matte to Movie or Image, this matting option creates a “window” into any background—even backgrounds composed of several elements. For example, you can create words inside of words. In this case, foreground text defines a window into background text, which slides right to left behind it. Follow these steps: 1 Create the foreground text to define the shape of the matte. a Add a text track in a heavy system font such as Helvetica Bold. b Type a word onto the track, then set the size so the word fills the width of the Canvas. 2 Create an intermediate layer to obscure the background. a Choose a texture from the Media Browser, then click Apply To New Track.118 Chapter 9 Advanced Design Techniques b Make sure the texture is underneath the text, but above the background bar in the Timeline. 3 Create a dynamic background that’s visible through the window created by the foreground word. a Add a new text track to the Canvas, then enter some text that’s smaller than the foreground word you created in step 1. b Position the track over the foreground text, and format the background text as you like. c Apply a crawl or slide effect to the track, to make the text move right to left. d Drag the track below the background bar in the Timeline. e Temporarily disable the texture and the foreground text track in the Timeline. f Define a background color in the Project Properties dialog, or place a different background behind the background text. g Enable the texture and the foreground text track in the Timeline. Foreground text to define the shape of the “window” into the background Texture to obscure the background elements Background elements Foreground elementsChapter 9 Advanced Design Techniques 119 4 Select the foreground text and choose Background from the “Matte to” pop-up menu in the Matte pane of the Attributes tab of the Inspector. Warping Shadows and Glows The Warp feature in the Style tab of the Inspector can be used to create a surprising variety of shapes to enhance your titles. This section describes how the Needle Drop effect takes advantage of the Warp parameter, in combination with several other parameters, to create a unique look. 1 Open a new project, and enter some text in a system font onto the track. 2 Change the text to a bright color in the Glyph pane of the Attributes tab of the Inspector, then close the Colors window. 3 In the Project Properties dialog, change the background color to black, at 100 percent opacity. Matted text reveals a moving word in the background.120 Chapter 9 Advanced Design Techniques 4 Apply the Needle Drop effect to the track, which is in the Glows category in the Effects tab of the Media Browser. 5 Set the track and effect durations to 1 second, set the Render Selection Out Point at 1 second, then click the Play button to render a RAM preview. 6 With the playhead over the effect in the Timeline, click the Effects tab of the Inspector to view the active parameters. The essential parameters used to create the Needle Drop effect are as follows:  Glyph settings: At the beginning keyframe, the glyphs on the track are small, transparent, and blurred. At the ending keyframe, the characters are normal. The middle keyframe simply makes the letters larger than normal.  Glow settings: At the beginning keyframe, the glow is invisible, with a 0 percent opacity, and has a vertical offset of –200 pixels. At the middle keyframe, the glow opacity is set at 500 percent, with some Scale and Blur adjustments and no offset. And at the ending keyframe, the glow is invisible again, and the vertical offset is 200 pixels.  Shadow settings: The shadow is what creates the “needles.” The shadow color is set to white, and the scale is set to 10 percent on the x axis, making the shadows very thin. The warp settings accentuate the narrow tips of the needles. And the shadow blur is set to 2 percent, which is essential for this effect. At the ending keyframe, the shadow goes to 0 percent opacity.  Timing settings: The Random parameter in the Timing tab is used to make this effect apply to each glyph in a random order. The Needle Drop effect applied to text on a black Canvas backgroundChapter 9 Advanced Design Techniques 121 One track, one effect, three keyframes—it’s actually fairly easy to re-create this effect. And even with the numerous parameters involved, the LiveType Timeline is remarkably clean, since one keyframe encapsulates all the parameters at a point in time. For another example showing an effective use of Warp parameters, take a look at the Screech effect, in the Caricature category of the Effects tab in the Media Browser. This effect is created by making the glyphs invisible and using the glow channel to display the letters, which are distorted using Warp parameters. Track Curves Using a Slide effect along a curved track can create a three-dimensional effect. This example explains how to combine these features to send text into a vortex in only a few steps. 1 Open a new project, and enter some text onto the track. 2 Left-justify the text on the track. 3 Move the track up toward the top of the Canvas. 4 Add a control point in the middle of the track by holding down the Control key and clicking the track line in the Canvas. Control-click the control point to choose Curve Out. You want to leave the left half of the track more or less in the same position, and create a curved path arcing down and around clockwise from that point. Only a couple of additional control points are needed. See Chapter 4, “Working With Tracks,” on page 47 for more about making curved tracks.122 Chapter 9 Advanced Design Techniques 5 Add a new effect to the track. 6 Select the ending keyframe of the effect. 7 In the Effects tab of the Inspector, add the Slide parameter to the Active Parameters stack. Double-click the Slide parameter and set the value to 100, which is a percentage of the track’s length. When you assign the Slide value to the ending keyframe, the beginning keyframe defaults to a Slide value of 0. 8 While you’re still on the ending keyframe, set the Size parameter to 0. 9 In the Timing tab of the Inspector, set the Sequence value to 10, and choose From Right from the Start pop-up menu. Add parameters using the Parameter pop-up menu and the + button. Change parameter values by double-clicking an active parameter.Chapter 9 Advanced Design Techniques 123 10 Adjust the ending keyframe Slide value as needed for the right look, which can vary depending on the length of the track and the text sliding on it. Creative Use of Special Characters Symbols and other kinds of special characters can be very useful and convenient as titling elements. Because these characters are vector-based shapes, they have very small file sizes, and no upper limit to their size in the Canvas. Plus, they’re easy to access. This example shows you how to create a pattern of boxes, covering the Canvas, which randomly change colors and fade away to reveal a message or image behind them. 1 Open a new LiveType project, and click in one of the text-entry areas. 2 Open the Character Palette.  If your Character Palette is enabled in your Mac OS X System Preferences, it appears as a small icon on the right side of the LiveType menu. The text appears to spiral down into a vortex.124 Chapter 9 Advanced Design Techniques  To enable the Character Palette, open System Preferences, click International, click the Input Menu button, and select Character Palette.  Alternatively, in LiveType, you can Control-click inside one of the text-entry boxes in the Inspector, then choose Font > Show Fonts from the shortcut menu. The Font dialog appears. Choose Characters from the Extras pop-up menu located on the bottom-left corner of the Font dialog. 3 Choose a solid square character, then click Insert to add the character to the text-entry box. Insert three lines of four boxes on the same text track. Enable the Character Palette in your System Preferences.Chapter 9 Advanced Design Techniques 125 4 Adjust the Size, Tracking, and Leading parameters in the Text tab of the Inspector to create a panel of evenly spaced squares. 5 In the Style tab, disable the shadow, and add a white outline thick enough for the outlines of each square to touch each other, obscuring the Canvas background. 6 Add a new effect, and set the duration of both the track and the effect to 1 second in the Timeline. 7 Select the beginning keyframe of the effect, and choose a glyph color in the Attributes tab of the Inspector. Change the ending keyframe to a different color. Then position the playhead at several intermittent points, changing the color each time. If you change an effect parameter when the playhead is not on a keyframe, a new keyframe is automatically added to the effect under the playhead. This step shows how automatic keyframe insertion can be a convenient time saver. 8 Set the glyph opacity to 0 percent at the ending keyframe, so that squares fade out at the end. First Keyframe Ending Keyframe126 Chapter 9 Advanced Design Techniques 9 In the Timing tab, set the Random setting to 15. 10 Add text or another element behind the panel of squares, so it is gradually revealed as the squares fade away. LiveFonts and Layers Several LiveFonts that come with LiveType are designed to work in tandem with other fonts. One of these is the Nitro font, which can make text look like it explodes. These steps explain how to use such fonts effectively. Note: You need to install the Nitro data file to follow this example. See “Managing LiveType Media Files” on page 29 for information on installing LiveType media. 1 Create a text track, and apply a system font with any basic formatting you like. 2 Choose Track > Duplicate Track to create a copy positioned directly over the original track. 3 In the Timeline, lock the two tracks together using the grouping buttons. 4 Select Track 1, and apply the Nitro LiveFont. 5 In the Style tab of the Inspector, disable the shadow for Track 1. 6 In the Timing tab, set Sequence at 5 percent, then shorten the duration of the track, either by dragging the end of the track in the Timeline or by adjusting the Speed parameter in the Timing tab.Chapter 9 Advanced Design Techniques 127 7 Apply the Fade Out effect to Track 2, since you want the letters to disappear once they’ve exploded. The trick is that you want the letters to fade out just as they explode, and because they are exploding in sequence, you need to align the timing of the sequencing markers for the two tracks. 8 Using the sequencing markers in the Timeline as your guide, adjust the speed of the Fade Out effect to line up the sequencing markers of Track 1 and the Track 2 effect. Align the sequencing markers of the Nitro LiveFont and the Fade Out effect. The combination of the top layer of text in the Nitro LiveFont, and the underlying text that fades away, makes the letters appear to explode from left to right.128 Chapter 9 Advanced Design Techniques Creating Scrolls and Crawls Scroll and crawl effects are used to create credit rolls, or to slide strings of text across the screen like a stock ticker. These two kinds of effects use the Canvas Offset parameter to create a vertical or horizontal motion path long enough to move text onto the Canvas and fully off the opposite side. The offset value, which defines the length of the motion path, is based on the length of the element that’s scrolling or crawling. So it’s best to enter and format the text before applying the effect, so you don’t have to reposition the starting point of the element multiple times. Note: From a design standpoint, scrolls and crawls are best used with system fonts, as opposed to LiveFonts. If you do choose to scroll a LiveFont, you’ll need to work with the font’s timing parameters, including speed and the Hold First and Hold Last options in the Timing tab of the Inspector, to coordinate the LiveFont animation with the scrolling or crawling movement. To create scrolling text: 1 Enter several lines of text onto a new track, using the Return key to create line breaks in the text-entry box. 2 Format the text, paying particular attention to any parameter affecting the total vertical length of the lines of text—font, size, leading, and so on. 3 Apply a scroll effect from the Scrolls and Crawls category in the Effects tab of the Media Browser. 4 Adjust the speed of the scroll, which is now visible in the Live Wireframe preview, by dragging the right edge of the effect bar in the Timeline, or by changing the Speed setting in the Timing tab of the Inspector. 5 In the Timeline, drag the right edge of the track to match the duration of the effect. 6 Move the text to its starting position. a Make sure the playhead is over the first frame in the Timeline. b Set the Canvas zoom to 25 percent, to see outside the boundaries of the Canvas. c Drag the track in the Canvas to set the starting position of the scrolling text. (Text that is beyond the edge of the Canvas is represented by blue bounding boxes.) Hold down the Shift key as you drag to constrain the horizontal position of the track. If you are using the Scroll Up effect, for example, you might want to set the starting position of the first line of text just below the bottom edge of the Canvas. Chapter 9 Advanced Design Techniques 129 To create crawling text: 1 Enter text—typically several words or a sentence on one line—onto a new track. 2 Format the text, paying particular attention to any parameter affecting the total horizontal length of the text—font, size, tracking, and so on. 3 Apply a crawl effect from the Scrolls and Crawls category in the Effects tab of the Media Browser. 4 Adjust the speed of the crawl, which is now visible in the Live Wireframe preview, by dragging the right edge of the effect bar in the Timeline, or by changing the Speed setting in the Timing tab of the Inspector. 5 In the Timeline, drag the right edge of the track to match the duration of the effect. 6 With the playhead over the first frame, drag the track in the Canvas to adjust its starting position. 131 A Appendix A Solutions to Common Problems and Customer Support If you run into problems while working with LiveType, there are several resources you can use to find a solution.  This appendix: This appendix includes information about some of the most frequent issues users encounter.  Late-Breaking News: A late-breaking news page in the LiveType Help menu provides last-minute information that didn’t make it into the manual. Be sure to consult this help page as soon as you install LiveType.  AppleCare Knowledge Base: AppleCare Support maintains a database of common support issues that is updated and expanded to include new issues as they arise. This is an excellent, free resource for LiveType users. To access the AppleCare Knowledge Base, go to the AppleCare support page at http://www.apple.com/support.  AppleCare Support: There are a variety of support options available to LiveType customers. For more information, see the Apple Professional Software Service & Support Guide that comes with your Final Cut Pro documentation. Frequently Asked Questions Some fonts appear to shake in the preview movie.  Because LiveType uses a small sampling for low-quality previews, some images may be missing pixel data that provides smoother movement. Increase your quality settings in the Project Properties dialog to produce smooth results. My images appear pixelated.  If you render a preview, your movie is displayed in low resolution and appears a bit pixelated. Also, if you size your elements beyond their original size, some pixelization may occur.132 Appendix A Solutions to Common Problems and Customer Support LiveType doesn’t open anymore.  It is possible to save a set of default settings that prevents LiveType from opening. Try erasing your default settings file: /Library/Preferences/LiveType Pro Defaults.dat. Your configuration reverts to the original LiveType settings. This is essentially the same as choosing LiveType > Settings > Clear Settings within the application. The motion is not smooth on my NTSC monitor.  Use the fielding option for the smoothest motion. When I bring titles into my nonlinear editor (NLE) or compositing program, the characters appear squashed or the aspect is wrong.  Make sure to set the project properties in LiveType according to the size and pixel aspect your NLE uses. Some NLEs require the correct frame size even if the title doesn’t use the entire frame. Square pixels take a value of 1, and NTSC pixels take a value of .9. A keyframe is “stuck” at the beginning or end of an effect, and I can’t select it, move it, or delete it.  Try increasing the Timeline zoom, to see whether you can select and drag the keyframe away from the beginning or end of the effect. Because the beginning and ending keyframes cannot be deleted, it is possible to slide an internal keyframe to the far end of the effect so that it cannot be moved, regardless of the Timeline magnification. To select an obscured keyframe, do the following: 1 Select the beginning or ending keyframe that’s obscuring the other keyframe. 2 Choose View > Go To > Next Keyframe (or Previous Keyframe) to select the “lost” keyframe. 3 Choose Edit > Cut. 4 Move the playhead and choose Edit > Paste. When I apply an effect with a glow or shadow change, I don’t see a change in the Live Wireframe Preview in the Inspector.  The wireframe boxes in the preview show the basic shape of each glyph, and aren’t changed by Style settings. Other preview options, such as a RAM preview or preview movie, reveal shadows and glows.Appendix A Solutions to Common Problems and Customer Support 133 When I change certain attributes of a track, they don’t seem to have any effect.  Because effect parameters override track parameters, you may be trying to adjust a parameter that is being overridden. Disable the effects associated with that track to see whether the attributes become active again. If so, the solution is to change the effect parameters. I can’t select an element or character.  Make sure that Lock Position is not selected in the Layout menu. When you add a texture or background movie, it is locked by default.  Also, you may be clicking an element that uses the entire Canvas. Try zooming out to view beyond the edge of the Canvas to reveal its bounding box.  Consider the layer order, too, when you want to select an element on the Canvas. If one element gets in the way of selecting another, use the Timeline to select the track underneath, and highlight glyphs in one of the text-entry boxes in the Inspector. I keep accidentally selecting the texture, image, or movie I created on a track as a background image.  Choose Layout > Lock Position to prevent the element from being selected. When I have a lot of elements in the Canvas, everything slows down.  See Chapter 8, “Previewing and Fully Rendering Your Titling Movie,” on page 109 for ways to optimize preview performance. Apple Applications Page for Pro Apps Developers The Apple Developer Connection website includes an Apple Applications page that is a one-stop destination for developers creating content or extensions for professional applications. On this page, developers can find late-breaking news of interest and technical resources such as developer documentation, special articles, and SDKs. Developers can also sign up for a new Pro Apps Developer mailing list. The URL is http://developer.apple.com/appleapplications. UP01103SOL Page 133 Tuesday, March 8, 2005 1:57 PM134 Appendix A Solutions to Common Problems and Customer Support Calling AppleCare Support Included in your LiveType package is documentation about the support options available from Apple. Several levels of support are available, depending on your needs. Note: There are certain support situations in which AppleCare may require information about both your computer and how this particular application is configured. Choosing Help > Create Support Profile creates a file that contains the necessary information and can be emailed to AppleCare. You would not normally use this feature unless directed to by an AppleCare representative. Whatever your issue, it’s a good idea to have the following information immediately available. The more of this information you have ready to give to the support agents, the faster they will be able to address your issue.  The Support ID number that came with Final Cut Pro. This number is different from the software serial number that is used to activate your copy of LiveType.  Which version of Mac OS X you have installed. This information is available by choosing About This Mac from the Apple menu.  The version of LiveType you have installed, including updates if applicable. The version number can be viewed by choosing LiveType > About LiveType.  The model of computer you are using  How much RAM is installed in your computer, and how much is available to LiveType. You can find out how much RAM is installed by choosing About This Mac from the Apple menu in the Finder.  What other third-party hardware is connected to or installed in the computer, and who are the manufacturers. Include hard disks, video cards, and so on.  Any third-party plug-ins or other software installed along with LiveType AppleCare Support can be reached online at http://www.apple.com/support/livetype/ index.html. 135 B Appendix B Creating and Editing EffectScripts Effects in LiveType are based on the EffectScript language. Effects consist of a plain text file and a representative QuickTime movie, which appears in the Media Browser in the LiveType interface. Each line of an EffectScript consists of a command followed by a set of command arguments. Tabs and spaces are skipped. In any command, two hyphens (--) can be followed by a comment. Comments are ignored by the EffectScript interpreter. Header The following header commands should appear at the beginning of each EffectScript. EffectScript 1.0  Use 1.0. as the EffectScript specification version number. Name "effect name"  Name the effect. Quotation marks can be any non-space delimiter (", ', /, and so on). Desc "description"  Describe the effect. The description may be a long string; the text wraps when displayed. Default Timing After the header, an EffectScript should have default timing settings. DefOffset a b c  a is a numeric value.  b is %, Seconds, or Frames.  c is Start or End. DefReverse a  a is 0 for forward, or 1 for reverse.136 Appendix B Creating and Editing EffectScripts DefSequence a b c  a is 0 for Off or 1 for On.  b is a numeric % value, may be floating point.  c is L for left first, or R for right first. DefRandStart a b c  a is 0 for Off or 1 for On.  b is a numeric value, may be floating point.  c is %, Seconds, or Frames. DefLoop a  a is a numeric value, must be an integer (use a large number like 9999 to loop forever). DefSpeed a  a is a numeric % value, may be floating point. Keyframes After the header, an EffectScript defines a number of keyframes. A keyframe starts with a Time command: Time t  t is the time of the keyframe in seconds. Each Time command is followed by parameter commands. For example, here is a keyframe: Time 0.0 Scale 50 Track -50 This keyframe means that at time Zero seconds, each glyph scales by 50 percent, and its tracking decreases by 50 percent. The first keyframe must be at time 0.0, and there must be at least one other keyframe after that. All keyframes must be listed in order. All keyframes in a given effect should have the same set of parameter commands. The following parameter commands are valid in a keyframe: Accelerate n  n is a percentage of acceleration. This affects how all the other keyframe parameter values are interpolated between this keyframe and the next. 0 means no acceleration, 100% means speed up, -100% means slow down.Appendix B Creating and Editing EffectScripts 137 Blur x [y]  x is the blur radius in pixels. If y is given, then the horizontal and vertical blur amounts are distinct. CanvasOffset x y  x and y are the horizontal and vertical offsets, in percentage of the Canvas dimensions. This is the parameter used for scrolls and crawls. Color r g b [n]  r, g, and b are color values, in [0..255].  n is optional, and is an opacity percentage. DoExtrude x  x is 0 for no extrusion, 1 for extrude. DoGlow n  n is 0 for No or 1 for Yes. DoShadow n  n is 0 for No or 1 for Yes. ExtrudeDirection n  n is an angle in degrees, 0 for up, 90 for right, and so on. ExtrudeLength n  n is the extrusion length in pixels. ExtrudeColor r g b  r, g, and b are the extrusion color, in [0..255]. ExtrudeOutline n  n is 0 for no outline, 1 to outline the extrusion. GlowBlur n  n is the glow blur radius in pixels. GlowColor r g b  r, g, and b are the glow color, in [0..255]. GlowLayer n  n is 0 for behind all, 1 is behind track, 2 is in front, 3 is in front matted to glyph. GlowOffset x y  x and y are the glow offsets in pixels. GlowOpacity n  n is the glow opacity percentage.138 Appendix B Creating and Editing EffectScripts GlowScale x y  x and y are the glow scale percentages. GlowWarp x1 y1 x2 y2 x3 y3 x4 y4  x, y pairs are the four Warp points. HideChar n  n is 0 for Show the glyph in addition to lighting effects (Outline, Shadow, Glow, Extrude), or 1 to Hide it. HSL h s l  h is the hue angle adjustment in degrees; 0 means no change.  s is the saturation adjustment in percent; 0 means no change.  l is the lightness adjustment in percent; 0 means no change. Leading n  n is a % that adjusts the position of the next line in the track (for example, use 0 to put the next line on top of this one, 100 to leave it unchanged, or 200 to double it). Matte n  n is 0 or 1 for Off or On. Offset x y  x and y are the horizontal and vertical offsets, in pixels. Opacity n  n is the opacity percentage. This is multiplied by the glyph’s opacity. Outline n  n is the pixel width of the outline. Rotate n  n is the rotation angle, in clockwise degrees. Scale x y  x and y are the horizontal and vertical scale percent multipliers. Scaling is done about the glyph pivot point. SetOutlineColor r g b  r, g, and b are the outline color, in [0..255]. SetOutlineBlur n  n is a number of pixels. SetOutlineOnly n  n is 0 for No or 1 for Yes.Appendix B Creating and Editing EffectScripts 139 SetOutlineWarp x1 y1 x2 y2 x3 y3 x4 y4  x, y pairs are the four Warp points. ShadBlur n  n is the shadow blur radius in pixels. ShadColor r g b  r, g, and b are the shadow color, in [0..255]. ShadLayer n  n is 0 for behind all, 1 for behind track, 2 for in front, 3 for in front matted to glyph. ShadOffset x y  x and y are the shadow offsets in pixels. ShadOpacity n  n is the shadow opacity percentage. ShadScale x y  x and y are the shadow scale percentages. ShadWarp x1 y1 x2 y2 x3 y3 x4 y4  x, y pairs are the four Warp points. Size n  n is percent modifier for the glyph size. This affects not only the size of the glyph but also the leading and tracking, which are based on the size. Glyphs are sized about the glyph center on the baseline. Slide n  n is the amount an element slides along its track, in percent of the track’s length. Tracking n  n is a % that adjusts the position of the next glyph (for example, use 0 to put the next glyph on top of this one, 100 to leave it unchanged, or 200 to double it).140 Appendix B Creating and Editing EffectScripts Sample EffectScripts You can view an EffectScript simply by opening one of the effect files stored in the /Library/Application Support/LiveType/Effects folder of your hard drive. Some simple EffectScripts follow: Zoom In EffectScript 1.0 -------------------------------------------------------------------- -- "Zoom In" example Name "Zoom In" Desc "Zoom In each glyph linearly from zero to normal from its anchor point. Simultaneously increase the kerning from zero to normal." DefOffset 0 % Start DefSequence 0 0 L DefRandStart 0 0 % DefLoop 1 DefSpeed 100 Time 0.0 Tracking -100 -- -100% tracking, means zero tracking. Scale 0 0 -- 0% scale Time 2.0 Tracking 0 -- 0% tracking, means normal. Scale 100 100 -- 100% scale. -------------------------------------------------------------------- Zoom Out EffectScript 1.0 -------------------------------------------------------------------- -- "Zoom Out" example Name "Zoom Out" Desc "Zoom Out each glyph linearly from normal to zero from its anchor point. Simultaneously decrease the kerning from normal to zero." DefOffset 0 % End DefSequence 0 0 L DefRandStart 0 0 % DefLoop 1 DefSpeed 105 Time 0.0 Tracking 0 Scale 100 100 Time 2.0 Tracking -100 Scale 0 0 --------------------------------------------------------------------Appendix B Creating and Editing EffectScripts 141 Tinted Rotate EffectScript 1.0 -------------------------------------------------------------------- -- "Tinted Rotate" example Name "Tinted Rotate" Desc "Rotate each glyph around its anchor point at 1 rev/sec. For fun, simultaneously mess around with the color" DefOffset 0 % Start DefSequence 0 0 L DefRandStart 1 100 % -- note large loopCount so that it will loop through the whole duration. DefLoop 9999 DefSpeed 100 Time 0 Color 255 0 0 -- Tint Red (R=255, G=0, B=0) Rotate 0 Time 1 Color 0 255 0 -- Tint Green (R=0, G=255, B=0) Rotate 120 Time 2 Color 0 0 255 -- Tint Blur (R=0, G=0, B=255) Rotate 240 Time 3 Color 255 0 0 -- Tint Red (R=255, G=0, B=0) Rotate 0 -------------------------------------------------------------------- 143 Glossary Glossary 16:9 A widescreen aspect ratio for video. The ratio of the width to the height of the visible area of the video frame, also called the picture aspect ratio, is 16:9, or 1.78. alpha channel An additional image channel used to store transparency information for compositing. Alpha channels are often 8-bit, but some applications support 16-bit alpha channels. Only certain formats, such as PICT and the QuickTime Animation codec, support alpha channels. aspect ratio A video frame’s width-to-height ratio on your viewing screen. The most common aspect ratio is 4:3, used for common television screens. AVI Acronym for Audio-Video Interleaved, Microsoft’s standard format for digital video. Bezier handles Two-direction handles that control or influence the curve of the line segment between the handle and the next point on either side. The farther a direction handle is pulled out from its vertex point, the more force it applies to its line segment to bend or curve it. Direction handles are moved by dragging them. bin In Final Cut Pro, the window that contains your clips, transitions, effects, and generators. The bin lets you organize all of these elements, sort them, add comments, rename items, and so on. Canvas One of the four main windows in the LiveType interface, where you position text and objects, create motion paths, and view the results as you design. channels May refer to color channels or alpha channels. Color and transparency information for video and graphics clips is divided into individual channels. CMYK Abbreviation for Cyan Magenta Yellow Black. The color space commonly used for images that will be printed with 4-color ink on offset presses. codec Short for compressor/decompressor. A software component used to translate video or audio between its uncompressed form and the compressed form in which it is stored. Sorenson Video and Cinepak are common QuickTime video codecs. Also referred to as a compressor.144 Glossary compositing The process of combining two or more video or electronic images into a single frame. This term can also describe the process of creating various video effects. compression The process by which video, graphics, and audio files are reduced in size by the removal of redundant or less important data. See also codec. decompression The process of creating a viewable image for playback from a compressed video, graphics, or audio file. digital A description of data that is stored or transmitted as a sequence of ones and zeros. Most commonly, this means binary data represented using electronic or electromagnetic signals. QuickTime movie files are digital. digital video Refers to the capturing, manipulation, and storage of video using a digital format, such as QuickTime. A digital video camcorder, for example, is a videocamera that captures and stores images on a digital medium such as DV. Video can then be easily imported. duration The length of time that a track or effect exists in the Timeline. DVD A DVD disc looks much like a CD-ROM or audio disc, but uses higher density storage methods to significantly increase its capacity. effect In LiveType, a set of attribute and timing parameters that animate an element. element In LiveType, anything that is placed on a track: an individual character, a block of text on a single track, an object, a movie, a texture, or an image. field Half of an interlaced video frame consisting of the odd or the even scan lines. Alternating video fields are drawn every 1/60th of a second in NTSC video to create the perceived 30 frames per second video. There are two fields for every frame, an upper field and a lower field. FireWire The Apple trademark name for the IEEE 1394 standard. FireWire is a fast and versatile interface used to connect DV cameras to computers. FireWire is well suited to applications that move large amounts of data, and can also be used to connect hard disks, scanners, and other kinds of computer peripherals. font A complete set of a single typeface. See also LiveFont. frame Video consists of a number of still-image frames which, when they play back over time, give the illusion of motion. NTSC video plays back 29.97 frames per second, and PAL video plays back 25 frames per second. Each broadcast video frame is made up of two fields, which is different from the way film handles frames. A film frame is a single photographic image, and does not have separate fields. glyph A single character on a track. A glyph frequently refers to a letter or symbol, but an object, texture, or imported element can also be referred to as a glyph in LiveType.Glossary 145 importing The process of bringing files of various types into a project in LiveType. Imported files have usually been created or captured in another application. Inspector One of the four main windows in the LiveType interface, which is used to insert text and apply attributes, styles, and effect parameters to titling elements. keyframe A special-purpose marker that denotes a value change of one or more parameters in an applied effect. When two keyframes are set in LiveType, the application calculates a smooth transition based on their values. LiveFont LiveFonts are sets of 32-bit characters. Most LiveFonts are computer-based animations. However, they may also be composed of video footage or still photographs. LiveType media The collective term for LiveFonts, textures, and objects in LiveType, all of which are built using the 32-bit .afd format for animated fonts. markers In Final Cut Pro, markers refer either to the edit points that define the Start and End points of a clip, or to points of reference you can use to denote places of interest in your clips and sequences. Media Browser One of the four main windows in the LiveType interface, which is used for selecting fonts, objects, textures, and effects. NTSC format NTSC stands for National Television Standards Committee, the organization that defines North American broadcast standards. The term “NTSC video” refers to the video standard defined by the committee, which has a specifically limited color gamut, is interlaced, and is approximately 720 x 480 pixels, 29.97 frames per second. object In LiveType, objects are single 32-bit elements. Like LiveFonts, they may be computer-based animations, real-world video, or still photographs, as well as other elements such as lower thirds. PAL format Acronym for Phase Alternating Line format. A 25 fps (625 lines per frame) interlaced video format used by many European countries. PICT A still-image file format developed by Apple. PICT files can contain both vector images and bitmap images, as well as text and an alpha channel. PICT is a ubiquitous image format on Mac OS computers. pixel One dot in a video or still image. A typical low-resolution computer screen is 640 pixels wide and 480 pixels tall. Digital video movies are often 320 pixels wide and 240 pixels tall. pixel aspect ratio The ratio of width to height for the pixels that compose the image. NTSC pixels are square (1:1 ratio), but D-1 pixels are nonsquare.146 Glossary postproduction The process of editing film or video after acquiring the footage. QuickTime The Apple cross-platform multimedia technology. Widely used for CD-ROM, web video, editing, and more. RAID Acronym for Redundant Array of Independent Disks. A method of providing nonlinear editors with many gigabytes of high-performance data storage by teaming together a group of slower, smaller, cheaper hard disks. RAM Acronym for random-access memory. Your computer’s memory capacity, measured in bytes, which determines the amount of data the computer can process and temporarily store at any moment. render In LiveType, the process of combining project elements with any applied effects, one frame at a time. Once rendered, your titling sequence can be played in real time. RGB Abbreviation for Red Green Blue. A color space commonly used on computers. Each color is described by the strength of its red, green, and blue components. This color space directly translates to the red, green, and blue phosphors used in computer monitors. The RGB color space has a very large gamut, meaning it can reproduce a very wide range of colors. SECAM Acronym for Sequential Couleur Avec Memoire. The French television standard for playback. Similar to PAL, the playback rate is 25 fps. sequencing An effect treatment in which each glyph on a track is transformed individually. A sequenced effect starts by transforming one character, then moves to the adjacent character, and so on. texture In LiveType, textures are full-screen animations, useful as backgrounds, texture mattes, or borders. TIFF Acronym for Tagged Image File Format. A widely used bitmapped graphics file format, developed by Aldus and Microsoft, that handles monochrome, grayscale, 8- and 24-bit color. timecode A method of associating each frame of film or video in a clip with a unique, sequential unit of time. The format is hours:minutes:seconds:frames. Timeline One of the four main windows in the LiveType interface, which shows the timing of project elements and the effects applied to them. title safe area The part of the video image that is guaranteed to be visible on all televisions. The title safe area is 80 percent of the screen.Glossary 147 track In LiveType, a track is what contains an element and its attributes. In the Canvas, a track appears as a dark blue line, usually at the base of the text, object, or image it contains. A track can be shaped to form a motion path for the track’s contents to move along. In the Timeline, a track is represented by a numbered bar, often with applied effects underlying it. widescreen Widescreen format is a way of shooting and projecting a movie in theaters. The original footage doesn’t get cut off because of the 4:3 aspect ratio. With the advent of high definition video, widescreen 16:9 video is coming into more popular use. wireframe The most elementary preview mode in LiveType, representing characters and objects as bounding boxes. Wireframe previews are useful because they render very quickly, showing the motion of elements. x Used to refer to the x coordinate in Cartesian geometry. The x coordinate describes horizontal placement. y Used to refer to the y coordinate in Cartesian geometry. The y coordinate describes vertical placement in motion effects. 149 Index Index 16:9 aspect ratio 143 A action safe guidelines 15 active parameters 97 Active Parameters window 94 .afd extension 111 .afp extension 111 aligning text tracks 63 alpha channels 7, 64, 80, 143 Alpha pop-up menu 64 angles, track 49 animation importing files 82 keyframes and 94 segmented LiveFont animation 61 types of animated items 8 Animation codec 114, 115 Apple Applications website 133 AppleCare Knowledge Base 131 AppleCare Support 131, 134 Apple Developer Connection website 133 Apple Store 12 Apple websites 11–12, 131, 133 aspect ratio 132, 143 attributes assigning 24 digital images 85 imported elements 85 movies 85 objects 85 tracks 133 Attributes tab 24, 64 AVI format 43, 82, 115, 143 B background bar 27, 43 background movies 43–45 backgrounds 41–45 adding 41–45 color 37, 41, 43 importing images for 44 overview 14–15 purpose of 41 rendering 37, 45 revealing in mattes 72 settings 37 textured 42 transparent 73–74 banners, web 35 baselines of text 66 Bezier handles 50, 143 bins 143 blur attributes 24 non-text elements 85 settings 66 text elements 69 BMP codec 115 BMP format 43, 82, 115 C Canvas 14–19 adding objects to 80 adding text to 58 adding textures to 81 adjusting keyframes in 96 background. See backgrounds color 37 customizing 17–19 described 13, 14, 143 grids 18 guides 18 illustrated 13, 14 isolating tracks in 19 positioning tracks in 48 RAM preview in 110 rulers 17 transport controls 16 using tracks in 15, 147 zoom controls 16 Canvas Offset parameter 128 categories Media Browser 30 preset effects 88 channels 143150 Index Character Palette 123 characters assigning effects to 106 character sets 60 elements as 84 locked 133 modifying individual characters 77–78 motion paths 96 problems selecting 133 removing effects from 90 spacing 63 special character effects 123–126 squashed 132 style settings 68 character sets 60 Cinepak codec 115 clips, importing 43 CMYK color space 143 codecs described 143 exporting movies and 114 QuickTime 115, 143 color attributes 24 background 37, 41, 43 Canvas 37 CMYK 143 extrude settings 71 glow or shadows 69 imported images 85 RGB 146 text 64–65 Color parameter 64 color space 143, 146 Component Video codec 115 compositing 144 compression 144 compressors. See codecs control points 15, 49–51 copying items effects 93, 101 keyframes 101 tracks 52, 101 crawling text 129 crosshair guides 18 curved tracks 50–51, 121–123 D data, digital 144 data files 30 decompression 144 delaying items effects 91 LiveFonts effects 61 track contents 54 Delay slider 54 deleting items keyframes 100 tracks 52 description field 36 digital data 144 digital images 85 See also images digital video 144 direction of extrusions 71 draft quality 112 duplicating items effects 93, 101 keyframes 101 strings of elements 84 tracks 101 duration described 144 effects 89, 91, 92 tracks 54 DV codec 115 DV format 43, 82 DV Stream format 115 DVCPRO-NTSC codec 115 DVCPRO-PAL codec 115 DVD discs 144 E editing LiveType movies in Final Cut Pro 114 effects adding keyframes to 101 adjusting timing 90–92 applying to tracks 88–89 considerations 87 copying keyframes in 101 creating custom 103–106 described 22, 87, 135, 144 disabling 28, 55, 89, 113 duplicating 93 duration of 144 effects files 28 examples of 98–100 finding 107 groups of 92 using individual characters or glyphs 106 list of 88 in LiveType 8 modifying 93–100 order of 93 preset. See preset effects previewing 89, 102 renaming 102 saving 102 sequenced 146 storing 29, 140Index 151 in Timeline 27 timing settings 23, 90–92 EffectScripts 135–141 Effects folder 29, 140 Effects tab 22, 87 elements See also objects creating strings of 84–85 described 144 imported. See imported elements locked 133 problems selecting 133 repositioning 83 resizing 83 rotating 66–67, 83 types of 8 Enable/Disable buttons 28 endpoints linking 51 tracks 15 exploding fonts 126 exporting items 113, 114, 115–116 extruded outlines 71 Extrude style 22, 71, 85 F Fade In effect 98–100 FAQs (frequently asked questions) 131–133 Field Dominance option 36 fields described 144 description field 36 rendering order 36, 38–39 "file pair" formats 29 files data 30 effects files 135 imported 30 included with LiveType 28 project files 32 support profiles 134 file sizes 113, 123 filling elements. See matte feature Final Cut Pro editing LiveType movies from 114 importing LiveType movies 113 rendering LiveType projects in 113 finding items using the Timeline 107 FireWire 144 FLC format 115 folders 29–30 FontBook application 78 Font dialog 124 FontMaker utility 8 fonts See also text animated 8 changing for text tracks 59 choosing 58 color 64–65 described 144 disabling 78 problems with 131 required fonts 78 system 59, 60, 65 formats See also specific formats export 115–116 import 43, 82 formatting text 62–71 frame rates 35 frame ruler 26 frames See also keyframes described 144 poster frames 111 proxy frames 19, 111 time settings 36 viewing in Timeline 26 freezing previews 109 frequently asked questions (FAQs) 131–133 G GIF format 35, 43, 82 Glow style 22, 68–69, 85, 119–121, 132 Glyph pane 64–67 glyphs 132, 144 assigning effects to 106 color 64–65 elements as 84 modifying individual glyphs 77–78 motion paths 96 removing effects from 90 special character effects 123–126 transformation options 65–67 graphics. See images Graphics codec 115 grid customizing 18 hiding 37 settings 18, 37 showing 17, 37 grouping items effects 92 tracks 27, 56 guides, Canvas 18 H H.261 and 263 codecs 115 handles on objects 79152 Index hardware field rendering and 38 noting for support calls 134 headers in EffectScripts 135 height settings for GIFs 35 help, onscreen 10–11 Heuris MPEG format 115 hidden elements 76 hidden keyframes 132 high quality 112 Hold First and Hold Last options 61, 92 holes in layers. See matte feature hot keys 28 HSL (Hue, Saturation, and Lightness) 64 Hue values 64 I IEEE 1394 (FireWire) 144 images background 44 digital 85 filling track contents with 75 finding 107 importing 44, 82 pixelated 131 still 44 storing 30 Images folder 30 imported elements See also elements creating strings of 84–85 resizing 83 size considerations 113 system performance and 113 transforming 83–85 importing items background images 44 background movies 43–45 data files 30 described 145 LiveType projects into Final Cut Pro 113 formats for 43, 82 images 44, 82 movies 43–45, 82 still images 44 into third-party applications 114 In Point/Out Point markers 27 Inspector 20–24 described 13, 20, 145 formatting options 62 illustrated 13, 20 LEDs in 96 Live Wireframe Preview 21 tabs in 21–24 text-entry boxes 20, 58 Intel Indeo Video r3.2 format 115 Intel Raw codec 115 interlaced video 36 invisible elements 76 invisible keyframes 132 .ipr extension 32 J JPEG 2000 Image format 115 JPEG format 43, 82, 115 K keyboard shortcuts 28 Keyboard Viewer 60 Key Cap utility. See Keyboard Viewer keyframes 94–96 adding to effects 101 adjusting parameters 95–96 copying 101 deleting 100 described 27, 145 EffectScripts 136–139 hidden 132 modifying all keyframes 96 moving 100 overview 94 rotation and 66 “stuck” 132 viewing parameters 94 L layers advanced techniques 126–127 assigning to treatments 68 holes in. See matte feature track 55 leading, text 63 LEDs, Inspector 96 length of extrusions 71 Lightness values 64 linking endpoints 51 LiveFonts adjusting timing 60–61 advanced techniques 126–127 character sets 60 described 8, 145 vs. system fonts 59 LiveFonts folder 29 LiveType effects files 28 introduction to 7–12 media files 28, 145 onscreen help 10–11 restoring default layout of 14 unable to open 132Index 153 website 11 LiveType projects. See projects Live Wireframe Preview 20, 21, 109, 132, 147 locked items characters 133 elements 133 movies 83 textures 83 tracks 27 Loop button 110 looping items effects 92 LiveFonts effects 61 .ltfx extension 29 .ltlf extension 29 .ltob extension 29 .lttm extension 29 .lttx extension 29 M Mac OS, version of 134 MacPaint format 115 magnifying view. See zoom controls mailing lists for Pro Apps Developers 133 markers described 145 In Point 27 Out Point 27 Render Selection 27, 113 sequencing 94–96 timing 45 matte feature 24, 72–76, 85, 117–119 Media Browser categories in 30 described 13, 25, 145 media files in 29 media files described 145 importing 30 included with LiveType 28 older versions of 29 memory 113, 134, 146 Missing AFD dialog 111 Motion JPEGA and JPEGB codecs 115 motion paths adding to effects 104 described 96 scrolling or crawling text 128 unsmooth 132 movies See also titling movies attributes 85 background 43–45 filling track contents with 75 finding using the Timeline 107 importing 43–45, 82 looping through 110 output quality 112 preview. See preview movies rendering 114–116 styles 85 unlocking position of 83 moving items grouped tracks 56 groups of effects 92 MPEG-2 format 43, 82, 115 MPEG-4 format 43, 82, 102, 115 N names of modified effects 102 Needle Drop effect 119–121 Nitro LiveFont 126 normal quality 112 NTSC format 145 NTSC monitors 132 NTSC pixels 132 NTSC video 144, 145 O objects See also elements adding to Canvas 80 animated 8 attributes 85 creating strings of 84–85 described 8, 145 resizing 83 storing 29 styles 85 transforming 83–85 treatments 22 working with 80 Objects folder 29 Objects tab 80 offsetting items attributes for 24 Canvas Offset parameter 128 glow or shadows 69 non-text elements 85 text 66 opacity attributes 24 backgrounds 41 glow or shadows 69 mattes. See matte feature rendering backgrounds and 45 transparent text 65 order of effects 93 Outline extrusion option 71 Outline style 22, 70–71, 85154 Index P PAL format 145 PAL video 144 Parameter pop-up menu 97 parameters active parameters 97 of keyframes 94 LED indicators 96 Particles objects 19 pausing previews 110 performance, preview 112–113, 133 PhotoJPEG codec 115 Photoshop format 43, 82, 115 PICS format 43, 82 PICT files 145 PICT format 43, 82, 115, 145 picture aspect ratio 143 pixel aspect ratio 36, 145 pixelated images 131 pixels 36, 132, 145 Planar RGB codec 115 playhead 26 PLS format 43, 82 PNG codec 115 PNG format 44, 82, 115 poster frames 111 postproduction process 146 precedence order of effects 93 Preferences dialog 29 preset effects See also effects applying to tracks 88–89 disabling 89 for individual characters or glyphs 106 list of 88 modifying 93–102 order of 93 previewing 89 timing settings 90–92 presets, project 35 previewing items effects 102 freezing previews 109 Live Wireframe Preview 20 pausing previews 110 preset effects 89 RAM preview 17, 37, 110 titling movies 109–111 Wireframe previews 21, 37, 109, 132, 147 preview movies described 111 quality of 112 rendering 111 saving 111 preview performance 112–113, 133 Project Properties dialog 34–37, 112 projects backgrounds. See backgrounds defaults 33 presets for 35 properties 31, 34–37 quality settings 36 rendering 114–116 rendering in Final Cut Pro 113 saving as templates 32 setting up 31–37 starting 33 timing in. See timing settings project tabs, Timeline 26 properties, project 31, 34–37, 112 proxy frames 19, 111 Q quality settings 36 QuickTime codecs 115, 143 described 146 effects and 102 preview clips and 102 QuickTime image format 44, 82, 115 QuickTime movie format 44, 82, 114 R RAID storage 146 RAM 113, 146 RAM preview 17, 37, 110 Random option for effects 91 for LiveFonts effects 61 removing guides 18 Render Background setting 37 rendering 114–116 backgrounds 37, 45 changing selection 27 described 146 field rendering order 36, 38–39 in Final Cut Pro 113 improving speed of 113 preview movies 111 quality of 112 quality settings 37 settings for 112 time requirements 112 Render Selection markers 27, 113 reordering effects 93 replacing elements in tracks 85 resources Apple websites ??–12 for troubleshooting 131 restoring character positions 78Index 155 Reveal in Finder command 107 Reveal in Media Browser command 107 RGB color space 146 ripple drags 54 rotating items attributes for 24 EffectScript for 141 non-text elements 85 nontext elements 83 text 66–67, 77 rotation handles 79 rulers hiding 37 settings 37 showing 17, 37 S Saturation values 64 saving modified effects 102 scale handles 79 Scale parameter 66 scaling items attributes for 24 glow or shadow effects 69 non-text elements 85 non-text items 83 text elements 66 Screech effect 121 scripts (EffectScripts) 135–141 scrolling text 128 searching for items using the Timeline 107 SECAM format 146 segmented LiveFont animation 61 sequenced effects 61, 91, 146 sequencing markers 94–96 SGI format 44, 82, 115 Shadow style 22, 68–69, 85, 119–121, 132 shortcuts 28 Show Outline only setting 70 Size parameter 66 Slide effect 121 Slide parameter 51 SMPTE Drop time setting 36 SMPTE time format 36 Sorenson Video and Video 3 codecs 115 source files 30 spacing in text 63 speed adjusting for track contents 54 of effects 91 LiveFont movies 61 square pixels 132 still images 44 styles digital images 85 imported elements 85 movies 85 objects 85 text 68–71, 119–121 Style tab 22, 68–71 support profiles 134 symbols 123–126 system fonts changing color of 65 described 59 duration of 60 vs. LiveFonts 59 in scrolling or crawling text 128 T Targa format 44, 82 Template Browser 32 templates 31–32 described 9 opening 32 saving projects as 32 storing 29 Templates folder 29 terminology 143–147 testing field rendering 38 text 57–78 aligning 63 baselines 66 color 64–65 entering and adjusting 21, 58 extrusion effect 71 fonts. See fonts formatting 62–71 glow effect 68–69, 119–121 inserting 57–59 leading 63 matte effect 24, 72–76, 117–119 modifying characters 77–78 outline effect 70–71 rotating 66–67, 77 scrolls and crawls 128–129 shadow effect 68–69, 119–121 size of 63, 66 special characters 123–126 styles 68–71, 119–121 tracking 63 transforming 65–67 treatments 22 warping 69, 119–121 words within words effect 117–119 text-entry boxes 20, 58 Text tab 21, 62 text tracks aligning 63 changing fonts 59156 Index curved 121–123 modifying characters on 77–78 text in 57 textures adding to Canvas 81 animated 8 background 42 creating strings of 84–85 described 8, 146 filling track contents with 76 resizing 83 storing 29 transforming 83–85 unlocking position of 83 working with 81 Textures folder 29 Textures tab 81 TGA codec 115 TGA format 115 third-party applications 114 TIFF codec 115 TIFF format 44, 82, 146 timecode 26, 146 Timeline 26–28 background bar 43 described 13, 26, 146 effects in 27 illustrated 13, 26 moving keyframes in 100 playhead 26 project tabs 26 searching for items with 107 timecode 26 viewing frames in 26 working with tracks in 27, 53–56, 147 Timeline zoom slider 28 timing markers 45 timing settings controlling 23 effects 90–92 EffectScripts 135–136 LiveFonts 60–61 start time 36 time format 36 in Timing tab 61 Timing tab 23, 61, 90–92 Tinted Rotate EffectScript 141 title safe area 15, 146 title safe guidelines 15 titling movies See also movies creation workflow 9 previewing 109–111 rendering 114–116 titling process 7, 8 tracking options for text 63 tracks 47–56 adding 52 applying preset effects to 88–89 attributes 95, 133 control points 49–51 creating strings of elements on 84–85 curved 50–51, 121–123 delaying appearance 54 deleting 52 described 15, 47, 147 disabled 28, 55, 113 duplicating 52 duplicating effects in 93 duration 54, 144 empty 52 endpoints 15 entering text onto 58 filling with images 75 filling with movies 75 filling with texture 76 grouping 27, 56 groups of effects in 92 illustrated 48 isolating in Canvas 19 layers 55 linking endpoints 51 locking position 27 moving 48, 54 numbering 27 rendering previews 113 reordering 55 replacing elements in 85 resizing 48 selecting 62 shape of 48 sloping 48 text. See text tracks timing 23, 53–54 turning on/off 28 ungrouping 56 working with in Canvas 15, 147 working with in Timeline 147, 53–56 transforming items imported elements 83–85 text 65–67 transparency backgrounds 41 rendering and 45 text 65 transparent backgrounds 73–74 transport controls 16 troubleshooting 131–134 common problems 131–133 disabling fonts 78 distorted field rendering 38 LiveFonts in large text sizes 63Index 157 positions of matte and background images 75 resources for 131 scrolling or crawling text 128 U ungrouping tracks 56 V video digital 144 interlaced 36 NTSC 144 PAL 144 Video codec 115 W warping items 69, 119–121 web banners 35 websites Apple Applications 133 AppleCare 131, 134 Apple Developer Connection 133 Apple Service and Support 11 Apple Store 12 FireWire 12 LiveType 11 weight of outlined text 70 widescreen format 147 width of GIF images 35 Wireframe previews 21, 37, 109, 132, 147 words within words effect 117 workflows, title creation 9 X x coordinate 147 Y y coordinate 147 Z zoom controls in Canvas 16 EffectScripts for 140 Timeline zoom slider 28 Zoom In EffectScript 140 Zoom Out EffectScript 140 iPod nano User Guide2 2 Contents Preface 4 About iPod nano Chapter 1 6 iPod nano Basics 6 iPod nano at a Glance 7 Using iPod nano Controls 11 Using iPod nano Menus 13 Disabling iPod nano Controls 14 Connecting and Disconnecting iPod nano 17 About the iPod nano Battery Chapter 2 20 Setting Up iPod nano 20 Using iTunes 21 Importing Music into Your iTunes Library 24 Organizing Your Music 25 Using Genius in iTunes 26 Purchasing or Renting Videos and Downloading Video Podcasts 27 Adding Music to iPod nano 31 Adding Videos to iPod nano Chapter 3 34 Listening to Music 34 Playing Music and Other Audio 38 Using Genius on iPod nano 39 Setting iPod nano to Shuffle Songs 42 Watching and Listening to Podcasts 43 Listening to Audiobooks 43 Listening to FM Radio Chapter 4 44 Watching Videos 44 Watching and Listening to Videos on iPod nano 45 Watching Videos on a TV Connected to iPod nano Chapter 5 47 Photo Features 47 Importing PhotosContents 3 50 Viewing Photos Chapter 6 53 More Settings, Extra Features, and Accessories 53 Using iPod nano as an External Disk 54 Using Extra Settings 58 Syncing Contacts, Calendars, and To-Do Lists 60 Storing and Reading Notes 60 Recording Voice Memos 61 Using Spoken Menus for Accessibility 62 Learning About iPod nano Accessories Chapter 7 64 Tips and Troubleshooting 64 General Suggestions 69 Updating and Restoring iPod Software Chapter 8 70 Safety and Cleaning 70 Important Safety Information 72 Important Handling Information Chapter 9 73 Learning More, Service, and Support Index 76Preface 4 About iPod nano Congratulations on choosing iPod nano. With iPod nano, you can take your music, video, and photo collections with you wherever you go. To use iPod nano, you put music, videos, photos, and other files on your computer and then add them to iPod nano. Read this guide to learn how to:  Set up iPod nano to play music, music videos, movies, TV shows, podcasts, audiobooks, and more.  Use iPod nano as your pocket photo album, portable hard drive, alarm clock, game console, and voice memo recorder.  View video and photo slideshows on your TV.  Get the most out of all the features in iPod nano.Preface About iPod nano 5 What’s New in iPod nano  Genius, which automatically creates playlists of songs from your library that go great together  A motion sensor that lets you control certain functions by rotating or shaking iPod nano  Full-screen photo viewing in portrait or landscape format  Quick browsing for songs based on the album or artist you’re listening to  Direct access to more options from the Now Playing screen  New voice recording options  Improved accessibility with spoken menus1 6 1 iPod nano Basics Read this chapter to learn about the features of iPod nano, how to use its controls, and more. iPod nano at a Glance Get to know the controls on iPod nano: Dock connector Menu Previous/Rewind Play/Pause Hold switch Headphones port Click Wheel Next/Fast-forward Center buttonChapter 1 iPod nano Basics 7 Using iPod nano Controls The controls on iPod nano are easy to find and use. Press any button to turn on iPod nano. The main menu appears. Use the Click Wheel and Center button to navigate through onscreen menus, play songs, change settings, and get information. Move your thumb lightly around the Click Wheel to select a menu item. To choose the item, press the Center button. To go back to the previous menu, press Menu on the Click Wheel. Here’s what else you can do with iPod nano controls. To Do this Turn on iPod nano Press any button. Turn off iPod nano Press and hold Play/Pause (’). Turn on the backlight Press any button or use the Click Wheel. Disable the iPod nano controls (so nothing happens if you press them accidentally) Slide the Hold switch to HOLD (an orange bar appears). Reset iPod nano (if it isn’t responding) Slide the Hold switch to HOLD and back again. Press the Menu and Center buttons at the same time for about 6 seconds, until the Apple logo appears. Choose a menu item Scroll to the item and press the Center button. Go back to the previous menu Press Menu. Go directly to the main menu Press and hold Menu. Browse for a song From the main menu, choose Music. Browse for a video From the main menu, choose Videos. Play a song or video Select the song or video and press the Center button or Play/Pause (’). iPod nano must be ejected from your computer to play songs and videos. Pause a song or video Press Play/Pause (’) or unplug your headphones. Change the volume From the Now Playing screen, use the Click Wheel.8 Chapter 1 iPod nano Basics Play all the songs in a playlist or album Select the playlist or album and press Play/Pause (’). Play all songs in random order From the main menu, choose Shuffle Songs. You can also shuffle songs by shaking iPod nano. Enable or disable Shake for shuffling songs Choose Settings > Playback, choose Shake, and then select Shuffle or Off. Skip to any point in a song or video From the Now Playing screen, press the Center button to show the scrubber bar (a diamond icon on the bar shows the current location), and then scroll to any point in the song or video. Skip to the next song or chapter in an audiobook or podcast Press Next/Fast-forward (‘). Start a song or video over Press Previous/Rewind (]). Play the previous song or chapter in an audiobook or podcast Press Previous/Rewind (]) twice. Fast-forward or rewind a song Press and hold Next/Fast-forward (‘) or Previous/Rewind (]). Create a Genius playlist Play or select a song, and then press and hold the Center button until a menu appears. Select Start Genius, and then press the Center button (Start Genius appears only if there is Genius data for the song). Save a Genius playlist Create a Genius playlist, select Save Playlist, and then press the Center button. Play a saved Genius playlist From the Playlist menu, select a Genius playlist, and then press Play/Pause (’). Add a song to the On-The-Go playlist Play or select a song, and then press and hold the Center button until a menu appears. Select “Add to On-The-Go,” and then press the Center button. Access additional options Press and hold the Center button until a menu appears. Find the iPod nano serial number From the main menu, choose Settings > About and press the Center button until you see the serial number, or look on the back of iPod nano. To Do thisChapter 1 iPod nano Basics 9 Browsing Music Using Cover Flow You can browse your music collection using Cover Flow, a visual way to flip through your library. Cover Flow displays your albums alphabetically by artist name. You can activate Cover Flow from the main menu, any music menu, or the Now Playing screen. To use Cover Flow: 1 Rotate iPod nano 90 degrees to the left or the right. Cover Flow appears. 2 Use the Click Wheel to move through your album art. 3 Select an album and press the Center button. 4 Use the Click Wheel to select a song, and then press the Center button to play it. You can also browse quickly through your albums in Cover Flow by moving your thumb quickly on the Click Wheel. Note: Not all languages are supported. To browse quickly in Cover Flow: 1 Move your thumb quickly on the Click Wheel, to display a letter of the alphabet on the screen. 2 Use the Click Wheel to navigate through the alphabet until you find the first letter of the artist you’re looking for.10 Chapter 1 iPod nano Basics Albums by various artists and by artists beginning with a symbol or number appear after the letter “Z.” 3 Lift your thumb momentarily to return to normal browsing. 4 Select an album and press the Center button. 5 Use the Click Wheel to select a song, and then press the Center button to play it. Scrolling Quickly Through Long Lists You can scroll quickly through a long list by moving your thumb quickly on the Click Wheel. Note: Not all languages are supported. To scroll quickly: 1 Move your thumb quickly on the Click Wheel, to display a letter of the alphabet on the screen. 2 Use the Click Wheel to navigate through the alphabet until you find the first letter of the item you’re looking for. Items beginning with a symbol or number appear after the letter “Z.” 3 Lift your thumb momentarily to return to normal scrolling. 4 Use the Click Wheel to navigate to the item you want. Searching Music You can search iPod nano for songs, playlists, album titles, artist names, audio podcasts, and audiobooks. The search feature doesn’t search videos, notes, calendar items, contacts, or lyrics. Note: Not all languages are supported. To search for music: 1 From the Music menu, choose Search. 2 Enter a search string by using the Click Wheel to navigate the alphabet and pressing the Center button to enter each character. iPod nano starts searching as soon as you enter the first character, displaying the results on the search screen. For example, if you enter “b,” iPod nano displays all music items containing the letter “b.” If you enter “ab,” iPod nano displays all items containing that sequence of letters. To enter a space, press the Next/Fast-forward button. To delete the previous character, press the Previous/Rewind button. 3 Press Menu to display the results list, which you can now navigate. Items appear in the results list with icons identifying their type: song, video, artist, album, audiobook, or podcast. Chapter 1 iPod nano Basics 11 To return to Search (if Search is highlighted in the menu), press the Center button. Using iPod nano Menus When you turn on iPod nano, you see the main menu. Choose menu items to perform functions or go to other menus. Icons along the top of the screen show iPod nano status. Adding or Removing Items on the Main Menu You might want to add often-used items to the iPod nano main menu. For example, you can add a Songs item to the main menu, so you don’t have to choose Music before you choose Songs. To add or remove items on the main menu: 1 Choose Settings > General > Main Menu. 2 Select each item you want to appear in the main menu. A checkmark indicates which items have been added. Display item Function Menu title Displays the title of the current menu. Lock icon The Lock icon appears when the Hold switch (on the top of iPod nano) is set to HOLD. This indicates that the iPod nano controls are disabled. Play icon The Play (“) icon appears when a song, video, or other item is playing. The Pause (1) icon appears when the item is paused. Battery icon The Battery icon shows the approximate remaining battery charge. Menu items Use the Click Wheel to scroll through menu items. Press the Center button to choose an item. An arrow next to a menu item indicates that choosing it leads to another menu or screen. Preview panel Displays album art, photos, and other items and information relating to the menu item selected. Menu title Lock icon Battery icon Menu items Preview panel Play icon12 Chapter 1 iPod nano Basics Turning Off the Preview Panel The preview panel at the bottom of the main menu, which displays album art, photo thumbnails, available storage, and other information, can be turned off to allow more space for menu items. To turn off the preview panel: m Choose Settings > General > Main Menu > Preview Panel and then choose Off. To turn the preview panel on again, choose Settings > General > Main Menu > Preview Panel, and then choose On. The preview panel only displays art for a category if iPod nano contains at least four items with art in the category. Setting the Font Size in Menus iPod nano can display text in two different sizes, standard and large. To set the font size: m Choose Settings > General > Font Size, and then press the Center button to select Standard or Large. Setting the Language iPod nano can be set to use different languages. To set the language: m Choose Settings > Language, and then choose a language from the list. Setting the Backlight Timer You can set the backlight to turn on and illuminate the screen for a certain amount of time when you press a button or use the Click Wheel. The default is 10 seconds. To set the backlight timer: m Choose Settings > General > Backlight Timer, and then choose the time you want. Choose “Always On” to prevent the backlight from turning off (choosing this option decreases battery performance). Setting the Screen Brightness You can adjust the brightness of the iPod nano screen by moving a slider. To set the screen brightness: m Choose Settings > General > Brightness, and then use the Click Wheel to move the slider. Moving it to the left dims the screen; moving it to the right increases the screen brightness. You can also set the brightness during a slideshow or video. Press the Center button to display or dismiss the brightness slider.Chapter 1 iPod nano Basics 13 Turning Off the Click Wheel Sound When you scroll through menu items, you can hear a clicking sound through the headphones and through the iPod nano internal speaker. If you like, you can turn off the Click Wheel sound through the headphones, the speaker, or both. To turn off the Click Wheel sound: m Choose Settings > General and set Clicker to Off. To turn the Click Wheel sound on again, set Clicker to Speaker, Headphones, or Both. Getting Information About iPod nano You can get details about your iPod nano, such as the amount of space available, the number of songs, videos, photos, and other items, and the serial number, model, and software version. To get information about iPod nano: m Choose Settings > About, and press the Center button to cycle through the screens of information. Resetting All Settings You can reset all the items on the Settings menu to their default setting. To reset all settings: m Choose Settings > Reset Settings, and then choose Reset. Disabling iPod nano Controls If you don’t want to turn iPod nano on or activate controls accidentally, you can disable them with the Hold switch. The Hold switch disables all Click Wheel controls, and also disables functions that are activated by movement, such as shaking to shuffle and rotating to enter or exit Cover Flow. To disable iPod nano controls: m Slide the Hold switch to HOLD (so you can see the orange bar).14 Chapter 1 iPod nano Basics If you disable the controls while using iPod nano, the song, playlist, podcast, or video that’s playing continues to play. To stop or pause, slide the Hold switch to enable the controls again. Connecting and Disconnecting iPod nano You connect iPod nano to your computer to add music, videos, photos, and files, and to charge the battery. Disconnect iPod nano when you’re done. Important: The battery doesn’t charge when your computer is in sleep mode. Connecting iPod nano To connect iPod nano to your computer: m Plug the included iPod Dock Connector to USB 2.0 cable into a high-powered USB 2.0 port on your computer, and then connect the other end to iPod nano. If you have an iPod Dock, you can connect the cable to a USB 2.0 port on your computer, connect the other end to the Dock, and then put iPod nano in the Dock. Note: The USB port on most keyboards doesn’t provide enough power. Connect iPod nano to a USB 2.0 port on your computer. By default, iTunes syncs songs on iPod nano automatically when you connect it to your computer. When iTunes is finished, you can disconnect iPod nano. You can sync songs while your battery is charging. If you connect iPod nano to a different computer and it’s set to sync music automatically, iTunes prompts you before syncing any music. If you click Yes, the songs and other audio files already on iPod nano will be erased and replaced with songs and other audio files on the computer iPod nano is connected to. For information about adding music to iPod nano and using iPod nano with more than one computer, see Chapter 2, “Setting Up iPod nano,” on page 20.Chapter 1 iPod nano Basics 15 Disconnecting iPod nano It’s important not to disconnect iPod nano while it’s syncing. You can see if it’s OK to disconnect iPod nano by looking at the iPod nano screen. Important: Don’t disconnect iPod nano if you see the “Connected” or “Synchronizing” messages. You could damage files on iPod nano. If you see one of these messages, you must eject iPod nano before disconnecting it. If you set iPod nano to manage songs manually (see “Managing iPod nano Manually” on page 29) or enable iPod nano for disk use (see “Using iPod nano as an External Disk” on page 53), you must always eject iPod nano before disconnecting it. If you see one of these messages, you must eject iPod nano before disconnecting it If you see the main menu or a large battery icon, you can disconnect iPod nano.16 Chapter 1 iPod nano Basics To eject iPod nano: m Click the Eject (C) button next to iPod nano in the list of devices in the iTunes source list. If you’re using a Mac, you can also eject iPod nano by dragging the iPod nano icon on the desktop to the Trash. If you’re using a Windows PC, you can also eject iPod nano in My Computer or by clicking the Safely Remove Hardware icon in the Windows system tray and selecting iPod nano. To disconnect iPod nano: 1 Unplug the headphones if they’re attached. 2 Disconnect the cable from iPod nano. If iPod nano is in the Dock, simply remove it. You can safely disconnect iPod nano while either of these messages is displayed.Chapter 1 iPod nano Basics 17 About the iPod nano Battery iPod nano has an internal, non-user-replaceable battery. For best results, the first time you use iPod nano, let it charge for about three hours or until the battery icon in the status area of the display shows that the battery is fully charged. If iPod nano isn’t used for a while, the battery might need to be charged. Note: iPod nano continues to use battery power after it’s been turned off. The iPod nano battery is 80-percent charged in about one and a half hours, and fully charged in about three hours. If you charge iPod nano while adding files, playing music, watching videos, or viewing a slideshow, it might take longer. Charging the iPod nano Battery You can charge the iPod nano battery in two ways:  Connect iPod nano to your computer.  Use the Apple USB Power Adapter, available separately. To charge the battery using your computer: m Connect iPod nano to a USB 2.0 port on your computer. The computer must be turned on and not in sleep mode. If the battery icon on the iPod nano screen shows the Charging screen, the battery is charging. If it shows the Charged screen, the battery is fully charged. If you don’t see the Charging screen, iPod nano might not be connected to a high-power USB port. Try another USB port on your computer. 18 Chapter 1 iPod nano Basics Important: If a “Charging, Please Wait” or “Connect to Power” message appears on the iPod nano screen, the battery needs to be charged before iPod nano can communicate with your computer. See“If iPod nano displays a “Connect to Power” message” on page 66. If you want to charge iPod nano when you’re away from your computer, you can purchase the Apple USB Power Adapter. To charge the battery using the Apple USB Power Adapter: 1 Connect the AC plug adapter to the power adapter (they might already be connected). 2 Connect the iPod Dock Connector to USB 2.0 cable to the power adapter, and plug the other end of the cable into iPod nano. 3 Plug the power adapter into a working electrical outlet. WARNING: Make sure the power adapter is fully assembled before plugging it into an electrical outlet. AC plug adapter (The plug on your Power Adapter may look different.) USB Power Adapter iPod Dock Connector to USB 2.0 CableChapter 1 iPod nano Basics 19 Understanding Battery States When iPod nano isn’t connected to a power source, a battery icon in the top-right corner of the iPod nano screen shows approximately how much charge is left. If iPod nano is connected to a power source, the battery icon changes to show that the battery is charging or fully charged. You can disconnect and use iPod nano before it’s fully charged. Note: Rechargeable batteries have a limited number of charge cycles and might eventually need to be replaced. Battery life and number of charge cycles vary by use and settings. For information, go to www.apple.com/batteries. Improving Battery Performance with Energy Saver Energy Saver can extend the time between battery charges by turning off the iPod nano screen when you aren’t using the controls. To turn Energy Saver on or off: m Choose Settings > Playback > Energy Saver, and then select On or Off. Battery less than 20% charged Battery about halfway charged Battery fully charged Battery charging (lightning bolt) Battery fully charged (plug)2 20 2 Setting Up iPod nano To set up iPod nano, you use iTunes on your computer to import, buy, and organize your music, video, podcasts, audiobooks, games, and other media content. Then you connect iPod nano to your computer and sync it to your iTunes library. Using iTunes iTunes is the software application you use with iPod nano. iTunes can sync music, audiobooks, podcasts, and more with iPod nano. When you connect iPod nano to your computer, iTunes opens automatically. This guide explains how to use iTunes to download songs and other audio and video to your computer, create personal compilations of your favorite songs (called playlists), sync them to iPod nano, and adjust iPod nano settings. iTunes also has a feature called Genius that creates instant playlists of songs from your iTunes library that go great together. You can sync Genius playlists that you create in iTunes to iPod nano, and you can create Genius playlists on iPod nano. To use Genius, you need iTunes 8.0 or later and an iTunes Store account. iTunes has many other features. You can burn your own CDs that play in standard CD players (if your computer has a recordable CD drive); listen to streaming Internet radio; watch videos and TV shows; rate songs according to preference; and much more. For information about using these iTunes features, open iTunes and choose Help > iTunes Help. If you already have iTunes 8.0 installed on your computer and you’ve set up your iTunes library, you can skip ahead to the next section, “Syncing iPod nano.” To learn how to set up Genius in iTunes, see “Using Genius in iTunes” on page 25.Chapter 2 Setting Up iPod nano 21 Importing Music into Your iTunes Library To listen to music on iPod nano, you first need to get that music into iTunes on your computer. There are three ways of getting music and other audio into iTunes:  Purchase music, audiobooks, and videos, or download podcasts online from the iTunes Store.  Import music and other audio from audio CDs.  Add music and other audio that’s already on your computer to your iTunes library. Purchasing Songs and Downloading Podcasts Using the iTunes Store If you have an Internet connection, you can easily purchase and download songs, albums, audiobooks, and videos online using the iTunes Store. You can also subscribe to and download podcasts. To purchase music online using the iTunes Store, you set up an Apple account in iTunes, find the songs you want, and then buy them. If you already have an Apple account, or if you have an America Online (AOL) account (available in some countries only), you can use that account to sign in to the iTunes Store and buy songs. You don’t need an iTunes Store account to download or subscribe to podcasts. To sign in to the iTunes Store: m Open iTunes and then:  If you already have an iTunes account, choose Store > Sign In.  If you don’t already have an iTunes account, choose Store > Create Account and follow the onscreen instructions to set up an Apple account or enter your existing Apple account or AOL account information. You can browse or search the iTunes Store to find the album, song, or artist you’re looking for. Open iTunes and select iTunes Store in the source list.  To browse the iTunes Store, choose a category (for example, Music) on the left side of the main page in the iTunes Store. You can choose a genre, look at new releases, click one of the featured songs, look at Top Songs and more, or click Browse under Quick Links in the main iTunes Store window.22 Chapter 2 Setting Up iPod nano  To browse for podcasts, click the Podcasts link on the left side of the main page in the iTunes Store.  To search the iTunes Store, type the name of an album, song, artist, or composer in the search field.  To narrow your search, type something in the search field, press Return or Enter on your keyboard, and then click links in the Search Bar at the top of the results page. For example, to narrow your search to songs and albums, click the Music link.  To search for a combination of items, click Power Search in the Search Results window.  To return to the main page of the iTunes Store, click the Home button in the status line at the top of the window. To buy a song, album, music video, or audiobook: 1 Select iTunes Store in the source list, and then find the item you want to buy. You can double-click a song or other item to listen to a portion of it and make sure it’s what you want. (If your network connection is slower than 128 kbps, choose iTunes > Preferences, and in the Store pane, select the “Load complete preview before playing” checkbox.) 2 Click Buy Song, Buy Album, Buy Video, or Buy Book. The song or other item is downloaded to your computer and charged to the credit card listed on your Apple or AOL account. To download or subscribe to a podcast: 1 Select iTunes Store in the source list. 2 Click the Podcasts link on the left side of the main page in the iTunes Store. 3 Browse for the podcast you want to download.  To download a single podcast episode, click the Get Episode button next to the episode.  To subscribe to a podcast, click the Subscribe button next to the podcast graphic. iTunes downloads the most recent episode. As new episodes become available, they are automatically downloaded to iTunes when you connect to the Internet. For more information, see “Adding Podcasts to iPod nano” on page 30 and “Watching and Listening to Podcasts” on page 42. Adding Songs Already on Your Computer to Your iTunes Library If you have songs on your computer encoded in file formats that iTunes supports, you can easily add the songs to iTunes. To add songs on your computer to your iTunes library: m Drag the folder or disk containing the audio files to Library in the iTunes source list (or choose File > Add to Library and select the folder or disk). If iTunes supports the song file format, the songs are automatically added to your iTunes library.Chapter 2 Setting Up iPod nano 23 You can also drag individual song files to iTunes. Note: Using iTunes for Windows, you can convert nonprotected WMA files to AAC or MP3 format. This can be useful if you have a library of music encoded in WMA format. For more information, open iTunes and choose Help > iTunes Help. Importing Music From Your Audio CDs Into iTunes Follow these instructions to get music from your CDs into iTunes. To import music from an audio CD into iTunes: 1 Insert a CD into your computer and open iTunes. If you have an Internet connection, iTunes gets the names of the songs on the CD from the Internet (if available) and lists them in the window. If you don’t have an Internet connection, you can import your CDs and, later, when you’re connected to the Internet, choose Advanced > Get CD Track Names. iTunes will bring in the track names for the imported CDs. If the CD track names aren’t available online, you can enter the names of the songs manually. See “Entering Song Names and Other Details” below. With song information entered, you can browse for songs in iTunes or on iPod by title, artist, album, and more. 2 Click to remove the checkmark next to any song you don’t want to import. 3 Click the Import button. The display area at the top of the iTunes window shows how long it will take to import each song. By default, iTunes plays songs as they are imported. If you’re importing a lot of songs, you might want to stop the songs from playing to improve performance. 4 To eject the CD, click the Eject (C) button. You cannot eject a CD until the import is done. 5 Repeat these steps for any other CDs with songs you want to import. Entering Song Names and Other Details To enter CD song names and other information manually: 1 Select the first song on the CD and choose File > Get Info. 2 Click Info. 3 Enter the song information. 4 Click Next to enter information for the next song. 5 Click OK when you finish.24 Chapter 2 Setting Up iPod nano Adding Lyrics You can enter song lyrics in plain text format into iTunes so that you can view the song lyrics on iPod nano while the song is playing. To enter lyrics into iTunes: 1 Select a song and choose File > Get Info. 2 Click Lyrics. 3 Enter song lyrics in the text box. 4 Click Next to enter lyrics for the next song. 5 When you finish, click OK. For more information, see “Viewing Lyrics on iPod nano” on page 35. Adding Album Artwork Music you purchase from the iTunes Store includes album artwork, which iPod nano can display. You can add album artwork automatically for music you’ve imported from CDs, if the CDs are available from the iTunes Store. You can add album artwork manually if you have the album art on your computer. To add album artwork automatically: m Choose Advanced > Get Album Artwork. You must have an iTunes Store account to add album artwork automatically. To add album artwork to iTunes manually: 1 Select a song and choose File > Get Info. 2 Click Artwork. 3 Click Add, navigate to the artwork file, and click Choose. 4 Use the slider to adjust the size of the artwork. 5 Click Next to add artwork for the next song or album. 6 Click OK when you finish. For more information, see “Viewing Album Artwork on iPod nano” on page 36. Organizing Your Music Using iTunes, you can organize songs and other items into lists, called playlists, in any way you want. For example, you can create playlists with songs to listen to while exercising, or playlists with songs for a particular mood. You can also create Smart Playlists that update automatically based on rules you define. When you add songs to iTunes that match the rules, they automatically get added to the Smart Playlist.Chapter 2 Setting Up iPod nano 25 You can create as many playlists as you like using any of the songs in your iTunes library. Adding a song to a playlist or later removing it doesn’t remove it from your library. To create a playlist in iTunes: 1 Click the Add (+) button or choose File > New Playlist. 2 Type a name for the playlist. 3 Click Music in the Library list, and then drag a song or other item to the playlist. To select multiple songs, hold down the Shift key or the Command (x) key on a Mac, or the Shift key or the Control key on a Windows PC, as you click each song. To create a Smart Playlist: m Choose File > New Smart Playlist and define the rules for your playlist. Note: To create playlists on iPod nano when iPod nano isn’t connected to your computer, see “Creating On-The-Go Playlists on iPod nano” on page 37. Using Genius in iTunes Genius automatically creates playlists containing songs in your library that go great together. To use Genius on iPod nano, you first need to set up Genius in iTunes. Genius is a free service, but an iTunes Store account is required (if you don’t have one, you can set one up when you turn on Genius). To set up Genius: 1 In iTunes, choose Store > Turn On Genius. 2 Follow the onscreen instructions. iTunes collects anonymous information about your library and compares it with all songs available at the iTunes Store and with the libraries of other iTunes Store customers. The amount of time this takes can vary according to the size of your library, connection speed, and other factors. 3 Connect and sync iPod nano. You can now use Genius on iPod nano (see page 38). To create a Genius playlist in iTunes: 1 Click Music in the Library list or select a playlist. 2 Select a song. 3 Click the Genius button at the bottom of the iTunes window.26 Chapter 2 Setting Up iPod nano 4 To change the maximum number of songs included in the playlist, choose a number from the pop-up menu. 5 To save the playlist, click Save Playlist. You can add and remove items from a saved Genius playlist. You can also click Refresh to create a new playlist based on the same original song. Genius playlists created in iTunes can be synced to iPod nano like any iTunes playlist. See “Syncing Music From Selected Playlists to iPod nano” on page 28. Purchasing or Renting Videos and Downloading Video Podcasts To purchase videos—movies, TV shows, and music videos—or rent movies online from the iTunes Store (part of iTunes and available in some countries only), you sign in to your iTunes Store account, find the videos you want, and then buy or rent them. A rented movie expires 30 days after you rent it or 24 hours after you begin playing it, whichever comes first. Expired rentals are deleted automatically. Note: These terms apply to U.S. rentals. Rental terms vary among countries. To browse videos in the iTunes Store: 1 In iTunes, select iTunes Store in the source list. 2 Click an item (Movies, TV Shows, or Music Videos) in the iTunes Store list on the left. You can also find some music videos as part of an album or other offer. You can view movie trailers or TV show previews. Videos in iTunes and in the iTunes Store have a display ( ) icon next to them. To buy or rent a video: 1 Select iTunes Store in the source list, and then find the item you want to buy or rent. 2 Click Buy Video, Buy Episode, Buy Season, Buy Movie, or Rent Movie. Purchased videos appear when you select Movies or TV Shows (under Library) or Purchased (under Store) in the source list. Rented videos appear when you select Rented Movies (under Library). Some items have other options, such as TV shows that let you buy a season pass for all episodes. To download a video podcast: Video podcasts appear alongside other podcasts in the iTunes Store. You can subscribe to them and download them just as you would other podcasts. You don’t need an iTunes Store account to download podcasts. See “Purchasing Songs and Downloading Podcasts Using the iTunes Store” on page 21.Chapter 2 Setting Up iPod nano 27 Converting Your Own Videos to Work with iPod nano You can view other video files on iPod nano, such as videos you create in iMovie on a Mac or videos you download from the Internet. Import the video into iTunes, convert it for use with iPod nano, if necessary, and then add it to iPod nano. iTunes supports all the video formats that QuickTime supports. For more information, choose Help > QuickTime Player Help from the QuickTime Player menu bar. To import a video into iTunes: m Drag the video file to your iTunes library. Some videos may be ready for use with iPod nano after you import them to iTunes. If you try to add a video to iPod nano (see “Syncing Videos Automatically” on page 31), and a message says the video can’t play on iPod nano, then you must convert the video for use with iPod nano. To convert a video for use with iPod nano: 1 Select the video in your iTunes library. 2 Choose Advanced > “Convert Selection to iPod.” Depending on the length and content of a video, converting it for use with iPod nano can take several minutes to several hours. When you convert a video for use with iPod nano, the original video remains in your iTunes library. For more about converting video for iPod nano, go to www.info.apple.com/kbnum/n302758. Adding Music to iPod nano After your music is imported and organized in iTunes, you can easily add it to iPod nano. To set how music is added from your computer to iPod nano, you connect iPod nano to your computer, and then use iTunes preferences to choose iPod nano settings.28 Chapter 2 Setting Up iPod nano You can set iTunes to add music to iPod nano in three ways:  Sync all songs and playlists: When you connect iPod nano, it’s automatically updated to match the songs and other items in your iTunes library. Any other songs on iPod nano are deleted.  Sync selected playlists: When you connect iPod nano, it’s automatically updated to match the songs in playlists you select in iTunes.  Manually add music to iPod nano: When you connect iPod nano, you can drag songs and playlists individually to iPod nano, and delete songs and playlists individually from iPod nano. Using this option, you can add songs from more than one computer without erasing songs from iPod nano. When you manage music yourself, you must always eject iPod nano from iTunes before you can disconnect it. Syncing Music Automatically By default, iPod nano is set to sync all songs and playlists when you connect it to your computer. This is the simplest way to add music to iPod nano. You just connect iPod nano to your computer, let it add songs, audiobooks, videos, and other items automatically, and then disconnect it and go. If you added any songs to iTunes since the last time you connected iPod nano, they are synced with iPod nano. If you deleted songs from iTunes, they are removed from iPod nano. To sync music with iPod nano: m Simply connect iPod nano to your computer. If iPod nano is set to sync automatically, the update begins. Important: The first time you connect iPod nano to a computer, a message asks if you want to sync songs automatically. If you accept, all songs, audiobooks, and videos are erased from iPod nano and replaced with songs and other items from that computer. If you don’t accept, you can still add songs to iPod nano manually without erasing any of the songs already on iPod nano. While music is being synced from your computer to iPod nano, the iTunes status window shows progress, and you see a sync icon next to the iPod nano icon in the source list. When the update is done, a message in iTunes says “iPod update is complete.” Syncing Music From Selected Playlists to iPod nano Setting iTunes to sync selected playlists to iPod nano is useful if the music in your iTunes library doesn’t all fit on iPod nano. Only the music in the playlists you select is synced to iPod nano. To set iTunes to sync music from selected playlists to iPod nano: 1 In iTunes, select iPod nano in the source list and click the Music tab. 2 Select “Sync music” and then choose “Selected playlists.”Chapter 2 Setting Up iPod nano 29 3 Select the playlists you want. 4 To include music videos and display album artwork, select those options. 5 Click Apply. If “Sync only checked songs and videos” is selected in the Summary pane, iTunes syncs only items that are checked. Managing iPod nano Manually Setting iTunes to let you manage iPod nano manually gives you the most flexibility for managing music and video on iPod nano. You can add and remove individual songs (including music videos) and videos (including movies and TV shows). Also, you can add music and video from multiple computers to iPod nano without erasing items already on iPod nano. Setting iPod nano to manually manage music and video turns off the automatic sync options in the Music, Movies, and TV Shows panes. You cannot manually manage one and automatically sync another at the same time. To set iTunes to let you manage music and video on iPod nano manually: 1 In iTunes, select iPod nano in the source list and click the Summary tab. 2 In the Options section, select “Manually manage music and video.” 3 Click Apply. When you manage songs and video yourself, you must always eject iPod nano from iTunes before you disconnect it. To add a song, video, or other item to iPod nano: 1 Click Music or another Library item in the iTunes source list. 2 Drag a song or other item to iPod nano in the source list. To remove a song, video, or other item from iPod nano: 1 In iTunes, select iPod nano in the source list. 2 Select a song or other item on iPod nano and press the Delete or Backspace key on your keyboard. If you manually remove a song or other item from iPod nano, it isn’t deleted from your iTunes library. To create a new playlist on iPod nano: 1 In iTunes, select iPod nano in the source list, and then click the Add (+) button or choose File > New Playlist. 2 Type a name for the playlist. 3 Click an item, such as Music, in the Library list, and then drag songs or other items to the playlist.30 Chapter 2 Setting Up iPod nano To add songs to or remove songs from a playlist on iPod nano: m Drag a song to a playlist on iPod nano to add the song. Select a song in a playlist and press the Delete key on your keyboard to delete the song. If you set iTunes to manage music manually, you can reset it later to sync automatically. To reset iTunes to sync all music automatically on iPod nano: 1 In iTunes, select iPod nano in the source list and click the Music tab. 2 Select “Sync music” and then choose “All songs and playlists.” 3 Click Apply. The update begins automatically. If “Only sync checked items” is selected in the Summary pane, iTunes syncs only items that are checked in your Music and other libraries. Adding Podcasts to iPod nano The settings for adding podcasts to iPod nano are unrelated to the settings for adding songs. Podcast update settings don’t affect song update settings, and vice versa. You can set iTunes to automatically sync all or selected podcasts, or you can add podcasts to iPod nano manually. To set iTunes to update the podcasts on iPod nano automatically: 1 In iTunes, select iPod nano in the source list and click the Podcasts tab. 2 In the Podcasts pane, select “Sync … episodes” and choose the number of episodes you want in the pop-up menu. 3 Click “All podcasts” or “Selected podcasts.” If you click “Selected podcasts,” also select the podcasts in the list that you want to sync. 4 Click Apply. When you set iTunes to sync iPod nano podcasts automatically, iPod nano is updated each time you connect it to your computer. Note: If “Only sync checked items” is selected in the Summary pane, iTunes syncs only items that are checked in your Podcasts and other libraries. To manually manage podcasts: 1 In iTunes, select iPod nano in the source list and click the Summary tab. 2 Select “Manually manage music and videos” and click Apply. 3 Select the Podcasts library in the source list and drag the podcasts you want to iPod nano.Chapter 2 Setting Up iPod nano 31 Adding Videos to iPod nano You add movies and TV shows to iPod nano much the same way you add songs. You can set iTunes to sync all movies and TV shows to iPod nano automatically when you connect iPod nano, or you can set iTunes to sync only selected playlists. Alternatively, you can manage movies and TV shows manually. Using this option, you can add videos from more than one computer without erasing videos already on iPod nano. Note: Music videos are managed with songs, under the Music tab in iTunes. See “Adding Music to iPod nano” on page 27. Important: You can view a rented movie on only one device at a time. For example, if you rent a movie from the iTunes Store and add it to iPod nano, you can only view it on iPod nano. If you transfer the movie back to iTunes, you can only view it there and not on iPod nano. All standard time limits apply to rented movies added to iPod nano. Syncing Videos Automatically By default, iPod nano is set to sync all videos when you connect it to your computer. This is the simplest way to add videos to iPod nano. You just connect iPod nano to your computer, let it add videos and other items automatically, and then disconnect it and go. If you added any videos to iTunes since the last time you connected iPod nano, they are added to iPod nano. If you deleted videos from iTunes, they are removed from iPod nano. You can set iPod nano to sync videos automatically when you connect it to your computer. To sync videos to iPod nano: m Simply connect iPod nano to your computer. If iPod nano is set to sync automatically, the syncing begins.32 Chapter 2 Setting Up iPod nano Important: The first time you connect iPod nano to a different computer and have the automatic sync option set, a message asks if you want to sync songs and videos automatically. If you accept, all songs, videos, and other items are deleted from iPod nano and replaced with the songs, videos, and other items in the iTunes library on that computer. If you don’t accept, you can still add videos to iPod nano manually without deleting any of the videos already on iPod nano. iTunes includes a feature to sync purchased items from iPod nano to another computer. For more information, see iTunes Help. While videos are being synced from your computer to iPod nano, the iTunes status window shows progress and the iPod nano icon in the source list flashes red. When the update is done, a message in iTunes says “iPod update is complete.” Syncing Selected Videos to iPod nano Setting iTunes to sync selected videos to iPod nano is useful if you have more videos in your iTunes library than will fit on iPod nano. Only the videos you specify are synced with iPod nano. You can sync selected videos or selected playlists that contain videos. To set iTunes to sync unwatched or selected movies to iPod nano: 1 In iTunes, select iPod nano in the source list and click the Movies tab. 2 Select “Sync movies.” 3 Select the movies or playlists you want. Unwatched movies: Select “… unwatched movies” and choose the number you want from the pop-up menu. Selected movies or playlists: Click “Selected …,” choose “movies” or “playlists” from the pop-up menu, and then select the movies or playlists you want. 4 Click Apply. If “Only sync checked items” is selected in the Summary pane, iTunes syncs only movies that are checked. To set iTunes to sync most recent episodes or selected TV shows to iPod nano: 1 In iTunes, select iPod nano in the source list and click the TV Shows tab. 2 Select “Sync … episodes” and choose the number of episodes you want from the pop-up menu. 3 Click “Selected …” and choose “TV shows” or “playlists” from the pop-up menu. 4 Select the movies or playlists you want to sync. 5 Click Apply. If “Only sync checked items” is selected in the Summary pane, iTunes syncs only TV show that are checked.Chapter 2 Setting Up iPod nano 33 Managing Videos Manually Setting iTunes to let you manage iPod nano manually gives you the most flexibility for managing videos on iPod nano. You can add and remove movies, TV shows, and other items individually. You can also add videos from multiple computers to iPod nano without removing videos already on iPod nano. See “Managing iPod nano Manually” on page 29. If you set iTunes to manage movies and TV shows manually, you can reset iTunes later to sync them automatically. If you set iTunes to sync automatically after you’ve been manually managing iPod nano, you lose any items on iPod nano that aren’t part of your iTunes library. To set iTunes to sync all movies automatically on iPod nano: 1 In iTunes, select iPod nano in the source list and click the Movies tab. 2 Select “Sync movies” and then select “All movies.” 3 Click Apply. If “Only sync checked items” is selected in the Summary pane, iTunes syncs only movies that are checked. To set iTunes to sync all TV shows automatically on iPod nano: 1 In iTunes, select iPod nano in the source list and click the TV Shows tab. 2 Select “Sync … episodes” and choose “all” from the pop-up menu. 3 Select “All TV shows.” 4 Click Apply. If “Only sync checked items” is selected in the Summary pane, iTunes syncs only TV shows that are checked. Adding Video Podcasts to iPod nano You add video podcasts to iPod nano the same way you add other podcasts (see “Adding Podcasts to iPod nano” on page 30). If a podcast has a video component, the video plays when you choose it from Podcasts.3 34 3 Listening to Music After you set up iPod nano, you can listen to songs, podcasts, audiobooks, radio, and more. Read this chapter to learn about listening on the go. Playing Music and Other Audio Use the Click Wheel and Center button to browse for a song or music video. To browse for and play a song: m Choose Music, browse for a song or music video, and press the Play/Pause button. Note: When you browse for music videos in the Music menu, you only hear the music. When you browse for them in the Videos menu, you also see the video. When a song is playing, the Now Playing screen appears. The following table describes the elements on the Now Playing screen of iPod nano. Now Playing screen item Function Shuffle (¡) icon Appears if iPod nano is set to shuffle songs or albums. Repeat (⁄) icon Appears if iPod nano is set to repeat all songs. The Repeat Once (!) icon appears if iPod nano is set to repeat one song. Album art Shows the album art, if it’s available. Song information (click the Center button to see the scrubber bar, Genius or shuffle slider, song rating and lyrics) Album art Shuffle icon Repeat iconChapter 3 Listening to Music 35 To change the playback volume: m When you see the progress bar, use the Click Wheel to change the volume. To listen to a different part of a song: 1 Press the Center button until you see the scrubber bar. 2 Use the Click Wheel to move the diamond along the scrubber bar. To return to the previous menu: m From any screen, press the Menu button to return to the previous menu. Viewing Lyrics on iPod nano If you enter lyrics for a song in iTunes (see “Adding Lyrics” on page 24) and then add the song to iPod nano, you can view the lyrics on iPod nano. Lyrics will not appear if you did not enter them. To view lyrics on iPod nano while a song is playing: m On the Now Playing screen, press the Center button until you see the lyrics. You can scroll through the lyrics as the song plays. Rating Songs You can assign a rating to a song (from 1 to 5 stars) to indicate how much you like it. You can use song ratings to help you create Smart Playlists automatically in iTunes. To rate a song: 1 Start playing the song. 2 From the Now Playing screen, press the Center button until the five rating bullets appear. 3 Use the Click Wheel to choose a rating (represented by stars). Note: You cannot assign ratings to video podcasts. Song information Displays the song title, artist, and album title. Song time progress bar Shows the elapsed and remaining times for the song that’s playing. Scrubber bar Allows you to quickly navigate to a different part of the track. Genius slider Creates a Genius playlist based on the current song (doesn’t appear if Genius information isn’t available for the current song). Shuffle slider Allows you to shuffle songs or albums directly from the Now Playing screen. Song Rating Displays stars if you rate the song. Lyrics Displays the lyrics of the song that’s playing (doesn’t appear if you didn’t enter the song’s lyrics). Now Playing screen item Function36 Chapter 3 Listening to Music Viewing Album Artwork on iPod nano By default, iTunes displays album artwork on iPod nano. If the artwork is available, you’ll see it on iPod nano in Cover Flow, in the album list, and when you play music from the album. To set iTunes to display album artwork on iPod nano: 1 Connect iPod nano to your computer. 2 In iTunes, select iPod nano in the source list and click the Music tab. 3 Select “Display album artwork on your iPod.” To see album artwork on iPod nano: m Hold iPod nano horizontally to view Cover Flow, or play a song that has album artwork. For more information about album artwork, open iTunes and choose Help > iTunes Help. Accessing Additional Commands Some iPod nano commands can be accessed directly from the Now Playing screen and some menus. To access additional commands: m Press and hold the Center button until a menu appears, select a command, and then press the Center button again. Browsing Songs by Album or Artist When you’re listening to a song, you can browse more songs by the same artist or all the songs in the current album. To browse songs by album: 1 From the Now Playing screen, press and hold the Center button until a menu appears. 2 Choose Browse Album, and then press the Center button. You see all the songs from the current album that are on iPod nano. You can select a different song or return to the Now Playing screen.Chapter 3 Listening to Music 37 To browse songs by artist: 1 From the Now Playing screen, press and hold the Center button until a menu appears. 2 Choose Browse Artist, and then press the Center button. You see all the songs by that artist that are on iPod nano. You can select a different song or return to the Now Playing screen. Creating On-The-Go Playlists on iPod nano You can create playlists on iPod nano, called On-The-Go Playlists, when iPod nano isn’t connected to your computer. To create an On-The-Go playlist: 1 Select a song, and then press and hold the Center button until a menu appears. 2 Choose “Add to On-The-Go.” 3 To add more songs, repeat steps 1 and 2. 4 Choose Music > Playlists > On-The-Go to browse and play your list of songs. You can also add a group of songs. For example, to add an album, highlight the album title, press and hold the Center button until a menu appears, and then choose “Add to On-The-Go.” To play songs in the On-The-Go playlist: m Choose Music > Playlists > On-The-Go, and then choose a song. To remove a song from the On-The-Go playlist: 1 Select a song in the playlist and hold down the Center button until a menu appears. 2 Choose “Remove from On-The-Go,” and then press the Center button. To clear the entire On-The-Go playlist: m Choose Music > Playlists > On-The-Go > Clear Playlist, and then click Clear. To save the On-The-Go playlist on iPod nano: m Choose Music > Playlists > On-The-Go > Save Playlist. The first playlist is saved as “New Playlist 1” in the Playlists menu. The On-The-Go playlist is cleared. You can save as many playlists as you like. After you save a playlist, you can no longer remove songs from it. To copy On-The-Go playlists from iPod nano to your computer: m If iPod nano is set to update songs automatically (see “Syncing Music Automatically” on page 28) and you create an On-The-Go playlist, the playlist is automatically copied to iTunes when you connect iPod nano. The new On-The-Go playlist appears in the list of playlists in iTunes. You can rename, edit, or delete the new playlist, just as you would any playlist.38 Chapter 3 Listening to Music Using Genius on iPod nano When iPod nano isn’t connected to your computer, Genius can still automatically create instant playlists of songs that go great together. To use Genius, you need to set up Genius in the iTunes Store, and then sync iPod nano to iTunes. You can also create Genius playlists in iTunes and add them to iPod nano. To set up Genius in iTunes, see “Using Genius in iTunes” on page 25. To make a Genius playlist with iPod nano: 1 Select a song, and then press and hold the Center button until a menu appears. You can select a song from a menu or playlist, or you can start from the Now Playing screen. 2 Choose Start Genius, and then press the Center button. The new playlist appears. Start Genius doesn’t appear if any of the following apply:  You haven’t set up Genius in iTunes and then synced iPod nano to iTunes.  Genius doesn’t recognize the song you’ve selected.  Genius recognizes the song but there aren’t at least ten similar songs in your library. 3 To keep the playlist, choose Save Playlist. The playlist is saved with the song title and artist of the song you used to make the playlist. 4 To change the playlist to a new one based on the same song, choose Refresh. If you refresh a saved playlist, the new playlist replaces the previous one. You can’t recover the previous playlist. You can also start Genius from the Now Playing screen by pressing the Center button until you see the Genius slider, and then using the Click Wheel to move the slider to the right. The Genius slider won’t appear if Genius doesn’t recognize the song that’s playing. Genius playlists saved on iPod nano sync to iTunes when you connect iPod nano to your computer. To play a Genius playlist: m Choose Music > Playlists and choose the playlist.Chapter 3 Listening to Music 39 Setting iPod nano to Shuffle Songs You can set iPod nano to play songs, albums, or your entire library in random order. To set iPod nano to shuffle and play all your songs: m Choose Shuffle Songs from the iPod nano main menu. iPod nano begins playing songs from your entire music library in random order, skipping audiobooks and podcasts. To set iPod nano to always shuffle songs or albums: 1 Choose Settings from the iPod nano main menu. 2 Set Shuffle to either Songs or Albums. When you set iPod nano to shuffle songs by choosing Settings > Shuffle, iPod nano shuffles songs within the list (for example, album or playlist) you choose to play. When you set iPod nano to shuffle albums, it plays all the songs on an album in order, and then randomly selects another album in the list and plays through it in order. You can also set iPod nano to shuffle songs directly from the Now Playing screen by clicking the Center button until the shuffle slider appears, and then using the Click Wheel to set iPod nano to shuffle songs or albums. To shuffle songs while a song is playing or paused: m Shake iPod nano from side to side. A new song starts to play. Shaking to shuffle doesn’t change your shuffle settings, whether you set them by choosing Settings > Shuffle or by using the shuffle slider.40 Chapter 3 Listening to Music To disable shaking: m Choose Settings > Playback > Shake and select Off. To turn shaking on again, choose Settings > Playback > Shake, and then select On. Shaking is also disabled when the Hold switch is in the HOLD position, or if the display is off. If iPod nano is off, you can’t turn it on by shaking it. Setting iPod nano to Repeat Songs You can set iPod nano to repeat a song over and over, or repeat songs within the list you choose to play. To set iPod nano to repeat songs: m Choose Settings from the iPod nano main menu.  To repeat all songs in the list, set Repeat to All.  To repeat one song over and over, set Repeat to One. Customizing the Music Menu You can add items to or remove them from the Music menu, just as you do with the main menu. For example, you can add a Compilations item to the Music menu, so you can easily choose compilations that are put together from various sources. To add or remove items in the Music menu: 1 Choose Settings > General > Music Menu. 2 Select each item you want to appear in the Music menu. A checkmark indicates which items have been added. To revert to the original Music menu settings, choose Reset Menu. Setting the Maximum Volume Limit You can set a limit for the maximum volume on iPod nano and assign a combination to prevent the setting from being changed. To set the maximum volume limit for iPod nano: 1 Choose Settings > Playback > Volume Limit. The volume control shows the current volume. 2 Use the Click Wheel to select the maximum volume limit. 3 Press the Center button to set the maximum volume limit. A triangle on the volume bar indicates the maximum volume limit.Chapter 3 Listening to Music 41 To require a combination to change the maximum volume: 1 After setting the maximum volume, use the Click Wheel to select Lock and then press the Center button. 2 In the screen that appears, enter a combination. To enter a combination:  Use the Click Wheel to select a number for the first position. Press the Center button to confirm your choice and move to the next position.  Use the same method to set the remaining numbers of the combination. You can use the Next/Fast-forward button to move to the next position and the Previous/Rewind button to move to the previous position. Press the Center button in the final position to confirm the entire combination. The volume of songs and other audio may vary depending on how the audio was recorded or encoded. See “Setting Songs to Play at the Same Volume Level” on page 42 for information about how to set a relative volume level in iTunes and on iPod nano. Volume level may also vary if you use different earphones or headphones. With the exception of the iPod Radio Remote, accessories that connect through the iPod Dock Connector don’t support volume limits. If you set a combination, you must enter it before you can change or remove the maximum volume limit. To change the maximum volume limit: 1 Choose Settings > Playback > Volume Limit. 2 If you set a combination, enter it by using the Click Wheel to select the numbers and pressing the Center button to confirm them. 3 Use the Click Wheel to change the maximum volume limit. 4 Press the Play/Pause button to accept the change. To remove the maximum volume limit: 1 If you’re currently listening to iPod nano, press Pause. 2 Choose Settings > Playback > Volume Limit. 3 If you set a combination, enter it by using the Click Wheel to select the numbers and pressing the Center button to confirm them. 4 Use the Click Wheel to move the volume limit to the maximum level on the volume bar. This removes any restriction on volume. 5 Press the Play/Pause button to accept the change. If you forget the combination, you can restore iPod nano. See “Updating and Restoring iPod Software” on page 69.42 Chapter 3 Listening to Music Setting Songs to Play at the Same Volume Level iTunes can automatically adjust the volume of songs, so they play at the same relative volume level. You can set iPod nano to use the iTunes volume settings. To set iTunes to play songs at the same sound level: 1 In iTunes, choose iTunes > Preferences if you’re using a Mac, or choose Edit > Preferences if you’re using a Windows PC. 2 Click Playback and select Sound Check, and then click OK. To set iPod nano to use the iTunes volume settings: m Choose Settings and set Sound Check to On. If you haven’t activated Sound Check in iTunes, setting it on iPod nano has no effect. Using the Equalizer You can use equalizer presets to change the sound on iPod nano to suit a particular music genre or style. For example, to make rock music sound better, set the equalizer to Rock. To use the equalizer to change the sound on iPod nano: m Choose Settings > Playback > EQ, and then choose an equalizer preset. If you assigned an equalizer preset to a song in iTunes and the iPod nano equalizer is set to Off, the song plays using the iTunes setting. See iTunes Help for more information. Crossfading Between Songs You can set iPod nano to fade out at the end of each song and fade in at the beginning of the song following it. To turn on crossfading: m Choose Settings > Playback > Audio Crossfade and select On. Note: Songs that are grouped for gapless playback play without gaps even when crossfading is on. Watching and Listening to Podcasts Podcasts are downloadable audio or video shows you get at the iTunes Store. You can listen to audio podcasts and watch video podcasts. Podcasts are organized by shows, episodes within shows, and chapters within episodes. If you stop watching or listening to a podcast and go back to it later, the podcast begins playing from where you left off. To watch or listen to a podcast: 1 From the main menu, choose Podcasts, and then choose a show.Chapter 3 Listening to Music 43 Shows appear in reverse chronological order so that you can watch or listen to the most recent one first. You see a blue dot next to shows and episodes you haven’t watched or listened to yet. 2 Choose an episode to play it. The Now Playing screen displays the show, episode, and date information, along with elapsed and remaining time. Press the Center button to see more information about the podcast. If the podcast includes artwork, you also see a picture. Podcast artwork can change during an episode. If the podcast has chapters, you can press the Next/Fast-forward or Previous/Rewind button to skip to the next chapter or the beginning of the current chapter in the podcast. For more information about podcasts, open iTunes and choose Help > iTunes Help. Then search for “podcasts.” Listening to Audiobooks You can purchase and download audiobooks from the iTunes Store or from audible.com and listen to them on iPod nano. Use iTunes to add audiobooks to iPod nano the same way you add songs. If you stop listening to an audiobook on iPod nano and go back to it later, the audiobook begins playing from where you left off. iPod nano skips audiobooks when set to shuffle. If the audiobook you’re listening to has chapters, you can press the Next/Fast-forward or Previous/Rewind button to skip to the next chapter or the beginning of the current chapter. You can play audiobooks at speeds faster or slower than normal. To set audiobook play speed: m Choose Settings > Playback > Audiobooks and choose a speed, or press and hold the Center button from the Now Playing window. Setting the play speed affects only audiobooks purchased from the iTunes Store or audible.com. Listening to FM Radio You can listen to radio using the optional iPod Radio Remote accessory for iPod nano. iPod Radio Remote attaches to iPod nano using the Dock connector cable. When you’re using iPod Radio Remote, you see a Radio menu item on the iPod nano main menu. For more information, see the iPod Radio Remote documentation.4 44 4 Watching Videos You can use iPod nano to watch TV shows, movies, video podcasts, and more. Read this chapter to learn about watching videos on iPod nano and on your TV. You can view and listen to videos on iPod nano. If you have an AV cable from Apple (available separately at www.apple.com/ipodstore), you can watch videos from iPod nano on your TV. Watching and Listening to Videos on iPod nano Videos you add to iPod nano appear in the Videos menus. Music videos also appear in Music menus. To watch a video on iPod nano: m Choose Videos and browse for a video. Select a video and then press Play/Pause. To watch the video, hold iPod nano horizontally. If you rotate iPod nano to the left or right, the video adjusts accordingly. When you play a video on iPod nano, you see and hear the video. Chapter 4 Watching Videos 45 To just listen to a music video: m Choose Music and browse for a music video. When you play the video, you hear it but don’t see it. When you play a playlist that includes video podcasts, you hear the podcasts but don’t see them. To watch a video podcast: m From the main menu, choose Podcasts and then choose a video podcast. See “Watching and Listening to Podcasts” on page 42 for more information. Watching Videos on a TV Connected to iPod nano If you have an AV cable from Apple, you can watch videos on a TV connected to your iPod nano. First you set iPod nano to display videos on a TV, then connect iPod nano to your TV, and then play a video. Note: Use the Apple Component AV Cable, the Apple Composite AV Cable, or the Apple AV Connection Kit. Other similar RCA-type cables might not work. You can purchase the cables at www.apple.com/ipodstore. To set iPod nano to display videos on a TV: m Choose Videos > Settings, and then set TV Out to Ask or On. If you set TV Out to Ask, iPod nano gives you the option of displaying videos on TV or on iPod nano every time you play a video. You can also set video to display full screen or widescreen, and set video to display on PAL or NTSC devices. To set TV settings: m Choose Videos > Settings, and then follow the instructions below. To set Do this Video to display on a TV Set TV Out to Ask or On. Video to display on PAL or NTSC TVs Set TV Signal to PAL or NTSC. PAL and NTSC refer to TV broadcast standards. Your TV might use either of these, depending on the region where it was purchased. If you aren’t sure which your TV uses, check the documentation that came with your TV. The format of your external TV Set TV Screen to Widescreen for 16:9 format or Standard for 4:3 format. Video to fit to your screen Set “Fit to Screen” to On. If you set “Fit to Screen” to Off, widescreen videos display in letterbox format on iPod nano or a standard (4:3) TV screen. Alternate audio to play Set Alternate Audio to On.46 Chapter 4 Watching Videos To use the Apple Component AV Cable to connect iPod nano to your TV: 1 Plug the red, green, and blue video connectors into the component video input (Y, Pb, and Pr) ports on your TV. You can also use the Apple Composite AV cable. If you do, plug in the yellow video connector into the video input port on your TV. Your TV must have RCA video and audio ports. 2 Plug the white and red audio connectors into the left and right analog audio input ports, respectively, on your TV. 3 Plug the iPod Dock Connector into your iPod nano or Universal Dock. 4 Plug the USB connector into your USB Power Adapter or your computer to keep your iPod nano charged. 5 Turn on iPod nano and your TV or receiver to start playing. Make sure you set TV Out on iPod nano to On. Note: The ports on your TV or receiver may differ from the ports in the illustration. To watch a video on your TV: 1 Connect iPod nano to your TV (see above). 2 Turn on your TV and set it to display from the input ports connected to iPod nano. See the documentation that came with your TV for more information. 3 On iPod nano, choose Videos and browse for a video. Captions to display Set Captions to On. Subtitles to display Set Subtitles to On. To set Do this USB Power Adapter iPod Left audio (white) Dock Connector Television Video in (Y, Pb, Pr) Right audio (red) USB connector5 47 5 Photo Features You can import digital photos to your computer and add them to iPod nano. You can view your photos on iPod nano or as a slideshow on your TV. Read this chapter to learn about importing and viewing photos. Importing Photos You can import digital photos from a digital camera to your computer, and then add them to iPod nano for viewing. You can connect iPod nano to your TV and view photos as a slideshow with music. Importing Photos from a Camera to Your Computer You can import photos from a digital camera or a photo card reader. To import photos to a Mac using iPhoto: 1 Connect the camera or photo card reader to your computer. Open iPhoto (located in the Applications folder) if it doesn’t open automatically. 2 Click Import. Images from the camera are imported into iPhoto. You can import other digital images into iPhoto, such as images you download from the web. For more information about importing and working with photos and other images, open iPhoto and choose Help > iPhoto Help.48 Chapter 5 Photo Features iPhoto is available for purchase as part of the iLife suite of applications at www.apple.com/ilife. iPhoto might already be installed on your Mac, in the Applications folder. If you don’t have iPhoto, you can import photos using Image Capture. To import photos to a Mac using Image Capture: 1 Connect the camera or photo card reader to your computer. 2 Open Image Capture (located in the Applications folder) if it doesn’t open automatically. 3 To choose specific items to import, click Download Some. Or to download all items, click Download All. To import photos to a Windows PC: m Follow the instructions that came with your digital camera or photo application. Adding Photos From Your Computer to iPod nano You can add photos to iPod nano from a folder on your hard disk. If you have a Mac and iPhoto 6 or later, you can sync iPhoto albums automatically. If you have a Windows PC and Adobe Photoshop Album 2.0 or later, or Adobe Photoshop Elements 4.0 or later, you can sync photo collections automatically. Adding photos to iPod nano the first time might take some time, depending on how many photos are in your photo library. To sync photos from a Mac or Windows PC to iPod nano using a photo application: 1 In iTunes, select iPod nano in the source list and click the Photos tab. 2 Select “Sync photos from: …”  On a Mac, choose iPhoto from the pop-up menu.  On a Windows PC, choose Photoshop Album or Photoshop Elements from the pop-up menu. Note: Some versions of Photoshop Album and Photoshop Elements don’t support collections. You can still use them to add all your photos.Chapter 5 Photo Features 49 3 If you want to add all your photos, select “All photos and albums.” If you want to keep your photos organized by event, select “…events” and choose an option from the popup menu. If you want to add photos from only certain albums, select “Selected albums” and select the albums you want. 4 Click Apply. Each time you connect iPod nano to your computer, photos are synced automatically. To add photos from a folder on your hard disk to iPod nano: 1 Drag the images you want into a folder on your computer. If you want images to appear in separate photo albums on iPod nano, create folders inside the main image folder, and drag images into the new folders. 2 In iTunes, select iPod nano in the source list and click the Photos tab. 3 Select “Sync photos from …” 4 Choose “Choose Folder” from the pop-up menu and select your image folder. 5 Click Apply. When you add photos to iPod nano, iTunes optimizes the photos for viewing. Full-resolution image files aren’t transferred by default. Adding full-resolution image files is useful, for example if you want to move them from one computer to another, but isn’t necessary for viewing the images at full quality on iPod nano. To add full-resolution image files to iPod nano: 1 In iTunes, select iPod nano in the source list and click the Photos tab. 2 Select “Include full-resolution photos.” 3 Click Apply. iTunes copies the full-resolution versions of the photos to the Photos folder on iPod nano. To delete photos from iPod nano: 1 In iTunes, select iPod nano in the source list and click the Photos tab. 2 Select “Sync photos from: …”  On a Mac, choose iPhoto from the pop-up menu.  On a Windows PC, choose Photoshop Album or Photoshop Elements from the pop-up menu. 3 Choose “Selected albums” and deselect the albums you no longer want on iPod nano. 4 Click Apply.50 Chapter 5 Photo Features Adding Photos from iPod nano to a Computer If you add full-resolution photos from your computer to iPod nano using the previous steps, they’re stored in a Photos folder on iPod nano. You can connect iPod nano to a computer and put these photos on the computer. iPod nano must be enabled for disk use (see “Using iPod nano as an External Disk” on page 53). To add photos from iPod nano to a computer: 1 Connect iPod nano to the computer. 2 Drag image files from the Photos folder or DCIM folder on iPod nano to the desktop or to a photo editing application on the computer. You can also use a photo editing application, such as iPhoto, to add photos stored in the Photos folder. See the documentation that came with the application for more information. To delete photos from the Photos folder on iPod nano: 1 Connect iPod nano to the computer. 2 Navigate to the Photos folder on iPod nano and delete the photos you no longer want. Viewing Photos You can view photos on iPod nano manually or as a slideshow. If you have an optional AV cable from Apple (for example, Apple Component AV Cable), you can connect iPod nano to your TV and view photos as a slideshow with music. Viewing Photos on iPod nano To view photos on iPod nano: 1 On iPod nano, choose Photos > All Photos. Or choose Photos and a photo album to see only the photos in the album. Thumbnail views of the photos might take a moment to appear. 2 Select the photo you want and press the Center button.Chapter 5 Photo Features 51 3 To view photos, hold iPod nano vertically for portrait format, or horizontally for landscape format. From any photo-viewing screen, use the Click Wheel to scroll through photos (if you’re viewing a slideshow, the Click Wheel controls music volume only). Press the Next/Fastforward or Previous/Rewind button to skip to the next or previous screen of photos. Press and hold the Next/Fast-forward or Previous/Rewind button to skip to the last or first photo in the library or album. Viewing Slideshows You can view a slideshow, with music and transitions if you choose, on iPod nano. If you have an optional AV cable from Apple, you can view the slideshow on your TV. To set slideshow settings: m Choose Photos > Settings, and then follow these instructions: To set Do this How long each slide is shown Choose Time Per Slide and pick a time. The music that plays during slideshows Choose Music and choose a playlist or Now Playing. If you’re using iPhoto, you can choose From iPhoto to copy the iPhoto music setting. Only the songs that you’ve added to iPod nano play. Slides to repeat Set Repeat to On. Slides to display in random order Set Shuffle Photos to On. Slides to display with transitions Choose Transitions and choose a transition type. Slideshows to display on iPod nano Set TV Out to Ask or Off.52 Chapter 5 Photo Features To view a slideshow on iPod nano: m Select any photo, album, or roll, and press the Play/Pause button. Or select any full-screen photo and press the Center button. To pause, press the Play/Pause button. To skip to the next or previous photo, press the Next/Fast-forward or Previous/Rewind button. When you view a slideshow, the Click Wheel controls just the music volume. You can’t use the Click Wheel to scroll through photos during a slideshow. To connect iPod nano to your TV: 1 Connect the optional Apple Component or Composite AV cable to iPod nano. Use the Apple Component AV Cable, Apple Composite AV Cable, or Apple AV Connection Kit. Other similar RCA-type cables won’t work. You can purchase the cables at www.apple.com/ipodstore. 2 Connect the audio connectors to the ports on your TV (for an illustration, see page 46). Your TV must have RCA video and audio ports. To view a slideshow on your TV: 1 Connect iPod nano to your TV (see above). 2 Turn on your TV and set it to display from the input ports connected to iPod nano. See the documentation that came with your TV for more information. 3 On iPod nano, select any photo or album and press the Play/Pause button. Or select any full-screen photo and press the Center button. To pause, press the Play/Pause button. To skip to the next or previous photo, press the Next/Fast-forward or Previous/ Rewind button. If you selected a playlist in Photos > Settings > Music, the playlist plays automatically when you start the slideshow. The photos display on your TV and advance automatically according to settings in the Slideshow > Settings menu. Slideshows to display on TV Set TV Out to Ask or On. If you set TV Out to Ask, iPod nano gives you the option of showing slideshows on TV or on iPod nano every time you start a slideshow. Slides to show on PAL or NTSC TVs Set TV Signal to PAL or NTSC. PAL and NTSC refer to TV broadcast standards. Your TV might use either of these, depending on the region where it was purchased. If you aren’t sure which your TV uses, check the documentation that came with your TV. To set Do this6 53 6 More Settings, Extra Features, and Accessories iPod nano can do a lot more than play songs. And you can do a lot more with it than listen to music. Read this chapter to find out more about the extra features of iPod nano, including how to use it as an external disk, alarm, or sleep timer; play games; show the time of day in other parts of the world; display notes; and sync contacts, calendars, and to-do lists. Learn about how to use iPod nano as a stopwatch and to lock the screen, and about the accessories available for iPod nano. Using iPod nano as an External Disk You can use iPod nano as an external disk to store data files. You won’t see songs you add using iTunes in the Mac Finder or in Windows Explorer. And if you copy music files to iPod nano in the Mac Finder or Windows Explorer, you won’t be able to play them on iPod nano. To enable iPod nano as an external disk: 1 In iTunes, select iPod nano in the source list and click the Summary tab. 2 In the Options section, select “Enable disk use.” 3 Click Apply. When you use iPod nano as an external disk, the iPod nano disk icon appears on the desktop on Mac, or as the next available drive letter in Windows Explorer on a Windows PC. Note: Clicking Summary and selecting “Manually manage music and videos” in the Options section also enables iPod nano to be used as an external disk. Drag files to and from iPod nano to copy them. If you use iPod nano primarily as a disk, you might want to keep iTunes from opening automatically when you connect iPod nano to your computer.54 Chapter 6 More Settings, Extra Features, and Accessories To prevent iTunes from opening automatically when you connect iPod nano to your computer: 1 In iTunes, select iPod nano in the source list and click the Summary tab. 2 In the Options section, deselect “Open iTunes when this iPod is connected.” 3 Click Apply. Using Extra Settings You can set the date and time, clocks in different time zones, and alarm and sleep features on iPod nano. You can use iPod nano as a stopwatch or to play games, and you can lock the iPod nano screen. Setting and Viewing the Date and Time The date and time are set automatically from your computer’s clock when you connect iPod nano, but you can change the settings. To set date and time options: 1 Choose Settings > Date & Time. 2 Choose one or more of the following options: Adding Clocks for Other Time Zones To add clocks for other time zones: 1 Choose Extras > Clocks. 2 On the Clocks screen, click the Center button and choose Add. 3 Choose a region and then choose a city. The clocks you add appear in a list. The last clock you added appears last. To delete a clock: 1 Choose Extras > Clocks. 2 Choose the clock. To Do this Set the date Choose Date. Use the Click Wheel to change the selected value. Press the Center button to move to the next value. Set the time Choose Time. Use the Click Wheel to change the selected value. Press the Center button to move to the next value. Specify the time zone Choose Time Zone and use the Click Wheel to select a city in another time zone. Display the time in 24-hour format Choose 24 Hour Clock and press the Center button to turn the 24-hour format on or off. Display the time in the title bar Choose Time in Title and press the Center button to turn the option on or off. Chapter 6 More Settings, Extra Features, and Accessories 55 3 Press the Center button. 4 Choose Delete. Setting Alarms You can set an alarm for any clock on iPod nano. To use iPod nano as an alarm clock: 1 Choose Extras > Alarms. 2 Choose Create Alarm and set one or more of the following options: If you sync calendar events with alarms to iPod nano, the events appear in the Alarms menu. To delete an alarm: 1 Choose Extras > Alarms. 2 Choose the alarm and then choose Delete. Setting the Sleep Timer You can set iPod nano to turn off automatically after playing or other content for a specific period of time. To set the sleep timer: 1 Choose Extras > Alarms. 2 Choose Sleep Timer and choose how long you want iPod nano to play. Using the Stopwatch You can use the stopwatch as you exercise to track your overall time and, if you’re running on a track, your lap times. You can play music while you use the stopwatch. To Do this Turn the alarm on Choose Alarm and choose On. Set the date Choose Date. Use the Click Wheel to change the selected value. Press the Center button to move to the next value. Set the time Choose Time. Use the Click Wheel to change the selected value. Press the Center button to move to the next value. Set a repeat option Choose Repeat and choose an option (for example, “weekdays”). Choose a sound Choose Alerts or a playlist. If you choose Alerts, select Beep to hear the alarm through the internal speaker. If you choose a playlist, you’ll need to connect iPod nano to speakers or headphones to hear the alarm. Name the alarm Choose Label and choose an option (for example, “Wake up”).56 Chapter 6 More Settings, Extra Features, and Accessories To use the stopwatch: 1 Choose Extras > Stopwatch. 2 Press Play/Pause to start the timer. 3 Press the Center button to record lap times. The two most recent lap times appear above the overall time. All lap times are recorded in the log. 4 Press Play/Pause to stop the overall timer. To start the timer again, press Play/Pause. To start a new stopwatch session, press the Menu button and then choose New Timer. To review or delete a logged stopwatch session: 1 Choose Extras > Stopwatch. The current log and a list of saved sessions appear. 2 Choose a log to view session information. iPod nano stores stopwatch sessions with dates, times, and lap statistics. You see the date and time the session started; the total time of the session; the shortest, longest, and average lap times; and the last several lap times. 3 Press the Center button and choose Delete Log to delete the chosen log, or Clear Logs to delete all current logs. Playing Games iPod nano comes with three games: Klondike, Maze, and Vortex. To play a game: m Choose Extras > Games and choose a game. When you play a game created for previous versions of iPod nano, you’re first shown how iPod nano controls work in the game you’re about to play. You can purchase additional games from the iTunes Store (in some countries) to play on iPod nano. After purchasing games in iTunes, you can add them to iPod nano by syncing them automatically or by managing them manually. Many games can be played in portrait or landscape mode. To buy a game: 1 In iTunes, select iTunes Store in the source list. 2 Choose iPod Games from the iTunes Store list. 3 Select the game you want and click Buy Game. To sync games automatically to iPod nano: 1 In iTunes, select iPod nano in the source list and click the Games tab. 2 Select “Sync games.”Chapter 6 More Settings, Extra Features, and Accessories 57 3 Click “All games” or “Selected games.” If you click “Selected games,” also select the games you want to sync. 4 Click Apply. Locking the iPod nano Screen You can set a combination to prevent iPod nano from being used by someone without your permission. If you lock iPod nano while it isn’t connected to a computer, you must then enter a combination to unlock and use it. This combination is different from the Hold button, which just prevents iPod nano buttons from being pressed accidentally. The combination prevents another person from using iPod nano. To set a combination for iPod nano: 1 Choose Extras > Screen Lock. 2 On the New Combination screen, enter a combination:  Use the Click Wheel to select a number for the first position. Press the Center button to confirm your choice and move to the next position.  Use the same method to set the remaining numbers of the combination. You can use the Next/Fast-forward button to move to the next position and the Previous/Rewind button to move to the previous position. Press the Center button in the final position. 3 On the Confirm Combination screen, enter the combination to confirm it, or press Menu to exit without locking the screen. When you finish, you return to the Screen Lock screen, where you can lock the screen or reset the combination. Press the Menu button to exit without locking the screen. To lock the iPod nano screen: m Choose Extras > Screen Lock > Lock. If you just finished setting your combination, Lock will already be selected on the screen. Just press the Center button to lock iPod. When the screen is locked, you see a picture of a lock. You might want to add the Screen Lock menu item to the main menu so that you can quickly lock the iPod nano screen. See “Adding or Removing Items on the Main Menu” on page 11. When you see the lock on the screen, you can unlock the iPod nano screen in two ways:  Press the Center button to enter the combination on iPod nano. Use the Click Wheel to select the numbers and press the Center button to confirm them. If you enter the wrong combination, the lock remains. Try again.58 Chapter 6 More Settings, Extra Features, and Accessories  Connect iPod nano to the primary computer you use it with, and iPod nano automatically unlocks. Note: If you try these methods and you still can’t unlock iPod nano, you can restore iPod nano. See “Updating and Restoring iPod Software” on page 69. To change a combination you’ve already set: 1 Choose Extras > Screen Lock > Reset. 2 On the Enter Combination screen, enter the current combination. 3 On the New Combination screen, enter and confirm a new combination. If you can’t remember the current combination, the only way to clear it and enter a new one is to restore the iPod nano software. See “Updating and Restoring iPod Software” on page 69. Syncing Contacts, Calendars, and To-Do Lists iPod nano can store contacts, calendar events, and to-do lists for viewing on the go. You can use iTunes to sync the contact and calendar information on iPod nano with Address Book and iCal. If you’re using Windows XP, and you use Windows Address Book or Microsoft Outlook 2003 or later to store your contact information, you can use iTunes to sync the address book information on iPod nano. If you use Microsoft Outlook 2003 or later to keep a calendar, you can also sync calendar information. To sync contacts or calendar information using Mac OS X v10.4.11 or later: 1 Connect iPod nano to your computer. 2 In iTunes, select iPod nano in the source list and click the Contacts tab. 3 Do one of the following:  To sync contacts, in the Contacts section, select “Sync Address Book contacts,” and select an option:  To sync all contacts automatically, select “All contacts.”  To sync selected groups of contacts automatically, select “Selected groups” and select the groups you want to sync.  To copy contacts’ photos to iPod nano, when available, select “Include contacts’ photos.” When you click Apply, iTunes updates iPod nano with the Address Book contact information you specified.  To sync calendars, in the Calendars section, select “Sync iCal calendars,” and choose an option:  To sync all calendars automatically, choose “All calendars.”Chapter 6 More Settings, Extra Features, and Accessories 59  To sync selected calendars automatically, choose “Selected calendars” and select the calendars you want to sync. When you click Apply, iTunes updates iPod nano with the calendar information you specified. To sync contacts or calendars using Windows Address Book or Microsoft Outlook for Windows: 1 Connect iPod nano to your computer. 2 In iTunes, select iPod nano in the source list and click the Contacts tab. 3 Do one of the following:  To sync contacts, in the Contacts section, select “Sync contacts from” and choose Windows Address Book or Microsoft Outlook from the pop-up menu. Then select which contact information you want to sync.  To sync calendars from Microsoft Outlook, in the Calendars section, select “Sync calendars from Microsoft Outlook.” 4 Click Apply. You can also add contact and calendar information to iPod nano manually. iPod nano must be enabled as an external disk (see “Using iPod nano as an External Disk” on page 53). To add contact information manually: 1 Connect iPod nano and open your favorite email or contacts application. You can add contacts using Palm Desktop, Microsoft Outlook, Microsoft Entourage, and Eudora, among others. 2 Drag contacts from the application’s address book to the Contacts folder on iPod nano. In some cases, you might need to export contacts and then drag the exported file or files to the Contacts folder. See the documentation for your email or contacts application. To add appointments and other calendar events manually: 1 Export calendar events from any calendar application that uses the standard iCal format (filenames end in .ics) or vCal format (filenames end in .vcs). 2 Drag the files to the Calendars folder on iPod nano. To add to-do lists to iPod nano manually, save them in a calendar file with an .ics or .vcs extension. To view contacts on iPod nano: m Choose Extras > Contacts. To sort contacts by first or last name: m Choose Settings > General > Sort Contacts, and then select First or Last.60 Chapter 6 More Settings, Extra Features, and Accessories To view calendar events: m Choose Extras > Calendars > All Calendars, and then choose a calendar. To view to-do lists: m Choose Extras > Calendars > To Do’s. Storing and Reading Notes You can store and read text notes on iPod nano if it’s enabled as an external disk (see “Using iPod nano as an External Disk” on page 53). 1 Save a document in any word-processing application as a text (.txt) file. 2 Place the file in the Notes folder on iPod nano. To view notes: m Choose Extras > Notes. Recording Voice Memos You can record voice memos using an optional iPod nano–compatible microphone (available for purchase at www.apple.com/ipodstore). You can set chapter marks while you record, store voice memos on iPod nano and sync them with your computer, and add labels to voice memos. Voice memos cannot be longer than two hours. If you record for more than two hours, iPod nano automatically starts a new voice memo to continue your recording. To record a voice memo: 1 Connect a microphone to the Dock connector port on iPod nano. The Voice Memos item appears in the main menu. 2 To begin recording, choose Voice Memo > Start Recording. 3 Hold the microphone a few inches from your mouth and speak. To pause recording, press the Menu button. Choose Resume to continue recording. 4 When you finish, press Menu and then choose “Stop and Save.” Your saved recording is listed by date and time. To set chapter marks: m While recording, press the Center button whenever you want to set a chapter mark. During playback, you can go directly to the next chapter by pressing the Next/Forward button. Press the Previous/Rewind button once to go to the start of the current chapter, and twice to go to the start of the previous chapter.Chapter 6 More Settings, Extra Features, and Accessories 61 To label a recording: 1 Choose Voice Memos > Recordings, and then choose a saved recording. 2 Choose Label, and then choose a label for the recording. You can choose Podcast, Interview, Lecture, Idea, Meeting, or Memo. To remove a label from a recording, choose None. To play a recording: m In the main menu, choose Voice Memos and select the recording. You won’t see a Voice Memos menu item if you’ve never connected a microphone to iPod nano. To sync voice memos with your computer: Voice memos are saved in a Recordings folder on iPod in the WAV file format. If you enable iPod nano for disk use, you can drag voice memos from the folder to copy them. If iPod nano is set to sync songs automatically (see “Syncing Music Automatically” on page 28) voice memos on iPod nano are automatically synced as an album in iTunes (and removed from iPod nano) when you connect iPod nano. The new Voice Memos playlist appears in the source list. Using Spoken Menus for Accessibility iPod nano features optional spoken menus, enabling visually impaired users to browse through their iPod nano content more easily. iTunes generates spoken menus using voices that are included in your computer’s operating system or that you may have purchased from third parties. Not all voices from computer operating systems or third parties are compatible with spoken menus, and not all languages are supported. You must enable spoken menus in iTunes before you can activate them on iPod nano. To enable spoken menus in iTunes: 1 Connect iPod nano to your computer. 2 In iTunes, select iPod nano in the source list and click the Summary tab. 3 Select “Enable spoken menus for accessibility.” In Mac OS X, if you have VoiceOver turned on in Universal Access preferences, this option is selected by default. 4 Click Apply. After iPod nano syncs with iTunes, spoken menus are enabled and activated on your iPod nano. iPod nano takes longer to sync if spoken menus are being enabled.62 Chapter 6 More Settings, Extra Features, and Accessories To deactivate spoken menus on iPod nano: m Choose Settings > Spoken Menus and then choose Off. To turn spoken menus on again, choose Settings > General > Spoken Menus, and then choose On. Note: The Spoken Menus option appears in the Settings menu on iPod nano only if spoken menus have been enabled in iTunes. Learning About iPod nano Accessories iPod nano comes with some accessories, and many other accessories are available. To purchase iPod nano accessories, go to www.apple.com/ipodstore. Available accessories include:  Apple Headphones with Remote and Mic  Apple In-Ear Headphones with Remote and Mic  Nike + iPod Sport Kit  Apple Universal Dock  Apple Component AV Cable  Apple Composite AV Cable  Apple AV Connection Kit  Apple USB Power Adapter  Apple USB/FireWire Adapter  iPod In-Ear Headphones  iPod Radio Remote  World Travel Adapter Kit  iPod Socks  iPod Earphones  Third-party accessories—such as speakers, headsets, cases, car stereo adapters, power adapters, and moreChapter 6 More Settings, Extra Features, and Accessories 63 To use the earphones included with iPod nano: m Plug the earphones into the Headphones port. Then place the earbuds in your ears as shown. WARNING: Permanent hearing loss may occur if earbuds or headphones are used at high volume. You can adapt over time to a higher volume of sound that may sound normal but can be damaging to your hearing. If you experience ringing in your ears or muffled speech, stop listening and have your hearing checked. The louder the volume, the less time is required before your hearing could be affected. Hearing experts suggest that to protect your hearing:  Limit the amount of time you use earbuds or headphones at high volume.  Avoid turning up the volume to block out noisy surroundings.  Turn the volume down if you can’t hear people speaking near you. For information about setting a maximum volume limit on iPod, see “Setting the Maximum Volume Limit” on page 40. The earphones cord is adjustable.7 64 7 Tips and Troubleshooting Most problems with iPod nano can be solved quickly by following the advice in this chapter. General Suggestions Most problems with iPod nano can be solved by resetting it. First, make sure iPod nano is charged. To reset iPod nano: 1 Toggle the Hold switch on and off (slide it to HOLD and then back again). 2 Press and hold the Menu and Center buttons for at least 6 seconds, until the Apple logo appears. If iPod nano won’t turn on or respond  Make sure the Hold switch isn’t set to HOLD.  The iPod nano battery might need to be recharged. Connect iPod nano to your computer or to an Apple USB Power Adapter and let the battery recharge. Look for the lightning bolt icon on the iPod nano screen to verify that iPod nano is receiving a charge. To charge the battery, connect iPod nano to a USB 2.0 port on your computer. The 5 Rs: Reset, Retry, Restart, Reinstall, Restore Remember these five basic suggestions if you have a problem with iPod nano. Try these steps one at a time until your issue is resolved. If one of the following doesn’t help, read on for solutions to specific problems.  Reset iPod nano. See “General Suggestions,” below.  Retry with a different USB port if you cannot see iPod nano in iTunes.  Restart your computer, and make sure you have the latest software updates installed.  Reinstall iTunes software from the latest version on the web.  Restore iPod nano. See “Updating and Restoring iPod Software” on page 69.Chapter 7 Tips and Troubleshooting 65  Try the 5 Rs, one by one, until iPod nano responds. If you want to disconnect iPod nano, but you see the message “Connected” or “Sync in Progress”  If iPod nano is syncing music, wait for it to complete.  Select iPod nano in the iTunes source list and click the Eject (C) button.  If iPod nano disappears from the list of devices in the iTunes source list, but you still see the “Connected” or “Sync in Progress” message on the iPod nano screen, disconnect iPod nano.  If iPod nano doesn’t disappear from the list of devices in the iTunes source list, drag the iPod nano icon from the desktop to the Trash (if you’re using a Mac) or, if you’re using a Windows PC, eject the device in My Computer or click the Safely Remove Hardware icon in the system tray and select iPod nano. If you still see the “Connected” or “Sync in Progress” message, restart your computer and eject iPod nano again. If iPod nano isn’t playing music  Make sure the Hold switch isn’t set to HOLD.  Make sure the headphone connector is pushed in all the way.  Make sure the volume is adjusted properly. A maximum volume limit might have been set. You can change or remove it by using Settings > Volume Limit. See “Setting the Maximum Volume Limit” on page 40.  iPod nano might be paused. Try pressing the Play/Pause button.  Make sure you’re using iTunes 8.0 or later (go to www.apple.com/ipod/start). Songs purchased from the iTunes Store using earlier versions of iTunes won’t play on iPod nano until you upgrade iTunes.  If you’re using the iPod Universal Dock, make sure the iPod nano is seated firmly in the Dock and make sure all cables are connected properly. If you connect iPod nano to your computer and nothing happens  Make sure you have installed the latest iTunes software from www.apple.com/ipod/start.  Try connecting to a different USB port on your computer. Note: A USB 2.0 port is recommended to connect iPod nano. USB 1.1 is significantly slower than USB 2.0. If you have a Windows PC that doesn’t have a USB 2.0 port, in some cases you can purchase and install a USB 2.0 card. For more information, go to www.apple.com/ipod.  iPod nano might need to be reset (see page 64).  If you’re connecting iPod nano to a portable or laptop computer using the iPod Dock Connector to USB 2.0 Cable, connect the computer to a power outlet before connecting iPod nano.66 Chapter 7 Tips and Troubleshooting  Make sure you have the required computer and software. See “If you want to doublecheck the system requirements” on page 68.  Check the cable connections. Unplug the cable at both ends and make sure no foreign objects are in the USB ports. Then plug the cable back in securely. Make sure the connectors on the cables are oriented correctly. They can be inserted only one way.  Try restarting your computer.  If none of the previous suggestions solves your problems, you might need to restore iPod nano software. See “Updating and Restoring iPod Software” on page 69. If iPod nano displays a “Connect to Power” message This message may appear if iPod nano is exceptionally low on power and the battery needs to be charged before iPod nano can communicate with your computer. To charge the battery, connect iPod nano to a USB 2.0 port on your computer. Leave iPod nano connected to your computer until the message disappears and iPod nano appears in iTunes or the Finder. Depending on how depleted the battery is, you may need to charge iPod nano for up to 30 minutes before it will start up. To charge iPod nano more quickly, use the optional Apple USB Power Adapter. If iPod nano displays a “Use iTunes to restore” message  Make sure you have the latest version of iTunes on your computer (download it from www.apple.com/ipod/start).  Connect iPod nano to your computer. When iTunes opens, follow the onscreen prompts to restore iPod nano.  If restoring iPod nano doesn’t solve the problem, iPod nano may need to be repaired. You can arrange for service at the iPod Service & Support website: www.apple.com/support/ipod If songs or data sync more slowly over USB 2.0  If you sync a large number of songs or amount of data using USB 2.0 and the iPod nano battery is low, iPod nano syncs the information at a reduced speed in order to conserve battery power.  If you want to sync at higher speeds, you can stop syncing and keep the iPod nano connected so that it can recharge, or connect it to the optional iPod USB 2.0 Power Adapter. Let iPod nano charge for about an hour, and then resume syncing your music or data. If you can’t add a song or other item to iPod nano The song may have been encoded in a format that iPod nano doesn’t support. The following audio file formats are supported by iPod nano. These include formats for audiobooks and podcasting:  AAC (M4A, M4B, M4P, up to 320 Kbps)Chapter 7 Tips and Troubleshooting 67  Apple Lossless (a high-quality compressed format)  MP3 (up to 320 Kbps)  MP3 Variable Bit Rate (VBR)  WAV  AA (audible.com spoken word, formats 2, 3, and 4)  AIFF A song encoded using Apple Lossless format has full CD-quality sound, but takes up only about half as much space as a song encoded using AIFF or WAV format. The same song encoded in AAC or MP3 format takes up even less space. When you import music from a CD using iTunes, it’s converted to AAC format by default. Using iTunes for Windows, you can convert nonprotected WMA files to AAC or MP3 format. This can be useful if you have a library of music encoded in WMA format. iPod nano doesn’t support WMA, MPEG Layer 1, MPEG Layer 2 audio files, or audible.com format 1. If you have a song in iTunes that isn’t supported by iPod nano, you can convert it to a format iPod nano supports. For more information, see iTunes Help. If iPod nano displays a “Connect to iTunes to activate Genius” message: You haven’t activated Genius in iTunes, or you haven’t synced iPod nano since you activated Genius in iTunes. See “Using Genius in iTunes” on page 25. If iPod nano displays a “Genius is not available for the selected song” message: Genius is activated but doesn’t recognize the song you selected to start a Genius playlist. New songs are added to the iTunes Store Genius database all the time, so try again soon. If you accidentally set iPod nano to use a language you don’t understand You can reset the language. 1 Press and hold Menu until the main menu appears. 2 Choose the sixth menu item (Settings). 3 Choose the last menu item (Reset Settings). 4 Choose the first item (Reset) and select a language. Other iPod nano settings, such as song repeat, are also reset. Note: If you added or removed items from the iPod nano main menu (see “Adding or Removing Items on the Main Menu” on page 11) the Settings menu item may be in a different place. If you can’t find the Reset Settings menu item, you can restore iPod nano to its original state and choose a language. See “Updating and Restoring iPod Software” on page 69.68 Chapter 7 Tips and Troubleshooting If you can’t see videos or photos on your TV  You must use RCA-type cables made specifically for iPod nano, such as the Apple Component or Apple Composite AV cables, to connect iPod nano to your TV. Other similar RCA-type cables won’t work.  Make sure your TV is set to display images from the correct input source (see the documentation that came with your TV for more information).  Make sure all cables are connected correctly (see “Watching Videos on a TV Connected to iPod nano” on page 45).  Make sure the yellow end of the Apple Composite AV Cable is connected to the video port on your TV.  If you’re trying to view a video, choose Videos > Settings and set TV Out to On, and then try again. If you’re trying to view a slideshow, choose Photos > Slideshow Settings and set TV Out to On, and then try again.  If that doesn’t work, choose Videos > Settings (for video) or Photos > Settings (for a slideshow) and set TV Signal to PAL or NTSC, depending on which type of TV you have. Try both settings. If you want to double-check the system requirements To use iPod nano, you must have:  One of the following computer configurations:  A Mac with a USB 2.0 port  A Windows PC with a USB 2.0 or a USB 2.0 card installed  One of the following operating systems:  Mac OS X v10.4.11 or later  Windows Vista  Windows XP Home or Professional with Service Pack 3 or later  iTunes 8.0 or later (iTunes can be downloaded from www.apple.com/ipod/start) If your Windows PC doesn’t have a USB 2.0 port, you can purchase and install a USB 2.0 card. For more information about cables and compatible USB cards, go to www.apple.com/ipod. On the Mac, iPhoto 6 or later is recommended for adding photos and albums to iPod nano. This software is optional. iPhoto might already be installed on your Mac. Check the Applications folder. On a Windows PC, iPod nano can sync photo collections automatically from Adobe Photoshop Album 2.0 or later, and Adobe Photoshop Elements 4.0 or later, available at www.adobe.com. This software is optional. On both Mac and Windows PC, iPod nano can sync digital photos from folders on your computer’s hard disk.Chapter 7 Tips and Troubleshooting 69 If you want to use iPod nano with a Mac and a Windows PC If you’re using iPod nano with a Mac and you want to use it with a Windows PC, you must restore the iPod software for use with the PC (see “Updating and Restoring iPod Software” on page 69). Restoring the iPod software erases all data from iPod nano, including all songs. You cannot switch from using iPod nano with a Mac to using it with a Windows PC without erasing all data on iPod nano. If you lock the iPod nano screen and can’t unlock it Normally, if you can connect iPod nano to the computer it’s authorized to work with, iPod nano automatically unlocks. If the computer authorized to work with iPod nano is unavailable, you can connect iPod nano to another computer and use iTunes to restore iPod software. See the next section for more information. If you want to change the screen lock combination and you can’t remember the current combination, you must restore the iPod software and then set a new combination. Updating and Restoring iPod Software You can use iTunes to update or restore iPod software. It’s recommended that you update iPod nano to use the latest software. You can also restore the software, which puts iPod nano back to its original state.  If you choose to update, the software is updated, but your settings and songs aren’t affected.  If you choose to restore, all data is erased from iPod nano, including songs, videos, files, contacts, photos, calendar information, and any other data. All iPod nano settings are restored to their original state. To update or restore iPod nano: 1 Make sure you have an Internet connection and have installed the latest version of iTunes from www.apple.com/ipod/start. 2 Connect iPod nano to your computer. 3 In iTunes, select iPod nano in the source list and click the Summary tab. The Version section tells you whether iPod nano is up to date or needs a newer version of the software. 4 Click Update to install the latest version of the software. 5 If necessary, click Restore to restore iPod nano to its original settings (this erases all data from iPod nano). Follow the onscreen instructions to complete the restore process.8 70 8 Safety and Cleaning Read the following important safety and handling information for Apple iPods. Keep the iPod Safety Guide and the features guide for your iPod handy for future reference. Important Safety Information Handling iPod Do not bend, drop, crush, puncture, incinerate, or open iPod. Avoiding water and wet locations Do not use iPod in rain, or near washbasins or other wet locations. Take care not to spill any food or liquid into iPod. In case iPod gets wet, unplug all cables, turn iPod off, and slide the Hold switch (if available) to HOLD before cleaning, and allow it to dry thoroughly before turning it on again. Repairing iPod Never attempt to repair iPod yourself. iPod does not contain any userserviceable parts. For service information, choose iPod Help from the Help menu in iTunes or go to www.apple.com/support/ipod. The rechargeable battery in iPod should be replaced only by an Apple Authorized Service Provider. For more information about batteries, go to www.apple.com/batteries. ± Read all safety information below and operating instructions before using iPod to avoid injury. WARNING: Failure to follow these safety instructions could result in fire, electric shock, or other injury or damage.Chapter 8 Safety and Cleaning 71 Using the Apple USB Power Adapter (available separately) If you use the Apple USB Power Adapter (sold separately at www.apple.com/ipodstore) to charge iPod, make sure that the power adapter is fully assembled before you plug it into a power outlet. Then insert the Apple USB Power Adapter firmly into the power outlet. Do not connect or disconnect the Apple USB Power Adapter with wet hands. Do not use any power adapter other than an Apple iPod power adapter to charge your iPod. The iPod USB Power Adapter may become warm during normal use. Always allow adequate ventilation around the iPod USB Power Adapter and use care when handling. Unplug the iPod USB Power Adapter if any of the following conditions exist:  The power cord or plug has become frayed or damaged.  The adapter is exposed to rain, liquids, or excessive moisture.  The adapter case has become damaged.  You suspect the adapter needs service or repair.  You want to clean the adapter. Avoiding hearing damage Permanent hearing loss may occur if earbuds or headphones are used at high volume. Set the volume to a safe level. You can adapt over time to a higher volume of sound that may sound normal but can be damaging to your hearing. If you experience ringing in your ears or muffled speech, stop listening and have your hearing checked. The louder the volume, the less time is required before your hearing could be affected. Hearing experts suggest that to protect your hearing:  Limit the amount of time you use earbuds or headphones at high volume.  Avoid turning up the volume to block out noisy surroundings.  Turn the volume down if you can’t hear people speaking near you. For information about how to set a maximum volume limit on iPod, see “Setting the Maximum Volume Limit” on page 40. Using headphones safely Use of headphones while operating a vehicle is not recommended and is illegal in some areas. Be careful and attentive while driving. Stop using iPod if you find it disruptive or distracting while operating any type of vehicle or performing any other activity that requires your full attention. Avoiding seizures, blackouts, and eye strain If you have experienced seizures or blackouts, or if you have a family history of such occurrences, please consult a physician before playing video games on iPod (if available). Discontinue use and consult a physician if you experience: convulsion, eye or muscle twitching, loss of awareness, involuntary movements, or disorientation. When watching videos or playing games on iPod (if available), avoid prolonged use and take breaks to prevent eye strain.72 Chapter 8 Safety and Cleaning Important Handling Information Carrying iPod iPod contains sensitive components, including, in some cases, a hard drive. Do not bend, drop, or crush iPod. If you are concerned about scratching iPod, you can use one of the many cases sold separately. Using connectors and ports Never force a connector into a port. Check for obstructions on the port. If the connector and port don’t join with reasonable ease, they probably don’t match. Make sure that the connector matches the port and that you have positioned the connector correctly in relation to the port. Keeping iPod within acceptable temperatures Operate iPod in a place where the temperature is always between 0º and 35º C (32º to 95º F). iPod play time might temporarily shorten in low-temperature conditions. Store iPod in a place where the temperature is always between -20º and 45º C (-4º to 113º F). Don’t leave iPod in your car, because temperatures in parked cars can exceed this range. When you’re using iPod or charging the battery, it is normal for iPod to get warm. The exterior of iPod functions as a cooling surface that transfers heat from inside the unit to the cooler air outside. Keeping the outside of iPod clean To clean iPod, unplug all cables, turn iPod off, and slide the Hold switch (if available) to HOLD. Then use a soft, slightly damp, lint-free cloth. Avoid getting moisture in openings. Don’t use window cleaners, household cleaners, aerosol sprays, solvents, alcohol, ammonia, or abrasives to clean iPod. Disposing of iPod properly For information about the proper disposal of iPod, including other important regulatory compliance information, see “Regulatory Compliance Information” on page 74. NOTICE: Failure to follow these handling instructions could result in damage to iPod or other property.9 73 9 Learning More, Service, and Support You can find more information about using iPod nano in onscreen help and on the web. The following table describes where to get more iPod-related software and service information. To learn about Do this Service and support, discussions, tutorials, and Apple software downloads Go to: www.apple.com/support/ipodnano Using iTunes Open iTunes and choose Help > iTunes Help. For an online iTunes tutorial (available in some areas only), go to: www.apple.com/support/itunes Using iPhoto (on Mac OS X) Open iPhoto and choose Help > iPhoto Help. Using iCal (on Mac OS X) Open iCal and choose Help > iCal Help. The latest information on iPod nano Go to: www.apple.com/ipodnano Registering iPod nano To register iPod nano, install iTunes on your computer and connect iPod nano. Finding the iPod nano serial number Look at the back of iPod nano or choose Settings > About and press the Center button. In iTunes (with iPod nano connected to your computer), select iPod nano in the source list and click the Settings tab. Obtaining warranty service First follow the advice in this booklet, the onscreen help, and online resources. Then go to: www.apple.com/support/ipodnano/ service74 Regulatory Compliance Information FCC Compliance Statement This device complies with part 15 of the FCC rules. Operation is subject to the following two conditions: (1) This device may not cause harmful interference, and (2) this device must accept any interference received, including interference that may cause undesired operation. See instructions if interference to radio or TV reception is suspected. Radio and TV Interference This computer equipment generates, uses, and can radiate radio-frequency energy. If it is not installed and used properly—that is, in strict accordance with Apple’s instructions—it may cause interference with radio and TV reception. This equipment has been tested and found to comply with the limits for a Class B digital device in accordance with the specifications in Part 15 of FCC rules. These specifications are designed to provide reasonable protection against such interference in a residential installation. However, there is no guarantee that interference will not occur in a particular installation. You can determine whether your computer system is causing interference by turning it off. If the interference stops, it was probably caused by the computer or one of the peripheral devices. If your computer system does cause interference to radio or TV reception, try to correct the interference by using one or more of the following measures:  Turn the TV or radio antenna until the interference stops.  Move the computer to one side or the other of the TV or radio.  Move the computer farther away from the TV or radio.  Plug the computer in to an outlet that is on a different circuit from the TV or radio. (That is, make certain the computer and the TV or radio are on circuits controlled by different circuit breakers or fuses.) If necessary, consult an Apple Authorized Service Provider or Apple. See the service and support information that came with your Apple product. Or, consult an experienced radio/TV technician for additional suggestions. Important: Changes or modifications to this product not authorized by Apple Inc. could void the EMC compliance and negate your authority to operate the product. This product was tested for EMC compliance under conditions that included the use of Apple peripheral devices and Apple shielded cables and connectors between system components. It is important that you use Apple peripheral devices and shielded cables and connectors between system components to reduce the possibility of causing interference to radios, TV sets, and other electronic devices. You can obtain Apple peripheral devices and the proper shielded cables and connectors through an Apple Authorized Reseller. For non-Apple peripheral devices, contact the manufacturer or dealer for assistance. Responsible party (contact for FCC matters only): Apple Inc. Corporate Compliance 1Infinite Loop, M/S 26-A Cupertino, CA 95014-2084 Industry Canada Statement This Class B device meets all requirements of the Canadian interference-causing equipment regulations. Cet appareil numérique de la classe B respecte toutes les exigences du Règlement sur le matériel brouilleur du Canada. VCCI Class B Statement Korea Class B Statement (૶ ૺૺဧ ઠધබ 75 Russia European Community Battery Replacement The rechargeable battery in iPod nano should be replaced only by an authorized service provider. For battery replacement services go to: www.apple.com/support/ipod/service/battery Disposal and Recycling Information Your iPod must be disposed of properly according to local laws and regulations. Because this product contains a battery, the product must be disposed of separately from household waste. When your iPod reaches its end of life, contact Apple or your local authorities to learn about recycling options. For information about Apple’s recycling program, go to: www.apple.com/environment/recycling Deutschland: Dieses Gerät enthält Batterien. Bitte nicht in den Hausmüll werfen. Entsorgen Sie dieses Gerätes am Ende seines Lebenszyklus entsprechend der maßgeblichen gesetzlichen Regelungen. Nederlands: Gebruikte batterijen kunnen worden ingeleverd bij de chemokar of in een speciale batterijcontainer voor klein chemisch afval (kca) worden gedeponeerd. China: Taiwan: European Union—Disposal Information: This symbol means that according to local laws and regulations your product should be disposed of separately from household waste. When this product reaches its end of life, take it to a collection point designated by local authorities. Some collection points accept products for free. The separate collection and recycling of your product at the time of disposal will help conserve natural resources and ensure that it is recycled in a manner that protects human health and the environment. Apple and the Environment At Apple, we recognize our responsibility to minimize the environmental impacts of our operations and products. For more information, go to: www.apple.com/environment © 2008 Apple Inc. All rights reserved. Apple, the Apple logo, FireWire, iCal, iLife, iPhoto, iPod, iPod Socks, iTunes, Mac, Macintosh, and Mac OS are trademarks of Apple Inc., registered in the U.S. and other countries. Finder, the FireWire logo, and Shuffle are trademarks of Apple Inc. iTunes Store is a service mark of Apple Inc., registered in the U.S. and other countries. NIKE is a trademark of NIKE, Inc. and its affiliates and is used under license. Other company and product names mentioned herein may be trademarks of their respective companies. Mention of third-party products is for informational purposes only and constitutes neither an endorsement nor a recommendation. Apple assumes no responsibility with regard to the performance or use of these products. All understandings, agreements, or warranties, if any, take place directly between the vendors and the prospective users. Every effort has been made to ensure that the information in this manual is accurate. Apple is not responsible for printing or clerical errors. The product described in this manual incorporates copyright protection technology that is protected by method claims of certain U.S. patents and other intellectual property rights owned by Macrovision Corporation and other rights owners. Use of this copyright protection technology must be authorized by Macrovision Corporation and is intended for home and other limited viewing uses only unless otherwise authorized by Macrovision Corporation. Reverse engineering or disassembly is prohibited. Apparatus Claims of U.S. Patent Nos. 4,631,603, 4,577,216, 4,819,098 and 4,907,093 licensed for limited viewing uses only. 019-1343/2008-09Index 76 Index A accessing additional options 8 accessories for iPod 62 adding album artwork 24 adding menu items 11, 40 adding music disconnecting iPod 15 from more than one computer 28, 31 manually 29 methods 27 On-The-Go playlists 37 tutorial 73 adding photos about 47 all or selected photos 48, 49 automatically 48 from computer to iPod 48 from iPod to computer 50 full-resolution image 49 address book, syncing 58 Adobe Photoshop Album 68 Adobe Photoshop Elements 68 alarms deleting 55 setting 55 album, browsing by 36 album artwork adding 24 viewing 36 albums, purchasing 22 artist, browsing by 37 audiobooks purchasing 22 setting play speed 43 AV cables 45, 46, 52 B backlight setting timer 12 turning on 7, 12 battery charge states when disconnected 19 charging 17 Energy Saver 19 improving performance 19 rechargeable 19 replacing 19 very low 66 viewing charge status 17 brightness setting 12 browsing by album 36 by artist 37 iTunes Store 21 podcasts 22 quickly 9, 10 songs 7, 34 videos 7 with Cover Flow 9 buttons Center 7 disabling with Hold switch 7 Eject 16 buying. See purchasing C calendar events, syncing 58 Center button, using 7, 34 Charging, Please Wait message 66 charging the battery about 17 using the iPod USB Power Adapter 18 using your computer 17 when battery very low 66 cleaning iPod 72 Click Wheel browsing songs 34 turning off the Click Wheel sound 13 using 7 clocks adding for other time zones 54 settings 54 close captions 46 compilations 40 component AV cable 45, 46, 52Index 77 composite AV cable 45, 46, 52 computer adding photos to iPod 48 charging the battery 17 connecting iPod 14 getting photos from iPod 50 importing photos from camera 47 problems connecting iPod 65 requirements 68 connecting iPod about 14 charging the battery 17 to a TV 46, 52 contacts sorting 59 syncing 58 controls disabling with Hold switch 13 using 7 converting unprotected WMA files 67 converting videos for use with iPod 27 Cover Flow 9 customizing the Music menu 40 D data files, storing on iPod 53 date and time setting 54 viewing 54 determining battery charge 19 diamond icon on scrubber bar 8 digital photos. See photos disconnecting iPod about 14 during music update 15 ejecting first 15 instructions 16 troubleshooting 65 disk, using iPod as 53 displaying time in title bar 54 downloading podcasts 22 video podcasts 26 See also adding; syncing E Eject button 16 ejecting before disconnecting 15 Energy Saver 19 external disk, using iPod as 53 F fast-forwarding a song or video 8 file formats, supported 66 finding your iPod serial number 8 fit video to screen 45 font size, setting 12 full-resolution images 49 G games 56 Genius 8, 25, 38 creating a playlist 8, 38 playing a playlist 8, 38 saving a playlist 8, 38 using in iTunes 25 using on iPod nano 38 getting help 73 getting information about your iPod 13 getting started with iPod 68 H handling information 70 hearing loss warning 63 help, getting 73 Hold switch 7, 13 I iCal, getting help 73 Image Capture, importing photos to a Mac 48 images. See photos importing contacts, calendars, and to-do lists. See syncing importing photos from camera to computer 47 See also adding photos importing videos 27 iPhoto getting help 47, 73 importing photos from camera 47 recommended version 68 iPod Dock 14 iPod Dock Connector 14 iPod Updater application 69 iPod USB power adapter 17 iTunes ejecting iPod 16 getting help 73 setting not to open automatically 53 Sound Check 42 Store 21 iTunes Library, adding songs 22 iTunes Store browsing 21 browsing videos 26 searching 22 signing in 21 L language78 Index resetting 67 specifying 12 letterbox 45 library, adding songs 22 lightning bolt on battery icon 17 locating your iPod serial number 8 locking iPod screen 57 lyrics adding 24 viewing on iPod 35 M Mac OS X operating system 68 main menu adding or removing items 11 opening 7 settings 11, 40 main menu, returning to 7 managing iPod manually 29 manually adding 29 maximum volume limit, setting 40 memos, recording 60 menu items adding or removing 11, 40 choosing 7 returning to main menu 7 returning to previous menu 7 modifying playlists 29 movies syncing 33 syncing selected 32 See also videos music iPod not playing 65 purchasing 22 rating 35 setting for slideshows 51 tutorial 73 See also adding music; songs Music menu, customizing 40 music videos syncing 29 See also videos N navigating quickly 10 notes, storing and reading 60 Now Playing screen moving to any point in a song or video 8 scrubber bar 8 NTSC TV 45, 52 O On-The-Go playlists copying to computer 37 making 37, 38 rating songs 35 saving 37 operating system requirements 68 P PAL TV 45, 52 pausing a song 7 a video 7 phone numbers, syncing 58 photo collections, adding automatically 48 photo library 48 photos adding and viewing 47 deleting 49, 50 full-resolution 49 importing to Windows PC 48 importing using Image Capture 48 syncing 48, 49 viewing on iPod 50 playing games 56 songs 7 videos 7 playlists adding songs 8, 29 making on iPod 37, 38 modifying 29 On-The-Go 37, 38 setting for slideshows 52 plug on battery icon 17 podcasting 42 podcasts browsing 22 downloading 22 downloading video podcasts 26 listening 42 subscribing 22 updating 30 ports RCA video and audio 46, 52 USB 68 power adapter safety 71 Power Search in iTunes Store 22 previous menu, returning to 7 problems. See troubleshooting purchasing songs, albums, audiobooks 22 purchasing videos 26 Q quick navigation 10 R radio accessory 43Index 79 random play 8 rating songs 35 RCA video and audio ports 46, 52 rechargeable batteries 19 recording voice memos 60 registering iPod 73 relative volume, playing songs at 42 removing menu items 11, 40 repairing iPod 70 replacing battery 19 replaying a song or video 8 requirements computer 68 operating system 68 reset all settings 13 resetting iPod 7, 64 resetting the language 67 restore message 66 restoring iPod software 69 rewinding a song or video 8 S Safely Remove Hardware icon 16 safety considerations setting up iPod 70 safety information 70 saving On-The-Go playlists 37 screen lock 57 scrolling quickly 10 scrubber bar 8 searching iPod 10 iTunes Store 22 Select button. See Center button serial number 8, 13 serial number, locating 73 service and support 73 sets of songs. See playlists setting combination for iPod 57 settings about your iPod 13 alarm 55 audiobook play speed 43 backlight timer 12 brightness 12 Click Wheel sound 13 date and time 54 language 12 main menu 11, 40 PAL or NTSC TV 45, 52 playing songs at relative volume 42 repeating songs 40 reset all 13 shuffle songs 39 sleep timer 55 slideshow 51 TV 45 volume limit 40 shuffling songs on iPod 8, 39 sleep mode and charging the battery 17 sleep timer, setting 55 slideshows background music 51 random order 51 setting playlist 52 settings 51 viewing on iPod 52 software getting help 73 iPhoto 68 iPod Updater 69 support versions 68 updating 69 songs adding to On-The-Go playlists 8 browsing 7 browsing and playing 34 entering names 23 fast-forwarding 8 pausing 7 playing 7 playing at relative volume 42 purchasing 22 rating 35 repeating 40 replaying 8 rewinding 8 shuffling 8, 39 skipping ahead 8 viewing lyrics 24 See also music sorting contacts 59 Sound Check 42 spoken menus 61 standard TV 45 stopwatch 55, 56 storing data files on iPod 53 notes on iPod 60 subscribing to podcasts 22 supported operating systems 68 suppressing iTunes from opening 53 syncing address book 58 movies 33 music 27 music videos 29 photos 48, 49 selected movies 32 selected videos 32 to-do lists 5880 Index TV shows 33 videos 31 See also adding T third-party accessories 62 time, displaying in title bar 54 timer, setting for backlight 12 time zones, clocks for 54 title bar, displaying time 54 to-do lists, syncing 58 transitions for slides 51 troubleshooting connecting iPod to computer 65 cross-platform use 69 disconnecting iPod 65 iPod not playing music 65 iPod won’t respond 64 resetting iPod 64 restore message 66 safety considerations 70 setting incorrect language 67 slow syncing of music or data 66 software update and restore 69 TV slideshows 68 unlocking iPod screen 69 turning iPod on and off 7 tutorial 73 TV connecting to iPod 46, 52 PAL or NTSC 45, 52 settings 45 viewing slideshows 46, 52 TV shows syncing 33 See also videos U unlocking iPod screen 57, 69 unresponsive iPod 64 unsupported audio file formats 67 updating and restoring software 69 USB 2.0 port recommendation 68 slow syncing of music or data 66 USB port on keyboard 14 Use iTunes to restore message in display 66 V video captions 46 video podcasts downloading 26 viewing on a TV 45 videos adding to iPod 31 browsing 7 browsing in iTunes Store 26 converting 27 fast-forwarding 8 importing into iTunes 27 pausing 7 playing 7 purchasing 26 replaying 8 rewinding 8 skipping ahead 8 syncing 31 viewing on a TV 45 viewing on iPod 44 viewing album artwork 36 viewing lyrics 35 viewing photos 50 viewing slideshows on a TV 46, 52 on iPod 52 settings 51 troubleshooting 68 voice memos recording 60 syncing with your computer 60 volume changing 7 setting maximum limit 40 W warranty service 73 widescreen TV 45 Windows importing photos 48 supported operating systems 68 troubleshooting 69 WMA files, converting 67 Safari Web Content GuideContents Developing Web Content for Safari 9 At a Glance 9 Making It Work 9 Enhancing the User Experience 10 How to Use This Document 11 Prerequisites 11 See Also 11 Introduction 13 Who Should Read This Document 14 Organization of This Document 14 See Also 15 Creating Compatible Web Content 18 Use Standards 18 Follow Good Web Design Practices 19 Use Security Features 20 Avoid Framesets 20 Use Columns and Blocks 21 Know iOS Resource Limits 23 Checking the Size of Webpages 24 Use the Select Element 25 Use Supported JavaScript Windows and Dialogs 25 Use Supported Content Types and iOS Features 26 Use Canvas for Vector Graphics and Animation 29 Use the HTML5 Audio and Video Elements 29 Use Supported iOS Rich Media MIME Types 29 Don’t Use Unsupported iOS Technologies 30 Optimizing Web Content 33 Using Conditional CSS 33 Using the Safari User Agent String 36 Configuring the Viewport 38 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 2Layout and Metrics on iPhone and iPod touch 39 What Is the Viewport? 39 Safari on the Desktop Viewport 41 Safari on iOS Viewport 41 Examples of Viewports on iOS 42 Default Viewport Settings 46 Using the Viewport Meta Tag 46 Changing the Viewport Width and Height 47 How Safari Infers the Width, Height, and Initial Scale 50 Viewport Settings for Web Applications 55 Customizing Style Sheets 58 Leveraging CSS3 Properties 58 Adjusting the Text Size 58 Highlighting Elements 60 Designing Forms 62 Laying Out Forms 62 Customizing Form Controls 64 Configuring Automatic Correction and Capitalization 66 Handling Events 68 One-Finger Events 69 Two-Finger Events 72 Form and Document Events 73 Making Elements Clickable 73 Handling Multi-Touch Events 74 Handling Gesture Events 77 Preventing Default Behavior 79 Handling Orientation Events 79 Supported Events 81 Promoting Apps with Smart App Banners 84 Implementing a Smart App Banner on Your Website 85 Providing Navigational Context to Your App 85 Configuring Web Applications 87 Specifying a Webpage Icon for Web Clip 87 Specifying a Startup Image 89 Hiding Safari User Interface Components 89 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 3 ContentsChanging the Status Bar Appearance 89 Creating Video 91 Sizing Movies Appropriately 92 Don’t Let the Bit Rate Stall Your Movie 92 Using Supported Movie Standards 92 Encoding Video for Wi-Fi, 3G, and EDGE 93 Creating a Reference Movie 94 Creating a Poster Image for Movies 94 Configuring Your Server 95 Storing Data on the Client 97 Creating a Manifest File 97 Declaring a Manifest File 98 Updating the Cache 98 Handling Cache Events 99 Getting Geographic Locations 101 Geographic Location Classes 101 Getting the Current Location 101 Tracking the Current Location 102 Handling Location Errors 103 Debugging 104 Enabling Web Inspector on iOS 104 Inspecting From Your Mac 106 Inspecting Content in a Web View 107 Using JavaScript to Interact with Your Device 108 HTML Basics 110 What Is HTML? 110 Basic HTML Structure 110 Creating Effective HTML Content 112 Using Other HTML Features 115 CSS Basics 117 What Is CSS? 117 Inline CSS 117 Head-Embedded CSS 118 External CSS 120 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 4 ContentsDocument Revision History 122 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 5 ContentsFigures, Tables, and Listings Creating Compatible Web Content 18 Figure 1-1 Comparison of frameset on the desktop and iOS 21 Figure 1-2 Comparison of no columns vs. columns 22 Figure 1-3 Comparison of the select element on the desktop and iOS 25 Figure 1-4 Confirm dialog 26 Figure 1-5 Playing video on iOS 27 Figure 1-6 Viewing PDF documents on iOS 28 Table 1-1 Supported iOS rich media MIME types 29 Optimizing Web Content 33 Figure 2-1 Small device rendering 34 Figure 2-2 Desktop rendering 34 Listing 2-1 Screen-specific style sheet 35 Listing 2-2 Print-specific style sheet 35 Listing 2-3 iPhone running on iOS 2.0 user agent string 36 Listing 2-4 iPod touch running iOS 1.1.3 user agent string 37 Listing 2-5 iPad running iOS 3.2 user agent string 37 Listing 2-6 iPhone running iOS 1.0 user agent string 37 Configuring the Viewport 38 Figure 3-1 Layout and metrics in portrait orientation 39 Figure 3-2 Differences between Safari on iOS and Safari on the desktop 40 Figure 3-3 Safari on desktop viewport 41 Figure 3-4 Viewport with default settings 42 Figure 3-5 Viewport with width set to 320 43 Figure 3-6 Viewport with width set to 320 and scale set to 150% 44 Figure 3-7 Viewport with width set to 320 and scale set to 50% 45 Figure 3-8 Viewport with arbitrary user scale 45 Figure 3-9 Default settings work well for most webpages 46 Figure 3-10 Comparison of 320 and 980 viewport widths 48 Figure 3-11 Webpage is too narrow for default settings 49 Figure 3-12 Web application page is too small for default settings 50 Figure 3-13 Default width and initial scale 51 Figure 3-14 Default width with initial scale set to 1.0 52 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 6Figure 3-15 Width set to 320 with default initial scale 53 Figure 3-16 Width set to 200 with default initial scale 54 Figure 3-17 Width set to 980 and initial scale set to 1.0 55 Figure 3-18 Not specifying viewport properties 56 Figure 3-19 Width set to device-width pixels 57 Customizing Style Sheets 58 Figure 4-1 Comparison of text adjustment settings 59 Figure 4-2 Differences between default and custom highlighting 61 Listing 4-1 Setting the text size adjustment property 60 Listing 4-2 Changing the tap highlight color 60 Designing Forms 62 Figure 5-1 Form metrics when the keyboard is displayed 63 Figure 5-2 A custom checkbox 64 Figure 5-3 A custom text field 65 Figure 5-4 A custom select element 66 Table 5-1 Form metrics 63 Listing 5-1 Creating a custom checkbox with CSS 64 Listing 5-2 Creating a custom text field with CSS 65 Listing 5-3 Creating a custom select control with CSS 66 Handling Events 68 Figure 6-1 The panning gesture 69 Figure 6-2 The touch and hold gesture 70 Figure 6-3 The double-tap gesture 71 Figure 6-4 One-finger gesture emulating a mouse 72 Figure 6-5 The pinch open gesture 72 Figure 6-6 Two-finger panning gesture 73 Table 6-1 Types of events 82 Listing 6-1 A menu using a mouseover handler 73 Listing 6-2 Adding an onclick handler 74 Listing 6-3 Displaying the orientation 80 Promoting Apps with Smart App Banners 84 Figure 7-1 A Smart App Banner of the Apple Store app 84 Listing 7-1 Routing the user to the correct view controller 86 Creating Video 91 Figure 9-1 Export movie panel 93 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 7 Figures, Tables, and ListingsFigure 9-2 Reference movie components 94 Table 9-1 File name extensions for MIME types 95 Storing Data on the Client 97 Listing 10-1 Sample manifest file 98 Debugging 104 Figure 12-1 The Develop menu 106 Figure 12-2 Web Inspector 106 Figure 12-3 Observing the value of document.title in the debug console 108 Figure 12-4 Alert dialog triggered from the debug console 109 HTML Basics 110 Listing A-1 Basic HTML document 110 Listing A-2 Adding a paragraph 113 Listing A-3 Adding a heading 113 Listing A-4 Creating a hyperlink 113 Listing A-5 Adding an image 114 Listing A-6 Creating a table 115 CSS Basics 117 Listing B-1 The styles.css file 120 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 8 Figures, Tables, and ListingsSafari is a full-featured Web browser for Mac OS, Windows, and iOS. You don't need to add any Safari-specific tweaks to make your website work with Safari or to make your website work on iOS-based devices. If you design your website using W3C standardsfor HTML, CSS, and JavaScript, and don't rely on third-party plug-ins, users can view and interact with your website using Safari on all supported platforms. Making websites work with Safari is just a first step, however. It should be your goal to optimize websites to create the best experience for all users, including people using Safari on handheld devices with touch screens. Use CSS to change the layout of your website in portrait or landscape modes, for example; add touch and gesture support; animate changes in CSS properties for Safari users, and so on. At a Glance There are three main areas to focus on when creating web content for Safari: ● Make sure your website is compatible with Safari. ● Enhance the user experience in Safari, particularly on mobile devices. ● Make the best use of dynamically changing network bandwidth when delivering audio and video. Making It Work Safari has an array of built-in tools for quickly spotting incompatibilities and debugging problems. If you have a website up and running, and are getting complaintsthat the site doesn't work with Safari, it is usually because of one of the following problems: ● The site uses Internet Explorer extensions that other browsers don't support. ● The site includes media compressed in a format that Safari doesn't support. ● The site relies on plug-ins to handle audio, video, or animation. Use the Error Console to immediately identify and locate any unsupported HTML, CSS, or JavaScript, making it easy to correct. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 9 Developing Web Content for SafariThere are Safari-compatible media formats and embedding techniques for every job. Safari supports audio media in AAC, MP3, AIFF, and WAVE formats on all platforms. Safari supports video media encoded using H.264 compression, commonly used in MPEG-4 format, on all platforms. Handheld devicessupport a somewhat more limited set of MPEG-4 profiles than desktop devices. Safari on the desktop supports plug-ins. There are Safari-compatible versions of all common plug-ins, including QuickTime, Flash, and SilverLight. Safari on iOS does not support plug-ins. To make your website accessible using handheld devices, do not rely on plug-ins to display content. Use the HTML5

,
    ,
      , and ) or image element. If the found element is a block, Safari on iOS zooms the content to fit the screen width and then centers it. If it is an image, Safari on iOS zooms to fit the image and then centers it. If the block or image is already zoomed in, Safari on iOS zooms out. Your webpage works well with double-tapping if you use columns and blocks. Read “CSS Basics” (page 117) for how to add CSS to existing HTML. Creating Compatible Web Content Use Columns and Blocks 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 22Know iOS Resource Limits Your webpage performing well on the desktop is no guarantee that it will perform well on iOS. Keep in mind that iOS uses EDGE (lower bandwidth, higher latency), 3G (higher bandwidth, higher latency), and Wi-Fi (higher bandwidth, lower latency) to connect to the Internet. Therefore, you need to minimize the size of your webpage. Including unused or unnecessary images, CSS, and JavaScript in your webpages adversely affects your site’s performance on iOS. Because of the memory available on iOS, there are limits on the number of resources it can process: ● The maximum size for decoded GIF, PNG, and TIFF images is 3 megapixels for devices with less than 256 MB RAM and 5 megapixels for devices with greater or equal than 256 MB RAM. That is, ensure that width * height ≤ 3 * 1024 * 1024 for devices with less than 256 MB RAM. Note that the decoded size is far larger than the encoded size of an image. ● The maximum decoded image size for JPEG is 32 megapixels using subsampling. JPEG images can be up to 32 megapixels due to subsampling, which allows JPEG images to decode to a size that has one sixteenth the number of pixels. JPEG images larger than 2 megapixels are subsampled—that is, decoded to a reduced size. JPEG subsampling allows the user to view images from the latest digital cameras. ● The maximum size for a canvas element is 3 megapixels for devices with less than 256 MB RAM and 5 megapixels for devices with greater or equal than 256 MB RAM. The height and width of a canvas object is 150 x 300 pixels if not specified. ● JavaScript execution time is limited to 10 seconds for each top-level entry point. If your script executes for more than 10 seconds, Safari on iOS stops executing the script at a random place in your code, so unintended consequences may result. This limit is imposed because JavaScript execution may cause the main thread to block, so when scripts are running, the user is not able to interact with the webpage. Read “Debugging” (page 104) for how to debug JavaScript on iOS. ● The maximum number of documents that can be open at once is eight on iPhone and nine on iPad. Creating Compatible Web Content Know iOS Resource Limits 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 23iOS Note: In iOS 1.1.4 and earlier, the JavaScript execution time was limited to 5 seconds and the size of allocations to 10 MB. Also, the limit on the size of canvas elements was the same as Safari on the desktop. In iOS 2.2.1 and earlier, the sum of all of the frames needs to be less than 2 megapixels—that is, width * height * number of frames ≤ 2 * 1024 * 1024. In iOS 3.0 and later, the limit only applies to one frame at a time. You also need to size images appropriately. Don’t rely on browser scaling. For example, don’t put a 100 x 100 image in a 10 x 10 element. Tile small backgrounds images; don’t use large background images. Checking the Size of Webpages You can check the size of your webpages by using Safari’s Web Inspector as described in “Optimizing Download Time” in Safari User Guide for Web Developers or by saving your webpage as a web archive. The total size of the web archive is the size of the page and its associated resources. Follow these steps to create a web archive: 1. Choose File > Save As. 2. Enter the filename in the Save As text field. 3. Choose Web Archive from the Format pop-up menu. 4. Click Save. On OS X, check the size of the web archive using either Finder or Terminal. Typically, pages under 30 MB work fine on iOS. Creating Compatible Web Content Know iOS Resource Limits 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 24Use the Select Element If you use the select HTML element in your webpage, iOS displays a custom select control that is optimized for selecting items in the list using a finger as the input device. On iOS, the user can flick to scroll the list and tap to select an item from the list. Figure 1-3 compares the select element on the desktop with the select element on iOS. Figure 1-3 Comparison of the select element on the desktop and iOS Select on the desktop Select on iPhone Use Supported JavaScript Windows and Dialogs Use windows and dialogs supported by Safari on iOS and avoid the others. You can open a new window in JavaScript by invoking window.open(). Remember that the maximum number of documents—hence, the maximum number of open windows—is eight on iOS. Creating Compatible Web Content Use the Select Element 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 25Supported JavaScript dialog methodsinclude alert, confirm, print, and prompt. If you use these methods, Safari on iOS displays an attractive dialog that doesn’t obscure the webpage, as show in Figure 1-4. Figure 1-4 Confirm dialog iOS Note: Note that the showModalDialog method is not supported in Safari on iOS. Use Supported Content Types and iOS Features Be aware of the features you get for free in Safari on iOS by using supported content types and elements that tailor the presentation of content for small handheld devices with touch screens. In particular, Safari on iOS handles content types such as video and PDF files different from the desktop. Safari on iOS also has the ability to preview content types and launch another application if it is available to display that type of document. Following links such as phone numbers in your web content may launch applications too. Creating Compatible Web Content Use Supported Content Types and iOS Features 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 26On iPhone and iPod touch, the video and audio is played back in fullscreen mode only. The video automatically expands to the size of the screen and rotates when the user changes orientation, as shown in Figure 1-5. The controls automatically hide when they are not in use. On iPad, the video and audio is played either inline in the webpage or in fullscreen mode. Read “Creating Video” (page 91) for how to export video for iOS. Figure 1-5 Playing video on iOS Creating Compatible Web Content Use Supported Content Types and iOS Features 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 27PDF documents are easy to view using Safari on iOS and even easier to page through as shown in Figure 1-6. PDF documents linked from web content are opened automatically. The page indicator keeps track of where the user isin a document. And just as with video, the user can rotate iOS to view a PDF in landscape orientation. Figure 1-6 Viewing PDF documents on iOS Safari on iOS previews other content typeslike MS Office (Word, Excel and PowerPoint), iWork (Pages, Numbers, and Keynote), and RTF documents. If another application registersfor a content type that Safari on iOS previews, then that application is used to open the document. For example, on iPad, Pages may be used to open Word and Pages documents that are previewed in Safari on iOS. If another application registers for a content type that Safari on iOS doesn’tsupport natively or preview, then Safari on iOS allowsthe document to be downloaded and opened using that application. iOS Note: Previews of RTF documents is available in iOS 3.2 and later. The ability to open a downloaded file is available in iOS 3.2 and later. When the user taps certain types of links, Safari on iOS may launch a native application to handle the link—for example, Mail to compose an email message, Maps to get directions, and YouTube to view a video. If the user taps a telephone number link on a phone device, a dialog appears asking whether the user wants to dial that number.On the desktop,most ofthese linksredirectto the respective website. Read Apple URL Scheme Reference to learn more about using these types of links in your web content. Creating Compatible Web Content Use Supported Content Types and iOS Features 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 28iOS Note: Note that Java and Flash content types are not supported. See “Don’t Use Unsupported iOS Technologies” (page 30) for a complete list of unsupported technologies. Use Canvas for Vector Graphics and Animation You can use the same canvas object used by Dashboard widgets to implement sophisticated user interfaces for web applications. The canvas object was introduced in Safari 2.0, is adopted by other browser engines, and is part of the WHATWG specification. Read WebKit DOM Programming Topics to learn more about using the canvas object. Use the HTML5 Audio and Video Elements You can use the HTML5 audio and video elements to add audio and video to your webpages. On smaller deviceslike iPhone and iPad touch, the movie playsin fullscreen mode only and automatic playback is disabled so a user action is required to initiate playback. On iPad, the video plays inline in the webpage. When the video is played inline, you can create custom controls and receive media events—for example, pause and play events—to enhance the user experience. Use the HTMLMediaElement class and its subclasses, described in Safari DOM Additions Reference , to do this. Read Safari HTML5 Audio and Video Guide for more in-depth information on the audio and video elements. Read “Creating Video” (page 91) for how to create media files compatible with Safari. Use Supported iOS Rich Media MIME Types Table 1-1 lists the rich media MIME types supported by Safari on iOS. Files with these MIME types and filename extensions can be played on iOS. Table 1-1 Supported iOS rich media MIME types MIME type Description Extensions audio/3gpp 3GPP media 3gp, 3gpp audio/3gpp2 3GPP2 media 3g2, 3gp2 audio/aiff AIFF audio aiff, aif, aifc, cdda audio/x-aiff audio/amr AMR audio amr Creating Compatible Web Content Use Canvas for Vector Graphics and Animation 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 29MIME type Description Extensions audio/mp3 MP3 audio mp3, swa audio/mpeg3 audio/x-mp3 audio/x-mpeg3 audio/mp4 MPEG-4 media mp4 audio/mpeg MPEG audio mpeg, mpg, mp3, swa audio/x-mpeg audio/wav WAVE audio wav, bwf audio/x-wav audio/x-m4a AAC audio m4a audio/x-m4b AAC audio book m4b audio/x-m4p AAC audio (protected) m4p video/3gpp 3GPP media 3gp, 3gpp video/3gpp2 3GPP2 media 3g2, 3gp2 video/mp4 MPEG-4 media mp4 video/quicktime QuickTime Movie mov, qt, mqv video/x-m4v Video m4v Don’t Use Unsupported iOS Technologies In general, Safari on iOS does not support any third-party plug-ins or features that require access to the file system. The following web technologies are not supported on iOS: ● Modal dialogs Don’t use window.showModalDialog() in JavaScript. Read “Use Supported JavaScript Windows and Dialogs” (page 25) for a list of supported dialogs. ● Mouse-over events The user cannot “mouse-over” a nonclickable element on iOS. The element must be clickable for a mouseover event to occur as described in “One-Finger Events” (page 69). Creating Compatible Web Content Don’t Use Unsupported iOS Technologies 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 30● Hover styles Since a mouseover event is sent only before a mousedown event, hover styles are displayed only if the user touches and holds a clickable element with a hover style. Read “Handling Events” (page 68) for all the events generated by gestures on iOS. ● Tooltips Similar to hover styles, tooltips are not displayed unless the user touches and holds a clickable element with a tooltip. ● Java applets ● Flash Don’t bring up JavaScript alerts that ask users to download Flash. ● QuickTime VR (QTVR) movies ● Plug-in installation ● Custom x.509 certificates ● WML Safari on iOS is not a miniature web browser—it is a full web browser that renders pages as designed—therefore, there is no need for Safari on iOS to support Wireless Markup Language (WML). Alternatively, it does support XHTML mobile profile document types and sites at .mobi domains. The XHTML mobile document type is: ● File uploads and downloads Safari on iOS does not support file uploading, that is, elements. If your webpage includes an input-file control, Safari on iOS disables it. Because iOS does not support file downloads, do not prompt the user to download plug-ins like Flash on iOS. See “Using the Safari User Agent String” (page 36) for how to detect Safari on iOS. By default, Safari on iOS blocks pop-up windows. However, it is a preference that the user can change. To change the Safari settings, tap Settings followed by Safari. The Block Pop-ups setting appears in the Security section. Creating Compatible Web Content Don’t Use Unsupported iOS Technologies 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 31iOSNote: The HTML contenteditable attribute issupported in iOS 5.0 and later. In earlier versions, replace contenteditable, used to enable textinput within a styled element, with a styled textarea element. In Safari, you can customize the appearance of textarea elements using CSS. If necessary, you can even disable any platform-specific, built-in styling on a textarea element by setting -webkit-appearance to none. The window.print() method is supported in iOS 4.2 and later. Downloadable web fonts are supported in iOS 1.1.4 and earlier, and iOS 4.2 and later. SVG is supported in iOS 2.1 and later. XSLT is supported in iOS 2.0 and later. Creating Compatible Web Content Don’t Use Unsupported iOS Technologies 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 32The first step in optimizing web content for iOS is to separate your iOS-specific content from your desktop content and the next step is to tailor the web content for iOS. You might want to follow these steps even if iOS is not your target platform so your web content is more maintainable in the future. Use conditional CSS so that you can create iOS-specific style sheets as described in “Using Conditional CSS” (page 33). You can also use object detection and WebKit detection as described in “Follow Good Web Design Practices” (page 19) to use extensions but remain browser-independent. Only if necessary, use the user agent string as described in “Using the Safari User Agent String” (page 36) to detect Safari on iOS or a specific device. After optimizing your content, read the rest of the chapters in this document to learn how to set viewport properties, adjust text size, lay out forms, handle events, use application links, and export media for iOS. Finally read “Debugging” (page 104) for how to debug your webpages. Using Conditional CSS Once you use CSS to lay out your webpage in columns, you can use conditional CSS to create different layouts for specific platforms and mobile devices. Using CSS3 media queries, you can add iOS-specific style sheets to your webpage without affecting how your webpages are rendered on other platforms. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 33 Optimizing Web ContentFor example, Figure 2-1 shows a webpage containing conditional CSS specifically for iOS. Figure 2-2 shows the same webpage rendered on the desktop. Figure 2-1 Small device rendering Figure 2-2 Desktop rendering CSS3 recognizes several media types, including print, handheld, and screen. iOS ignores print and handheld media queries because these types do not supply high-end web content. Therefore, use the screen media type query for iOS. Optimizing Web Content Using Conditional CSS 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 34To specify a style sheet that isjust for iOS without affecting other devices, use the only keyword in combination with the screen keyword in your HTML file. Older browsers ignore the only keyword and won’t read your iOS style sheet. Use max-device-width, and min-device-width to describe the screen size. For example, to specify a style sheet for iPhone and iPod touch, use an expression similar to the following: To specify a style sheet for devices other than iOS, use an expression similar to the following: Alternatively, you can use this format inside a CSS block in an HTML file, or in an external CSS file: @media screen and (min-device-width: 481px) { ... } Here are some examples of CSS3 media-specific style sheets where you might provide a different style for screen and print. Listing 2-1 displays white text on dark gray background for the screen. Listing 2-2 displays black text on white background and hides navigation for print. Listing 2-1 Screen-specific style sheet @media screen { #text { color: white; background-color: black; } } Listing 2-2 Print-specific style sheet @media print { #text { color: black; background-color: white; } #nav { display: none; } } For more information on media queries, see: http://www.w3.org/TR/css3-mediaqueries/. Optimizing Web Content Using Conditional CSS 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 35Using the Safari User Agent String A browser sends a special string, called a user agent, to websites to identify itself. The web server, or JavaScript in the downloaded webpage, detects the client’s identity and can modify its behavior accordingly. In the simplest case, the user agentstring includes an application name—for example, Navigator asthe application name and 6.0 as the version. Safari on the desktop and Safari on iOS have their own user agent strings, too. The Safari user agent string for iOS is similar to the user agent string for Safari on the desktop except for two additions: It contains a platform name and the mobile version number. The device name is contained in the platform name. For example, you can detect iOS and the specific device such as iPad. Typically, you do not send iPhone-specific web content to an iPad since it has a much larger screen. Note that the version numbers in this string are subject to change over time as new versions of iOS become available, so any code that checks the user agent string should not rely on version numbers. For example, Listing 2-3 shows the user agent string for an iPhone running iOS 2.0 and later, where the string XXXX is replaced with the build number. Listing 2-3 iPhone running on iOS 2.0 user agent string Mozilla/5.0 (iPhone; U; CPU iOS 2_0 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/XXXXX Safari/525.20 The parts of the Safari on iOS user agent string are as follows: (iPhone; U; CPU iOS 2_0 like Mac OS X; en-us) The platform string. iPhone is replaced with iPod when running on an iPod touch and iPad when running on an iPad. AppleWebKit/525.18.1 The WebKit engine build number. Version/3.1.1 The Safari family version. Mobile/XXXXX The mobile version number, where XXXX is the build number. Safari/525.20 The Safari build number. For example, the user agent string for an iPod touch contains iPod in the platform name as shown in Listing 2-4. Optimizing Web Content Using the Safari User Agent String 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 36Listing 2-4 iPod touch running iOS 1.1.3 user agent string Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3 The user agent string for an iPad contains iPad in the platform name as shown in Listing 2-5. Listing 2-5 iPad running iOS 3.2 user agent string Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10 Note that the user agent string is slightly different for earlier Safari on iOS releases. Listing 2-6 shows the user agent string for an iPhone running iOS 1.1.4 and earlier. Note that the platform string does not contain the iOS version number. Listing 2-6 iPhone running iOS 1.0 user agent string Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3 Typically, you use the WebKit build number to test for supported WebKit HTML tags and CSS properties. The Safari family version, or marketing version, is included in the user agent string for Safari on the desktop, too. Therefore, you can use it to track usage statistics across all Safari platforms. Go to these websites to learn more about other recommended techniques for detecting Safari and WebKit: ● webkit.org http://trac.webkit.org/projects/webkit/wiki/DetectingWebKit Contains JavaScript sample code for detecting Safari on iPhone and iPod touch. ● developer.apple.com http://developer.apple.com/internet/webcontent/objectdetection.html Optimizing Web Content Using the Safari User Agent String 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 37Safari on iOS displays webpages at a scale that worksfor most web content originally designed for the desktop. If these default settings don’t work for your webpages, it is highly recommended that you change the settings by configuring the viewport. You especially need to configure the viewport if you are designing webpages specifically for iOS. Configuring the viewport is easy—just add one line of HTML to your webpage—but understanding how viewport properties affect the presentation of your webpages on iOS is more complex. Before configuring the viewport, you need a deeper understanding of what the visible area and viewport are on iOS. If you are already familiar with the viewport on iOS, read “Using the Viewport Meta Tag” (page 46) for details on the viewport tag and “Viewport Settingsfor Web Applications” (page 55) for web application tips. Otherwise, read the sections in this chapter in the following order: ● Read “Layout and Metrics on iPhone and iPod touch” (page 39) to learn about the available screen space for webpages on small devices. ● Read “What Is the Viewport?” (page 39) for a deeper understanding of the viewport on iOS. ● Read “Default Viewport Settings” (page 46) and “Using the Viewport Meta Tag” (page 46) for how to use the viewport meta tag. ● Read “Changing the Viewport Width and Height” (page 47) and “How Safari Infers the Width, Height, and Initial Scale” (page 50) to understand better how setting viewport properties affects the way webpages are rendered on iOS. ● Read “Viewport Settings for Web Applications” (page 55) if you are designing a web application for iOS. See “Supported Meta Tags” for a complete description of the viewport meta tag. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 38 Configuring the ViewportLayout and Metrics on iPhone and iPod touch Because Safari on iOS adds controls above and below your web content, you don’t have access to the entire screen real estate. In portrait orientation, the visible area for web content on iPhone and iPod touch is 320 x 356 pixels as shown in Figure 1-1. In landscape orientation, the visible area is 480 x 208 pixels. Figure 3-1 Layout and metrics in portrait orientation 480 pixels Status bar: 20 pixels URL text field: 60 pixels Visible area: 320 x 356 pixels Button bar: 44 pixels Note that if the URL text field is not in use, it is anchored above the webpage and moves with the webpage when the user pans. This adds 60 pixels to the height of the visible area. However, since the URL text field can appear at any time, you should not rely on this extra real estate when designing your webpage. Video playback uses the entire screen on small devices. Read “Laying Out Forms” (page 62) in “Designing Forms” (page 62) for more metrics when the keyboard is displayed for user input. Note: Although it is helpful to know the metrics on small devices like iPhone and iPod touch, you should avoid using these values in your code. Read “Using the Viewport Meta Tag” (page 46) for how to use the viewport meta tag constants. What Is the Viewport? The viewport on the desktop and the viewport on iOS are slightly different. Configuring the Viewport Layout and Metrics on iPhone and iPod touch 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 39Safari on iOS has no windows, scroll bars, or resize buttons as shown on the right in Figure 3-2. The user pans by flicking a finger. The user zooms in by double-tapping and pinch opening, and zooms out by pinch closing—gestures that are not available for Safari on the desktop. Because of the differences in the way users interact with web content, the viewport on the desktop and on iOS are not the same. Note that these differences between the viewports may affect some of the HTML and CSS instructions on iOS. Figure 3-2 Differences between Safari on iOS and Safari on the desktop Safari on the desktop Safari on iPhone Configuring the Viewport What Is the Viewport? 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 40Safari on the Desktop Viewport The viewport on the desktop is the visible area of the webpage as shown in Figure 3-3. The user resizes the viewport by resizing the window. If the webpage is larger than the viewport, then the user scrolls to see more of the webpage. When the viewport isresized, Safari may change the document’slayout—for example, expand or shrink the width of the text to fit. If the webpage is smaller than the viewport, it is filled with white space to fit the size of the viewport. Figure 3-3 Safari on desktop viewport Viewport Safari on iOS Viewport For Safari on iOS, the viewport is the area that determines how content is laid out and where text wraps on the webpage. The viewport can be larger or smaller than the visible area. When the user pans a webpage on iOS, gray bars appear on the right and bottom sides of the screen as visual feedback to show the user the size of the visible area as compared to the viewport (similar to the length of scroll bars on the desktop). Using the double tap, pinch open, and pinch close gestures, users can change the scale of the viewport but not the size. The only exception is when the user changes from portrait to landscape orientation—under certain circumstances, Safari on iOS may adjust the viewport width and height, and consequently, change the webpage layout. You can set the viewport size and other properties of your webpage. Mostly, you do this to improve the presentation the first time iOS renders the webpage. Configuring the Viewport What Is the Viewport? 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 41Examples of Viewports on iOS The viewport on iOS is best illustrated using a few examples. Figure 3-4 shows a webpage on iPhone, containing a single 320 x 356 pixel image, that is rendered for the first time using the default viewport settings. Figure 3-4 Viewport with default settings Viewport default width = 980 pixels Configuring the Viewport What Is the Viewport? 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 42Figure 3-5 shows the same webpage with the viewport set to the size of the visible area, which is also the size of the image. Figure 3-5 Viewport with width set to 320 Viewport width = 320 pixels scale = 1.0 Configuring the Viewport What Is the Viewport? 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 43However, the viewport can be larger or smaller than the visible area. If the viewport is larger than the visible area, as shown in Figure 3-6, then the user pans to see more of the webpage. Figure 3-6 Viewport with width set to 320 and scale set to 150% Viewport width = 320 pixels scale = 1.5 Visible area Configuring the Viewport What Is the Viewport? 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 44Figure 3-7 show the webpage when it is smaller than the viewport and filled with white space. Figure 3-7 Viewport with width set to 320 and scale set to 50% Viewport width = 320 pixels scale = 0.5 The user can also zoom in and out using gestures. When zooming in and out, the user changes the scale of the viewport, not the size of the viewport. Consequently, panning and zooming do not change the layout of the webpage. Figure 3-8 shows the same webpage when the user zooms in to see details. Figure 3-8 Viewport with arbitrary user scale User zoom, arbitrary scale Configuring the Viewport What Is the Viewport? 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 45Default Viewport Settings Safari on iOS sets the size and scale of the viewport to reasonable defaults that work well for most webpages, as shown on the left in Figure 3-9. The default width is 980 pixels. However, these defaults may not work well for your webpages, particularly if you are tailoring your website for a particular device. For example, the webpage on the right in Figure 3-9 appears too narrow. Because Safari on iOS provides a viewport, you can change the default settings. Figure 3-9 Default settings work well for most webpages Works well Too narrow Using the Viewport Meta Tag Use the viewport meta tag to improve the presentation of your web content on iOS. Typically, you use the viewport meta tag to set the width and initialscale of the viewport. For example, if your webpage is narrower than 980 pixels, then you should set the width of the viewport to fit your web content. If you are designing an iPhone or iPod touch-specific web application, then set the width to the width of the device. Refer to “Additional meta Tag Keys” in Safari HTML Reference for a detailed description of the viewport meta tag. Because iOS runs on devices with differentscreen resolutions, you should use the constantsinstead of numeric values when referring to the dimensions of a device. Use device-width for the width of the device and device-height for the height in portrait orientation. Configuring the Viewport Default Viewport Settings 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 46You do not need to set every viewport property. If only a subset of the properties are set, then Safari on iOS infers the other values. For example, if you set the scale to 1.0, Safari assumes the width is device-width in portrait and device-height in landscape orientation. Therefore, if you want the width to be 980 pixels and the initial scale to be 1.0, then set both of these properties. For example, to set the viewport width to the width of the device, add this to your HTML file: To set the initial scale to 1.0, add this to your HTML file: To set the initial scale and to turn off user scaling, add this to your HTML file: Use the Safari on iOS console to help debug your webpages as described in “Debugging” (page 104). The console contains tips to help you choose viewport values—for example, it reminds you to use the constants when referring to the device width and height. Changing the Viewport Width and Height Typically, you set the viewport width to match your web content. Thisisthe single most important optimization that you can do for iOS—make sure your webpage looks good the first time it is displayed on iOS. Configuring the Viewport Changing the Viewport Width and Height 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 47The majority of webpages fit nicely in the visible area with the viewport width set to 980 pixels in portrait orientation, as shown in Figure 3-10. If Safari on iOS did not set the viewport width to 980 pixels, then only the upper-left corner of the webpage, shown in gray, would be displayed. However, this default doesn’t work for all webpages, so you’ll want to use the viewport meta tag if your webpage is different. Figure 3-10 Comparison of 320 and 980 viewport widths 320 pixels 980 pixels 356 pixels 1090 pixels If your webpage is narrower than the default width, as shown on the left in Figure 3-11, then set the viewport width to the width of your webpage, as shown on the right in Figure 3-11. To do this, add the following to your HTML file inside the
      block, replacing 590 with the width of your webpage: Configuring the Viewport Changing the Viewport Width and Height 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 48 Figure 3-11 Webpage is too narrow for default settings Default width Custom width 980 pixels 590 pixels Configuring the Viewport Changing the Viewport Width and Height 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 49It is particularly important to change the viewport width for web applications designed for devices with smaller screens such as iPhone and iPod touch. Figure 3-12 shows the effect of setting the viewport width to device-width. Read “Viewport Settings for Web Applications” (page 55) for more web application tips. Figure 3-12 Web application page is too small for default settings Default width Width set to device-width 980 pixels 320 pixels Similarly you can set the viewport height to match your web content. How Safari Infers the Width, Height, and Initial Scale If you set only some of the properties, then Safari on iOS infers the values of the other properties with the goal of fitting the webpage in the visible area. For example, if just the initial scale is set, then the width and height are inferred. Similarly, if just the width is set, then the height and initial scale are inferred, and so on. If the inferred values do not work for your webpage, then set more viewport properties. Since any of the width, height, and initial scale may be inferred by Safari on iOS, the viewport may resize when the user changes orientation. For example, when the user changes from portrait to landscape orientation by rotating the device, the viewport width may expand. This is the only situation where a user action might resize the viewport, changing the layout on iOS. Configuring the Viewport How Safari Infers the Width, Height, and Initial Scale 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 50Specifically, the goal of Safari on iOS is to fit the webpage in the visible area when completely zoomed out by maintaining a ratio equivalent to the ratio of the visible area in either orientation. This is best illustrated by setting the viewport propertiesindependently, and observing the effect on the other viewport properties. The following series of examples shows the same web content with different viewport settings. Figure 3-13 shows a typical webpage displayed with the default settings where the viewport width is 980 and no initial scale is set. Figure 3-13 Default width and initial scale default = 980 pixels Configuring the Viewport How Safari Infers the Width, Height, and Initial Scale 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 51Figure 3-14 shows the same webpage when the initial scale is set to 1.0 on iPhone. Safari on iOS infers the width and height to fit the webpage in the visible area. The viewport width is set to device-width in portrait orientation and device-height in landscape orientation. Figure 3-14 Default width with initial scale set to 1.0 320 pixels 356 pixels 480 pixels 208 pixels Configuring the Viewport How Safari Infers the Width, Height, and Initial Scale 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 52Similarly, if you specify only the viewport width, the height and initial scale are inferred. Figure 3-15 shows the rendering of the same webpage when the viewport width is set to 320 on iPhone. Notice that the portrait orientation is rendered in the same way as in Figure 3-14 (page 52), but the landscape orientation maintains a width equal to device-width, which changes the initial scale and has the effect of zooming in when the user changes to landscape orientation. Figure 3-15 Width set to 320 with default initial scale 320 pixels 356 pixels 320 pixels 139 pixels Configuring the Viewport How Safari Infers the Width, Height, and Initial Scale 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 53You can also set the viewport width to be smaller than the visible area with a minimum value of 200 pixels. Figure 3-16 shows the same webpage when the viewport width is set to 200 pixels on iPhone. Safari on iOS infers the height and initial scale, which has the effect of zooming in when the webpage is first rendered. Figure 3-16 Width set to 200 with default initial scale 200 pixels 223 pixels Configuring the Viewport How Safari Infers the Width, Height, and Initial Scale 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 54Finally, Figure 3-17 shows the same webpage when both the width and initial scale are set on iPhone. Safari on iOS infers the height by maintaining a ratio equivalent to the ratio of the visible area in either orientation. Therefore, if the width is set to 980 and the initial scale is set to 1.0 on iPhone, the height is set to 1091 in portrait and 425 in landscape orientation. Figure 3-17 Width set to 980 and initial scale set to 1.0 Width = 980 pixels Height = 1091 pixels Initial scale = 1.0 Width = 980 pixels Height = 425 pixels Initial scale = 1.0 The minimum-scale and maximum-scale properties also affect the behavior when changing orientations. The range of these property values is from >0 to 10.0. The default value for minimum-scale is 0.25 and maximum-scale is 5.0. Viewport Settings for Web Applications If you are designing a web application specifically for iOS, then the recommended size for your webpages is the size of the visible area on iOS. Apple recommends that you set the width to device-width so that the scale is 1.0 in portrait orientation and the viewport is not resized when the user changesto landscape orientation. Configuring the Viewport Viewport Settings for Web Applications 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 55If you do not change the viewport properties, Safari on iOS displays your webpage in the upper-left corner as shown in Figure 3-18. Setting the viewport width should be the first task when designing web applications for iOS to avoid the user zooming in before using your application. Figure 3-18 Not specifying viewport properties Viewport width = 980 pixels By setting the width to device-width in portrait orientation, Safari on iOS displays your webpage as show in Figure 3-19. Users can pan down to view the rest of the webpage if it is taller than the visible area. Add this line to your HTML file to set the viewport width to device-width: Configuring the Viewport Viewport Settings for Web Applications 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 56 Figure 3-19 Width set to device-width pixels Viewport width = 320 pixels You may not want users to scale web applications designed specifically for iOS. In this case, set the width and turn off user scaling as follows: Configuring the Viewport Viewport Settings for Web Applications 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 57Although configuring the viewport is an important way to optimize your web content for iOS, style sheets provide further techniques for optimizing. For example, use iOS CSS extensions to control text resizing and element highlighting. If you use conditional CSS, then you can use these settings without affecting the way other browsers render your webpages. Read “Optimizing Web Content” (page 33) for how to use conditional CSS and “CSS Basics” (page 117) for how to add CSS to existing HTML. See Safari CSS Reference for a complete list of CSS properties supported by Safari. Leveraging CSS3 Properties There are many CSS3 properties available for you to use in Safari on the desktop and iOS. CSS properties that begin with -webkit- are usually proposed CSS3 properties or Apple extensions to CSS. For example, you can use the following CSS properties to emulate the iOS user interface: -webkit-border-image Allows you to use an image as the border for a box. See "-webkit-border-image" in Safari CSS Reference for details. -webkit-border-radius Creates elements with rounded corners. See “Customizing Form Controls” (page 64) for code samples. See "-webkit-border-radius" in Safari CSS Reference for details. Adjusting the Text Size In addition to controlling the viewport, you can control the text size that Safari on iOS uses when rendering a block of text. Adjusting the textsize isimportantso that the text islegible when the user double-taps. If the user double-taps an HTML block element—such as a
      element—then Safari on iOS scales the viewport to fit the block width in the visible area. The first time a webpage is rendered, Safari on iOS gets the width of the block and determines an appropriate text scale so that the text is legible. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 58 Customizing Style SheetsIf the automatic text size-adjustment doesn’t work for your webpage, then you can either turn this feature off or specify your own scale as a percentage. For example, text in absolute-positioned elements might overflow the viewport after adjustment. Other pages might need a few minor adjustments to make them look better. In these cases, use the -webkit-text-size-adjust CSS property to change the default settings for any element that renders text. Figure 4-1 compares a webpage rendered by Safari on iOS with -webkit-text-size-adjust set to auto, none, and 200%. On iPad, the default value for -webkit-text-size-adjust is none. On all other devices, the default value is auto. Figure 4-1 Comparison of text adjustment settings Auto None 200% To turn automatic text adjustment off, set -webkit-text-size-adjust to none as follows: html {-webkit-text-size-adjust:none} To change the text adjustment,set -webkit-text-size-adjust to a percentage value asfollows, replacing 200% with your percentage: html {-webkit-text-size-adjust:200%} Listing 4-1 shows setting this property for different types of blocks using inline style in HTML. Customizing Style Sheets Adjusting the Text Size 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 59Listing 4-1 Setting the text size adjustment property
      Highlighting Elements By default, when the user taps a link or a JavaScript clickable element, Safari on iOS highlights the area in a transparent gray color. Using the -webkit-tap-highlight-color CSS property, you can either modify or disable this default behavior on your webpages. The syntax for setting this CSS property is: -webkit-tap-highlight-color: This is an inherited property that changes the tap highlight color, obeying the alpha value. If you don’t specify an alpha value, Safari on iOS applies a default alpha value to the color. To disable tap highlighting, set the alpha to 0 (invisible). If you set the alpha to 1.0 (opaque), then the element won’t be visible when tapped. Listing 4-2 uses an alpha value of 0.4 for the custom highlight color shown on the right in Figure 4-2. Listing 4-2 Changing the tap highlight color
      default highlight color

      custom highlight color Customizing Style Sheets Highlighting Elements 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 60 Figure 4-2 Differences between default and custom highlighting Default highlight Custom highlight Note that changing this behavior does not affect the color of the information bubble when the user touches and holds. You can also use the -webkit-tap-highlight-color CSS property in combination with setting a touch event to configure buttons to behave similar to the desktop. On iOS, mouse events are sent so quickly that the down or active state is never received. Therefore, the :active pseudo state is triggered only when there is a touch eventset on the HTML element—for example, when ontouchstart isset on the element asfollows: Now when the button is tapped and held on iOS, the button changes to the specified color without the surrounding transparent gray color appearing. Read “Handling Events” (page 68) for the definition of a clickable element. See "-webkit-tap-highlight-color" in Safari CSS Reference to learn more about this property. Read “Handling Multi-Touch Events” (page 74) for details on touch events. Customizing Style Sheets Highlighting Elements 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 61There are many adjustments you can make to your forms so that they work better on iOS. The forms should fit neatly on the iOS screen, especially if you are designing a web application specifically for iOS. Web applications can have a rich user interface and even look like native applications to the user. Consequently, the user may expect them to behave like native applications, too. This chapter explains what you can do to make your forms work well on iOS: ● Take into account the available screen space when the keyboard is and isn’t displayed. ● Use CSS extensions to create custom controls. ● Control where automatic correction and capitalization are used. See iOS Human Interface Guidelines for more tips on laying out forms and designing web applications for iOS. Read “Hiding Safari User Interface Components” (page 89) for how to use the full-screen like a native application. Laying Out Forms The available area for your forms changes depending on whether or not the keyboard is displayed on iOS. You should compute this area and design your forms accordingly. Figure 5-1 shows the layout of Safari controls when the keyboard is displayed on iPhone. The status bar that appears at the top of the screen contains the time and Wi-Fi indicator. The URL text field is displayed below the status bar. The keyboard is used to enter text in forms and is displayed at the bottom of the screen. The form assistant appears above the keyboard when editing forms. It contains the Previous, Next, and Done buttons. The user taps the Next and Previous buttons to move between form elements. The user taps Done 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 62 Designing Formsto dismissthe keyboard. The button bar containsthe back, forward, bookmarks, and page buttons and appears at the bottom of the screen. The tool bar is not visible when the keyboard is visible. Your webpage is displayed in the area below the URL text field and above the tool bar or keyboard. Figure 5-1 Form metrics when the keyboard is displayed Status bar: 20 pixels URL text field: 60 pixels Form assistant: 44 pixels Keyboard: 216 pixels 480 pixels Table 5-1 contains the metrics for the objects that you need to be aware of, in both portrait and landscape orientation, when laying out forms to fit on iPhone and iPod touch. Table 5-1 Form metrics Object Metrics in pixels Status bar Height = 20 URL text field Height = 60 Form assistant Height = 44 Portrait height = 216 Landscape height = 162 Keyboard Portrait height = 44 Landscape height = 32 Button bar Designing Forms Laying Out Forms 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 63Use this information to compute the available area for your web content when the keyboard is and isn't displayed. For example, when the keyboard is not displayed, the height available for your web content on iPhone is 480 - 20 - 60 - 44 = 356. Therefore, you should design your content to fit within 320 x 356 pixels in portrait orientation. If the keyboard is displayed, the available area is 320 x 140 pixels on iPhone. iOS Note: In iOS 1.1.4 and earlier, the keyboard height in landscape orientation on iPhone and iPod touch was 180 pixels. Customizing Form Controls Form controls in Safari on iOS are resolution independent and can be styled with CSS specifically for iOS. You can create custom checkboxes, text fields, and select elements. For example, you can create a custom checkbox designed for iOS as shown in Figure 5-2 with the CSS code fragment in Listing 5-1. This example uses the -webkit-border-radius property—an Apple extension to WebKit. See Safari CSS Reference for details on more WebKit properties. Figure 5-2 A custom checkbox Listing 5-1 Creating a custom checkbox with CSS { Designing Forms Customizing Form Controls 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 64width: 100px; height: 100px; -webkit-border-radius:50px; background-color:purple; } Figure 5-3 shows a custom text field with rounded corners corresponding to the CSS code in Listing 5-2 (page 65). Figure 5-3 A custom text field Listing 5-2 Creating a custom text field with CSS { -webkit-border-radius:10px; } Designing Forms Customizing Form Controls 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 65Figure 5-4 shows a custom select control corresponding to the CSS code in Listing 5-3 (page 66). Figure 5-4 A custom select element Listing 5-3 Creating a custom select control with CSS { background:red; border: 1px dashed purple; -webkit-border-radius:10px; } Configuring Automatic Correction and Capitalization You can also control whether or not automatic correction or capitalization are used in your forms on iOS. Set the autocorrect attribute to on if you want automatic correction and the autocapitalize attribute to a value if you want automatic capitalization. If you do notset these attributes, then the browser chooses whether or not to use automatic correction or capitalization. For example, Safari on iOS turns the autocorrect and autocapitalize attributes off in login fields and on in normal text fields. For example, the following line turns the autocorrect attribute on: Designing Forms Configuring Automatic Correction and Capitalization 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 66 The following line turns the autocorrect attribute off: In iOS 5.0, the autocapitalize attribute allows finer control on how automatic capitalization behaves than just specifying on and off values. For example, if autocapitalize is words, each word is capitalized, as in “Jane Doe,” appropriate for a first and last name input field. If autocapitalize is characters, each letter is capitalized, as in “NY” and “CA,” appropriate for a state input field. You can also use the autocorrect and autocapitalize attributes on
      elements to give inner form controls (like and Refer to autocorrect and autocapitalize in Safari HTML Reference for all possible values and defaults. Designing Forms Configuring Automatic Correction and Capitalization 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 67This chapter describes the events that occur when the user interacts with a webpage on iOS. Forms and documents generate the typical events in iOS that you might expect on the desktop. Gestures handled by Safari on iOS emulate mouse events. In addition, you can register for iOS-specific multi-touch and gesture events directly. Orientation events are another example of an iOS-specific event. Also, be aware that there are some unsupported events such as cut, copy, and paste. Gestures that the user makes—for example, a double tap to zoom and a flick to pan—emulate mouse events. However, the flow of events generated by one-finger and two-finger gestures are conditional depending on whether or not the selected element is clickable or scrollable as described in “One-Finger Events” (page 69) and “Two-Finger Events” (page 72). A clickable element is a link, form element, image map area, or any other element with mousemove, mousedown, mouseup, or onclick handlers. A scrollable element is any element with appropriate overflow style, text areas, and scrollable iframe elements. Because of these differences, you might need to change some of your elements to clickable elements, as described in “Making Elements Clickable” (page 73), to get the desired behavior in iOS. In addition, you can turn off the default Safari on iOS behavior as described in “Preventing Default Behavior” (page 79) and handle your own multi-touch and gesture events directly. Handling multi-touch and gesture events directly gives developers the ability to implement unique touch-screen interfaces similar to native applications. Read “Handling Multi-Touch Events” (page 74) and “Handling Gesture Events” (page 77) to learn more about DOM touch events. If you want to change the layout of your webpage depending on the orientation of iOS, read “Handling Orientation Events” (page 79). See “Supported Events” (page 81) for a complete list of events supported in iOS. On iOS, emulated mouse events are sent so quickly that the down or active pseudo state of buttons may never occur. Read “Highlighting Elements” (page 60) for how to customize a button to behave similar to the desktop. It’s very common to combine DOM touch events with CSS visual effects. Read Safari CSS Visual Effects Guide to learn more about CSS visual effects. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 68 Handling EventsOne-Finger Events This section uses flow charts to break down gestures into the individual actions that might generate events. Some of the events generated on iOS are conditional—the events generated depend on what the user is tapping or touching and whether they are using one or two fingers. Some gestures don’t generate any events on iOS. One-finger panning doesn’t generate any events until the userstops panning—an onscroll event is generated when the page stops moving and redraws—as shown in Figure 6-1. Figure 6-1 The panning gesture Pan (no events) Finger down Finger stop onscroll Finger move Displaying the information bubble doesn’t generate any events as shown in Figure 6-2. However, if the user touches and holds an image, the image save sheet appears instead of an information bubble. Handling Events One-Finger Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 69iOS Note: The image save sheet appears on iOS 2.0 and later. Figure 6-2 The touch and hold gesture Information bubble (no events) Finger down Finger held down Clickable element Handling Events One-Finger Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 70Finally, a double tap doesn’t generate any events either as shown in Figure 6-3. Figure 6-3 The double-tap gesture Finger down Quick finger up Double-tap zoom (no events) Quick finger down Quick finger up Handling Events One-Finger Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 71Mouse events are delivered in the same order you'd expect in other web browsers illustrated in Figure 6-4. If the user taps a nonclickable element, no events are generated. If the user taps a clickable element, events arrive in this order: mouseover, mousemove, mousedown, mouseup, and click. The mouseout event occurs only if the user taps on another clickable item. Also, if the contents of the page changes on the mousemove event, no subsequent events in the sequence are sent. This behavior allows the user to tap in the new content. Figure 6-4 One-finger gesture emulating a mouse Content change Finger down Not a clickable element No events Finger up Clickable element mouseover, mousemove No events No content change mousedown, mouseup, click Two-Finger Events The pinch open gesture does not generate any mouse events as shown in Figure 6-5. Figure 6-5 The pinch open gesture Fingers separate Pinch zoom (no events) Two fingers down Figure 6-6 illustrates the mouse events generated by using two fingers to pan a scrollable element. The flow of events is as follows: Handling Events Two-Finger Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 72● If the user holds two fingers down on a scrollable element and moves the fingers, mousewheel events are generated. ● If the element is not scrollable, Safari on iOS pans the webpage. No events are generated while panning. ● An onscroll event is generated when the user stops panning. Figure 6-6 Two-finger panning gesture Two fingers down Scrollable element Two fingers move Not a scrollable element mousewheel Pan (no events) Finger stop onscroll Form and Document Events Typical events generated by forms and documents include blur, focus, load, unload, reset, submit, change and abort. See “Supported Events” (page 81) for a complete list of supported events on iOS. Making Elements Clickable Because of the way Safari on iOS creates events to emulate a mouse, some of your elements may not behave as expected on iOS. In particular, some menus that only use mousemove handlers, as in Listing 6-1, need to be changed because iOS doesn’t recognize them as clickable elements. Listing 6-1 A menu using a mouseover handler To fix this, add a dummy onclick handler, onclick = "void(0)", so that Safari on iOS recognizes the span element as a clickable element, as shown in Listing 6-2. Listing 6-2 Adding an onclick handler WHERE TO BUY Handling Multi-Touch Events You can use JavaScript DOM touch event classes available on iOS to handle multi-touch and gesture events in a way similar to the way they are handled in native iOS applications. If you register for multi-touch events, the system continually sends TouchEvent objectsto those DOM elements as fingers touch and move across a surface. These are sent in addition to the emulated mouse events unless you prevent this default behavior as described in “Preventing Default Behavior” (page 79). A touch event provides a snapshot of all touches during a multi-touch sequence, most importantly the touches that are new or have changed for a particular target. The different types of multi-touch events are described in TouchEvent Class Reference in Safari DOM Additions Reference . A multi-touch sequence begins when a finger first touches the surface. Other fingers may subsequently touch the surface, and all fingers may move across the surface. The sequence ends when the last of these fingers is lifted from the surface. An application receives touch event objects during each phase of any touch. Handling Events Handling Multi-Touch Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 74Touch events are similar to mouse events except that you can have simultaneous touches on the screen at different locations. A touch event object is used to encapsulate all the touches that are currently on the screen. Each finger is represented by a touch object. The typical properties that you find in a mouse event are in the touch object, not the touch event object. Note that a sequence of touch eventsis delivered to the element that received the original touchstart event regardless of the current location of the touches. Follow these steps to use multi-touch events in your web application. 1. Register handlers for multi-touch events in HTML as follows:
      2. Alternatively, register handlers in JavaScript as follows: element.addEventListener("touchstart", touchStart, false); element.addEventListener("touchmove", touchMove, false); element.addEventListener("touchend", touchEnd, false); element.addEventListener("touchcancel", touchCancel, false); 3. Respond to multi-touch events by implementing handlers in JavaScript. For example, implement the touchStart method as follows: function touchStart(event) { // Insert your code here } 4. Optionally, get all touches on a page using the touches property as follows: var allTouches = event.touches; Note that you can get all other touches for an event even when the event is triggered by a single touch. Handling Events Handling Multi-Touch Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 755. Optionally, get all touches for the target element using the targetTouches property: var targetTouches = event.targetTouches; 6. Optionally, get all changed touches for this event using the changedTouches property: var changedTouches = event.changedTouches; 7. Access the Touch object properties—such as the target, identifier, and location in page, client, or screen coordinates—similar to mouse event properties. For example, get the number of touches: event.touches.length Get a specific touch object at index i: var touch = event.touches[i]; Finally, get the location in page coordinates for a single-finger event: var x = event.touches[0].pageX; var y = event.touches[0].pageY; You can also combine multi-touch events with CSS visual effectsto enable dragging orsome other user action. To enable dragging, implement the touchmove event handler to translate the target: function touchMove(event) { event.preventDefault(); curX = event.targetTouches[0].pageX - startX; curY = event.targetTouches[0].pageY - startY; event.targetTouches[0].target.style.webkitTransform = 'translate(' + curX + 'px, ' + curY + 'px)'; } Handling Events Handling Multi-Touch Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 76Typically, you implement multi-touch event handlers to track one or two touches. But you can also use multi-touch event handlersto identify custom gestures. That is, custom gesturesthat are not already identified for you by gesture events described in “Handling Gesture Events” (page 77). For example, you can identify a two-finger tap gesture as follows: 1. Begin gesture if you receive a touchstart event containing two target touches. 2. End gesture if you receive a touchend event with no preceding touchmove events. Similarly, you can identify a swipe gesture as follows: 1. Begin gesture if you receive a touchstart event containing one target touch. 2. Abort gesture if, at any time, you receive an event with >1 touches. 3. Continue gesture if you receive a touchmove event mostly in the x-direction. 4. Abort gesture if you receive a touchmove event mostly the y-direction. 5. End gesture if you receive a touchend event. Handling Gesture Events Multi-touch events can be combined together to form high-level gesture events. GestureEvent objects are also sent during a multi-touch sequence. Gesture events contain scaling and rotation information allowing gestures to be combined, if supported by the platform. If not supported, one gesture ends before another starts. Listen for GestureEvent objects if you want to respond to gestures only, not processthe low-level TouchEvent objects. The different types of gesture events are described in GestureEvent Class Reference in Safari DOM Additions Reference . Follow these steps to use gesture events in your web application. 1. Register handlers for gesture events in HTML:
      2. Alternatively, register handlers in JavaScript: Handling Events Handling Gesture Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 77element.addEventListener("gesturestart", gestureStart, false); element.addEventListener("gesturechange", gestureChange, false); element.addEventListener("gestureend", gestureEnd, false); 3. Respond to gesture events by implementing handlers in JavaScript. For example, implement the gestureChange method as follows: function gestureChange(event) { // Insert your code here } 4. Get the amount of rotation since the gesture started: var angle = event.rotation; The angle is in degrees, where clockwise is positive and counterclockwise is negative. 5. Get the amount scaled since the gesture started: var scale = event.scale; The scale is smaller if less than 1.0 and larger if greater than 1.0. You can combine gesture events with CSS visual effects to enable scaling, rotating, or some other custom user action. For example, implement the gesturechange event handler to scale and rotate the target as follows: onGestureChange: function(e) { e.preventDefault(); e.target.style.webkitTransform = 'scale(' + e.scale + startScale + ') rotate(' + e.rotation + startRotation + 'deg)'; } Handling Events Handling Gesture Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 78Preventing Default Behavior iOS Note: The preventDefault method applies to multi-touch and gesture input in iOS 2.0 and later. The default behavior of Safari on iOS can interfere with your application’s custom multi-touch and gesture input. You can disable the default browser behavior by sending the preventDefault message to the event object. For example, to preventscrolling on an element in iOS 2.0, implement the touchmove and touchstart event handlers as follows : function touchMove(event) { // Prevent scrolling on this element event.preventDefault(); ... } To disable pinch open and pinch close gesturesin iOS 2.0, implement the gesturestart and gesturechange event handlers as follows: function gestureChange(event) { // Disable browser zoom event.preventDefault(); ... } Important: The default browser behavior may change in future releases. Handling Orientation Events An event is sent when the user changes the orientation of iOS. By handling this event in your web content, you can determine the current orientation of the device and make layout changes accordingly. For example, display a simple textual list in portrait orientation and add a column of icons in landscape orientation. Similar to a resize event, a handler can be added to the element in HTML as follows: Handling Events Preventing Default Behavior 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 79 where updateOrientation is a handler that you implement in JavaScript. In addition, the window object has an orientation property set to either 0, -90, 90, or 180. For example, if the user starts with the iPhone in portrait orientation and then changes to landscape orientation by turning the iPhone to the right, the window’s orientation property is set to -90. If the user instead changes to landscape by turning the iPhone to the left, the window’s orientation property is set to 90. Listing 6-3 adds an orientation handler to the body element and implements the updateOrientation JavaScript method to display the current orientation on the screen. Specifically, when an orientationchange event occurs, the updateOrientation method isinvoked, which changesthe string displayed by the division element in the body. Listing 6-3 Displaying the orientation
      Orientation
      Supported Events Be aware of all the events that iOS supports and under what conditions they are generated. Table 6-1 specifies which events are generated by Safari on iOS and which are generated conditionally depending on the type of element selected. This table also lists unsupported events. Handling Events Supported Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 81iOS Note: Although drag and drop are notsupported, you can produce the same effect using touch events as described in “Using Touch to Drag Elements” in Safari CSS Visual Effects Guide . The unload event may not work as expected for back and forward optimization. Use the pageshow and pagehide events instead. Table 6-1 Types of events Event Generated Conditional Available abort Yes No iOS 1.0 and later. blur Yes No iOS 1.0 and later. change Yes No iOS 1.0 and later. click Yes Yes iOS 1.0 and later. copy No N/A cut No N/A drag No N/A drop No N/A focus Yes No iOS 1.0 and later. gesturestart Yes N/A iOS 2.0 and later. gesturechange Yes N/A iOS 2.0 and later. gestureend Yes N/A iOS 2.0 and later. load Yes No iOS 1.0 and later. mousemove Yes Yes iOS 1.0 and later. mousedown Yes Yes iOS 1.0 and later. mouseup Yes Yes iOS 1.0 and later. mouseover Yes Yes iOS 1.0 and later. mouseout Yes Yes iOS 1.0 and later. orientationchange Yes N/A iOS 1.1.1 and later. Handling Events Supported Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 82Event Generated Conditional Available pagehide Yes No iOS 4.0 and later. pageshow Yes No iOS 4.0 and later. paste No N/A reset Yes No iOS 1.0 and later. selection No N/A submit Yes No iOS 1.0 and later. touchcancel Yes N/A iOS 2.0 and later. touchend Yes N/A iOS 2.0 and later. touchmove Yes N/A iOS 2.0 and later. touchstart Yes N/A iOS 2.0 and later. unload Yes No iOS 1.0 and later. Handling Events Supported Events 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 83Safari has a new Smart App Banner feature in iOS 6 and later that provides a standardized method of promoting apps on the App Store from a website, as shown in Figure 7-1 (page 84). Figure 7-1 A Smart App Banner of the Apple Store app Note: Smart App Banners only show on iOS, not OS X. Smart App Banners vastly improve users’ browsing experience compared to other promotional methods. As banners are implemented in iOS 6, they will provide a consistent look and feel across the web that users will come to recognize. Users will trust that tapping the banner will take them to the App Store and not a third-party advertisement. They will appreciate that banners are presented unobtrusively at the top of a webpage, instead of as a full-screen ad interrupting the web content. And with a large and prominent close button, a banner is easy for users to dismiss. If the app is already installed on a user's device, the banner intelligently changes its action, and tapping the banner will simply open the app. If the user doesn’t have your app on his device, tapping on the banner will take him to the app’s entry in the App Store. When he returns to your website, a progress bar appears in the banner, indicating how much longer the download will take to complete. When the app finishes downloading, the View button changes to an Open button, and tapping the banner will open the app while preserving the user’s context from your website. Smart App Banners automatically determine whether the app is supported on the user’s device. If the device loading the banner does not support your app, or if your app is not available in the user's location, the banner will not display. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 84 Promoting Apps with Smart App BannersImplementing a Smart App Banner on Your Website To add a Smart App Banner to your website, include the following meta tag in the head of each page where you’d like the banner to appear: You can include three comma-separated parameters in the content attribute: ● app-id: (Required.) Your app's unique identifier. To find your app ID from the iTunes Link Maker, type the name of your app in the Search field, and select the appropriate country and media type. In the results, find your app and select iPhone App Link in the column on the right. Your app ID is the nine-digit number in between id and ?mt. ● affiliate-data: (Optional.) Your iTunes affiliate string, if you are an iTunes affiliate. If you are not, find out more about becoming an iTunes affiliate at http://www.apple.com/itunes/affiliates/. ● app-argument: (Optional.) A URL that provides context to your native app. If you include this, and the user has your app installed, she can jump from your website to the corresponding position in your iOS app. Typically, it is beneficial to retain navigational context because: ● If the user is deep within the navigational hierarchy of your website, you can pass the document’s entire URL, and then parse it in your app to reroute her to the correct location in your app. ● If the user performs a search on your website, you can passthe query string so thatshe can seamlessly continue the search in your app without having to retype her query. ● If the user isin the midst of creating content, you can passthe session ID to download the web session state in your app so she can nondestructively resume her work. You can generate the app-argument of each page dynamically with a server-side script. You can format it however you'd like, as long as it is a valid URL. Note: You cannot display Smart App Banners inside of a frame. Providing Navigational Context to Your App In your app, implement the application:openURL:sourceApplication:annotation: method in your app delegate, which fires when your app is launched from a URL. Then provide logic that can interpret the URL that you pass. The value you set to the app-argument parameter is available as the NSURL url object. Promoting Apps with Smart App Banners Implementing a Smart App Banner on Your Website 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 85The example in Listing 7-1 (page 86) illustrates a website that passes data to a native iOS app. To accomplish this, detect if the URL contains the string /profile. If it does, then open the profile view controller and pass the profile ID number that is in the query string. Listing 7-1 Routing the user to the correct view controller - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { // in this example, the URL from which the user came is http://example.com/profile/?12345 // determine if the user was viewing a profile if ([[url path] isEqualToString:@"/profile"]) { // switch to profile view controller [self.tabBarController setSelectedViewController:profileViewController]; // pull the profile id number found in the query string NSString *profileID = [url query]; // pass profileID to profile view controller [profileViewController loadProfile:profileID]; } return YES; } Promoting Apps with Smart App Banners Providing Navigational Context to Your App 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 86A web application is designed to look and behave in a way similar to a native application—for example, it is scaled to fit the entire screen on iOS. You can tailor your web application for Safari on iOS even further, by making it appear like a native application when the user adds it to the Home screen. You do this by using settings for iOS that are ignored by other platforms. For example, you can specify an icon for your web application used to represent it when added to the Home screen on iOS, as described in “Specifying a Webpage Icon for Web Clip” (page 87). You can also minimize the Safari on iOS user interface, as described in “Changing the Status Bar Appearance” (page 89) and “Hiding Safari User Interface Components” (page 89), when your web application is launched from the Home screen. These are all optional settings that when added to your web content are ignored by other platforms. Read “Viewport Settings for Web Applications” (page 55) for how to set the viewport for web applications on iOS. Specifying a Webpage Icon for Web Clip iOS Note: The Web Clip feature is available in iOS 1.1.3 and later. The apple-touch-icon-precomposed.png filename is available in iOS 2.0 and later. Support for multiple icons for different device resolutions is available in iOS 4.2 and later. You may want users to be able to add your web application or webpage link to the Home screen. These links, represented by an icon, are called Web Clips. Follow these simple steps to specify an icon to represent your web application or webpage on iOS. ● To specify an icon for the entire website (every page on the website), place an icon file in PNG format in the root document folder called apple-touch-icon.png or apple-touch-icon-precomposed.png. If you use apple-touch-icon-precomposed.png as the filename, Safari on iOS won’t add any effects to the icon. ● To specify an icon for a single webpage or replace the website icon with a webpage-specific icon, add a link element to the webpage, as in: 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 87 Configuring Web Applications In the above example, replace custom_icon.png with your icon filename. If you don’t want Safari on iOS to add any effectsto the icon, replace apple-touch-icon with apple-touch-icon-precomposed. ● To specify multiple icons for different device resolutions—for example, support both iPhone and iPad devices—add a sizes attribute to each link element as follows: The icon that is the most appropriate size for the device is used. If no sizes attribute is set, the element’s size defaults to 57 x 57. If there is no icon that matches the recommended size for the device, the smallest icon larger than the recommended size is used. If there are no icons larger than the recommended size, the largest icon is used. If multiple icons are suitable, the icon that has the precomposed keyword is used. If no icons are specified using a link element, the website root directory is searched for icons with the apple-touch-icon... or apple-touch-icon-precomposed... prefix. For example, if the appropriate icon size for the device is 57 x 57, the system searches for filenames in the following order: 1. apple-touch-icon-57x57-precomposed.png 2. apple-touch-icon-57x57.png 3. apple-touch-icon-precomposed.png 4. apple-touch-icon.png See “Custom Icon and Image Creation Guidelines” for webpage icon metrics. Configuring Web Applications Specifying a Webpage Icon for Web Clip 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 88Specifying a Startup Image iOS Note: Specifying a startup image is available in iOS 3.0 and later. On iOS,similar to native applications, you can specify a startup image that is displayed while your web application launches. This is especially useful when your web application is offline. By default, a screenshot of the web application the last time it was launched is used. To set another startup image, add a link element to the webpage, as in: In the above example, replace startup.png with your startup screen filename. On iPhone and iPod touch, the image must be 320 x 460 pixels and in portrait orientation. Hiding Safari User Interface Components On iOS, as part of optimizing your web application, have it use the standalone mode to look more like a native application. When you use this standalone mode, Safari is not used to display the web content—specifically, there is no browser URL text field at the top of the screen or button bar at the bottom of the screen. Only a status bar appears at the top of the screen. Read “Changing the Status Bar Appearance” (page 89) for how to minimize the status bar. Set the apple-mobile-web-app-capable meta tag to yes to turn on standalone mode. For example, the following HTML displays web content using standalone mode. You can determine whether a webpage is displaying in standalone mode using the window.navigator.standalone read-only Boolean JavaScript property. Changing the Status Bar Appearance If your web application displays in standalone mode like that of a native application, you can minimize the status bar that is displayed at the top of the screen on iOS. Do so using the status-bar-style meta tag. Configuring Web Applications Specifying a Startup Image 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 89This meta tag has no effect unless you firstspecify standalone mode as described in “Hiding Safari User Interface Components” (page 89). Then use the status bar style meta tag, apple-mobile-web-app-status-bar-style, to change the appearance of the status bar depending on your application needs. For example, if you want to use the entire screen, set the status bar style to translucent black. For example, the following HTML sets the background color of the status bar to black: Configuring Web Applications Changing the Status Bar Appearance 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 90Safari supports audio and video viewing in a webpage on the desktop and iOS. You can use audio and video HTML elements or use the embed element to use the native application for video playback. In either case, you need to ensure that the video you create is optimized for the platform and different bandwidths. iOS streams movies and audio using HTTP over EDGE, 3G, and Wi-Fi networks. iOS uses a native application to play back video even when video is embedded in your webpages. Video automatically expands to the size of the screen and rotates when the user changes orientation. The controls automatically hide when they are not in use and appear when the user taps the screen. This is the experience the user expects when viewing all video on iOS. Safari on iOS supports a variety of rich media, including QuickTime movies, as described in “Use Supported iOS Rich Media MIME Types” (page 29). Safari on iOS does not support Flash so don’t bring up JavaScript alerts that ask usersto download Flash. Also, don’t use JavaScript movie controlsto play back video since iOS supplies its own controls. Safari on the desktop supports the same audio and video formats as Safari on iOS. However, if you use the audio and video HTML elements on the desktop, you can customize the play back controls. See Safari DOM Additions Reference for more details on the HTMLMediaElement class. Follow these guidelines to deliver the best web audio and video experience in Safari on any platform: ● Follow current best practices for embedding movies in webpages as described in “Sizing Movies Appropriately” (page 92), “Don’t Let the Bit Rate Stall Your Movie” (page 92), and “Using Supported Movie Standards” (page 92). ● Use QuickTime Pro to encode H.264/AAC at appropriate sizes and bit ratesfor EDGE, 3G, and Wi-Fi networks, as described in “Encoding Video for Wi-Fi, 3G, and EDGE” (page 93). ● Use reference movies so that iOS automatically streams the best version of your content for the current network connection, as described in “Creating a Reference Movie” (page 94). ● Use posterJPEGs(not poster framesin a movie) to display a preview of your embedded movie in webpages, as described in “Creating a Poster Image for Movies” (page 94). ● Make sure the HTTP servers hosting your media files support byte-range requests, as described in “Configuring Your Server” (page 95). ● If your site has a custom media player, also provide direct links to the media files. iOS users can follow these links to play those files directly. 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 91 Creating VideoSizing Movies Appropriately In landscape orientation on iOS, the screen is 480 x 320 pixels. Users can easily switch the view mode between scaled-to-fit (letterboxed) and full-screen (centered and cropped). You should use a size that preserves the aspect ratio of your content and fits within a 480 x 360 rectangle. 480 x 360 is a good choice for 4:3 aspect ratio content and 480 x 270 is a good choice for widescreen content as it keeps the video sharp in full-screen view mode. You can also use 640 x 360 or anamorphic 640 x 480 with pixel aspect ratio tagging for widescreen content. Don’t Let the Bit Rate Stall Your Movie When viewing media over the network, the bit rate makes a crucial difference to the playback experience. If the network cannot keep up with the media bit rate, playback stalls. Encode your media for iOS as described in “Encoding Video for Wi-Fi, 3G, and EDGE” (page 93) and use a reference movie as described in “Creating a Reference Movie” (page 94). Using Supported Movie Standards The following compression standards are supported: ● H.264 Baseline Profile Level 3.0 video, up to 640 x 480 at 30 fps. Note that B frames are not supported in the Baseline profile. ● MPEG-4 Part 2 video (Simple Profile) ● AAC-LC audio, up to 48 kHz Movie files with the extensions .mov, .mp4, .m4v, and .3gp are supported. Any movies or audio files that can play on iPod play correctly on iPhone. If you export your movies using QuickTime Pro 7.2, as described in “Encoding Video for Wi-Fi, 3G, and EDGE” (page 93), then you can be sure that they are optimized to play on iOS. Creating Video Sizing Movies Appropriately 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 92Encoding Video for Wi-Fi, 3G, and EDGE Because users may be connected to the Internet via wired or wireless technology, using either Wi-Fi, 3G, or EDGE on iOS, you need to provide alternate media for these different connection speeds. You can use QuickTime Pro, the QuickTime API, or any Apple applications that provide iOS exporters to encode your video for Wi-Fi, 3G, and EDGE. This section contains specific instructions for exporting video using QuickTime Pro. Follow these steps to export video using QuickTime Pro 7.2.1 and later: 1. Open your movie using QuickTime Player Pro. 2. Choose File > Export for Web. A dialog appears. 3. Enter the file name prefix, location of your export, and set of versions to export as shown in Figure 9-1. Figure 9-1 Export movie panel 4. Click Export. QuickTime Player Pro saves these versions of your QuickTime movie, along with a reference movie, poster image, and ReadMe.html file to the specified location. See the ReadMe.html file for instructions on embedding the generated movie in your webpage, including sample HTML. Creating Video Encoding Video for Wi-Fi, 3G, and EDGE 2012-09-19 | © 2012 Apple Inc. All Rights Reserved. 93Creating a Reference Movie A reference movie contains a list of movie URLs, each of which has a list of tests, as show in Figure 9-2. When opening the reference movie, a playback device or computer chooses one of the movie URLs by finding the last one that passes all its tests. Tests can check the capabilities of the device or computer and the speed of the network connection. Figure 9-2 Reference movie components iPhone over EDGE iPhone over WiFi Computer desktop 80 kbit foo-iPhone-cell.3gp 1 Mbit foo-iPhone.m4v Main Profile foo-desktop.m4v foo-ref.mov If you use QuickTime Pro 7.2.1 or later to export your movies for iOS, as described in “Encoding Video for Wi-Fi, 3G, and EDGE” (page 93), then you already have a reference movie. Otherwise, you can use the MakeRefMovie tool to create reference movies. For more information on creating reference movies see Creating Reference Movies - MakeRefMovie . Also, refer to the MakeiPhoneRefMovie sample for a command-line tool that creates reference movies. For more details on reference movies and instructions on how to set them up see “Applications and Examples” in HTML Scripting Guide for QuickTime . Creating a Poster Image for Movies The video is not decoded until the user enters movie playback mode. Consequently, when displaying a webpage with video, users may see a gray rectangle with a QuickTime logo until they tap the Play button. Therefore, use a poster JPEG as a preview of your movie. If you use QuickTime Pro 7.2.1 or later to export your movies, as described in “Encoding Video for Wi-Fi, 3G, and EDGE” (page 93), then a poster image is already created for you. Otherwise, follow these instructions to set a poster image. If you are using the