WebKitDisplayWebContent.docx
- 文档编号:5603266
- 上传时间:2022-12-28
- 格式:DOCX
- 页数:58
- 大小:159.78KB
WebKitDisplayWebContent.docx
《WebKitDisplayWebContent.docx》由会员分享,可在线阅读,更多相关《WebKitDisplayWebContent.docx(58页珍藏版)》请在冰豆网上搜索。
WebKitDisplayWebContent
WebKitObjective-CProgrammingGuide
Networking,Internet,&Web:
WebClient
2009-07-28
AppleInc.
©2003,2009AppleInc.Allrightsreserved.
Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmitted,inanyformorbyanymeans,mechanical,electronic,photocopying,recording,orotherwise,withoutpriorwrittenpermissionofAppleInc.,withthefollowingexceptions:
AnypersonisherebyauthorizedtostoredocumentationonasinglecomputerforpersonaluseonlyandtoprintcopiesofdocumentationforpersonaluseprovidedthatthedocumentationcontainsApple’scopyrightnotice.
TheApplelogoisatrademarkofAppleInc.Nolicenses,expressorimplied,aregranted
withrespecttoanyofthetechnologydescribed
inthisdocument.Appleretainsallintellectualpropertyrightsassociatedwiththetechnologydescribedinthisdocument.ThisdocumentisintendedtoassistapplicationdeveloperstodevelopapplicationsonlyforApple-labeledcomputers.
AppleInc.
1InfiniteLoop
Cupertino,CA95014
408-996-1010
Apple,theApplelogo,Carbon,Cocoa,Mac,MacOS,Objective-C,Pages,QuickTime,Safari,andXcodearetrademarksofAppleInc.,registeredintheUnitedStatesandothercountries.
WebScriptisatrademarkofAppleInc.
JavaisaregisteredtrademarkofOracleand/oritsaffiliates.
EventhoughApplehasreviewedthisdocument,APPLEMAKESNOWARRANTYORREPRESENTATION,EITHEREXPRESSORIMPLIED,WITHRESPECTTOTHISDOCUMENT,ITSQUALITY,ACCURACY,MERCHANTABILITY,ORFITNESSFORAPARTICULARPURPOSE.ASARESULT,THISDOCUMENTISPROVIDED“ASIS,”ANDYOU,THEREADER,AREASSUMINGTHEENTIRERISKASTOITSQUALITYANDACCURACY.
INNOEVENTWILLAPPLEBELIABLEFORDIRECT,INDIRECT,SPECIAL,INCIDENTAL,ORCONSEQUENTIALDAMAGESRESULTINGFROMANYDEFECTORINACCURACYINTHISDOCUMENT,evenifadvisedofthepossibilityofsuchdamages.
THEWARRANTYANDREMEDIESSETFORTHABOVEAREEXCLUSIVEANDINLIEUOFALLOTHERS,ORALORWRITTEN,EXPRESSORIMPLIED.NoAppledealer,agent,oremployeeisauthorizedtomakeanymodification,extension,oradditiontothiswarranty.
Somestatesdonotallowtheexclusionorlimitationofimpliedwarrantiesorliabilityforincidentalorconsequentialdamages,sotheabovelimitationorexclusionmaynotapplytoyou.Thiswarrantygivesyouspecificlegalrights,andyoumayalsohaveotherrightswhichvaryfromstatetostate.
Contents
IntroductiontoWebKitObjective-CProgrammingGuide9
WhatIstheWebKit?
9
WhoShouldReadThisDocument?
9
OrganizationofThisDocument10
SeeAlso11
WhyUsetheWebKit?
13
CoreWebKitClasses15
FrameModelandViewClasses15
DataModelandViewClasses16
Provisionalvs.CommittedDataSources17
WebViewDelegates18
SimpleBrowsing21
MultipleWindows23
OpeningWindows23
EnteringURLs23
HandlingNewWindowRequests24
LoadingPages27
SequenceofFrameLoadDelegateMessages27
TestingfortheMainFrame28
DisplayingtheCurrentURL28
DisplayingthePageTitle28
DisplayingLoadStatus29
LoadingResources31
SequenceofResourceLoadDelegateMessages31
IdentifyingResources31
TrackingResourceLoadProgress32
PagingBackandForward35
EnablingandDisablingtheBack-ForwardList35
AddingBackandForwardButtons35
3
2009-07-28|©2003,2009AppleInc.AllRightsReserved.
SettingthePageCache35
SettingtheCapacity36
TheCurrentItem36
ManagingState36
ManagingHistory37
SharingHistoryObjects37
AddingandRemovingHistoryItems37
LoadingaHistoryItem38
SavingandLoadingHistoryObjects38
MakingPolicyDecisions39
EnablingEditing41
SavingandLoadingWebContent43
ModifyingtheCurrentSelection45
ChangingEditingBehavior47
ShouldMethods47
DidMethods47
UsingUndoWhenEditing49
UsingtheDocumentObjectModelfromObjective-C51
InterpretingtheDOMSpecification51
HandlingExceptions53
UsingtheDocumentObjectModelExtensions55
UsingJavaScriptFromObjective-C57
Spoofing59
AccessingtheWebKitFromCarbonApplications61
DeterminingWebKitAvailability63
TestingforURLLoadingSystemAvailability63
4
2009-07-28|©2003,2009AppleInc.AllRightsReserved.
TestingforWebKitAvailability63
IsolatingYourWebKitandURLLoadingSystemSymbols64
ConditionallyLoadingCode64
WeakLinkingSymbols64
DocumentRevisionHistory67
5
2009-07-28|©2003,2009AppleInc.AllRightsReserved.
6
2009-07-28|©2003,2009AppleInc.AllRightsReserved.
FiguresandListings
CoreWebKitClasses15
Figure1WebViewandWebFrameViewobjects16
Figure2WebFrameandWebDataSourceobjects17
Figure3Typicalwebsite18
DeterminingWebKitAvailability63
Listing1DeterminingiftheURLLoadingsystemisavailable.63
Listing2DeterminingiftheWebKitframeworkisavailable63
Listing3LoadingWebKitconstantsdynamicallyusingCFBundle65
7
2009-07-28|©2003,2009AppleInc.AllRightsReserved.
8
2009-07-28|©2003,2009AppleInc.AllRightsReserved.
IntroductiontoWebKitObjective-CProgrammingGuide
ConcurrencyNote:
TheWebKitframeworkisnotthreadsafe.Ifyoucallfunctionsormethodsinthisframework,youmustdosoexclusivelyonthemainprogramthread.
WhatIstheWebKit?
TheWebKitprovidesasetofcoreclassestodisplaywebcontentinwindows,andbydefault,implementsfeaturessuchasfollowinglinksclickedbytheuser.TheWebKitgreatlysimplifiesthecomplicatedprocess
ofloadingwebpages—thatis,asynchronouslyrequestingwebcontentfromanHTTPserveroverthenetworkwheretheresponsemayarriveincrementally,inrandomorder,orpartiallyduetonetworkerrors.TheWebKitalsosimplifiestheprocessofdisplayingcontentthatcancontainvariousMIMEtypes,andmultipleframeseachwiththeirownsetofscrollbars.
YouusetheWebKittodisplaywebcontentinawindowofyourapplication.It’sassimpleascreatingaview,placingitinawindow,andsendingaURLloadrequestmessage.Bydefault,yourWebKitapplicationbehavesasyouwouldexpectwithouterror.TheWebKitconvenientlycreatesandmanagesalltheviewsneededtohandledifferentMIMEtypes.Whentheuserclicksonalinkinapage,theWebKitautomaticallycreatestheviewsneededtodisplaythenextpage.
However,theWebKitdoesn’timplementacompletesetofwebbrowserfeatures.Youcan,however,extendtheWebKitbyimplementingcustomdelegate,view,andmodelobjects.Forexample,youcanimplementadelegatetodisplayloadstatus,andthecurrentURL.
TheWebKitalsoofferswebcontentediting.IfyouenableeditinginyourWebView,userscaneditthewebcontentitdisplays.YoucanprogrammaticallycontrolthecurrentselectionandcontroleditingbehaviorusingaWebViewdelegate.YoucanalsomodifytheDocumentObjectModeldirectlyusinganObjective-CAPI.
YoucanalsoaccessJavaScriptfromObjective-Candviceversa.
WhoShouldReadThisDocument?
TheWebKitObjective-CAPIisspecificallydesignedforembeddingwebcontentinyourCocoaorCarbonapplications—developingwebclientapplicationsnotwebserverapplicationsorwebcontent.Itisalsonotsuitableforimplementingnon-GUIapplicationssuchaswebcrawlers.IfyouareawebcontentcreatororJavaScriptprogrammer,refertoWebKitDOMProgrammingTopics.
WhatIstheWebKit?
9
2009-07-28|©2003,2009AppleInc.AllRightsReserved.
IntroductiontoWebKitObjective-CProgrammingGuide
Important:
Currently,thisAPIisavailableinObjective-Conly.AminimalCAPIisprovidedforembeddingwebbrowserviewsinCarbonapplications.YoucanuseObjective-CincombinationwithC.TheWebKitworkswithallversionsofMacOSX10.2thathaveSafari1.0installed.
OrganizationofThisDocument
ThefollowingarticlescoverkeyconceptsinunderstandinghowtheWebKitworks:
●“WhyUsetheWebKit?
”(page13)describesthepurposeoftheWebKitandwhyyoumightwanttouseitinyourapplications.
●“CoreWebKitClasses”(page15)describesthecoreWebKitclassesandtheobject-orienteddesignthatisfundamentaltounderstandinghowtheWebKitworks.
Thefollowingarticlesexplainhowtodisplaywebcontentinviews:
●“SimpleBrowsing”(page21)showshowtoembedwebcontentinyourapplicationbyfollowingafewsimplesteps.
●“MultipleWindows”(page23)showshowtoaddsupportformultiplewindows,andopenwindowsautomatically.
●“LoadingPages”(page27)showshowtotracktheprogressofloadingframecontent.
●“LoadingResources”(page31)showshowtotracktheprogressofloadingindividualresourcesonapage.
●“PagingBackandForward”(page35)showshowtoimplementaback-forwardlistandaddBackand
Forwardbuttonstoyourapplication.
●“ManagingHistory”(page37)showshowtomaintainahistoryofallthevisitedpages,andallowtheusertogotoapreviouslyvisitedpage.
●“Spoofing”(page59)showshowtouseuser-agentstrings.
●“AccessingtheWebKitFromCarbonApplications”(page61)explainshowtoembedwebcontentin
Carbonapplications.
●“DeterminingWebKitAvailability”(page63)explainshowtodetermineiftheWebKitisavailableonyoursystem.
Thefollowingarticlesexplainhowtoimplementwebcontentediting:
●“EnablingEditing”(page41)showshowtoenableusereditinginaWebView.
●“SavingandLoadingWebContent”(page43)showshowtosaveandloadwebcontenteditedbytheuser.
●“ModifyingtheCurrentSelection”(page45)showshowtoprogrammaticallymodifyth
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- WebKitDisplayWebContent
![提示](https://static.bdocx.com/images/bang_tan.gif)