ÕªÒª£º±¾ÎÄÌṩMonoTouchƽ̨µÄÍêÕû½éÉÜ£¬Èôó¼ÒÖªµÀµ½ÄÄÀï»ñÈ¡±ØÒªµÄ¹¤¾ß£¬MonoTouchÓÐʲôÑùµÄÏÞÖÆ£¬ÒÔ¼°ÈçºÎ¹¹½¨Ò»¸ö¼òµ¥µÄÓ¦ÓóÌÐò¡£
Ö±µ½×î½ü£¬ÒªÎªÆ»¹ûµÄiPhone¿ª·¢Ó¦ÓóÌÐòµÄΨһѡÔñ¾ÍÊÇһͷÔú½øÆ»¹ûµÄ¿ª·¢ÏµÍ³ÖС£ÕâÒâζ×Å£¬Äã±ØÐë¡°Ô¸Ò⡱ÔÚXCode
IDEÖбàдObjective-C´úÂë¡£¶ÔÓںܶ࿪·¢ÈËÔ±£¬Ñ§Ï°Objective-C±»¿´×÷ÊÇÒ»¸ö¾Þ´óµÄÕϰ¡£Ìرð¶ÔÓÚÄÄЩ´ÓÀ´²»Óõ£ÐÄÄÚ´æ¹ÜÀí¡¢Ö¸ÕëºÍCÓïÑÔÒª¸ºÔð´¦ÀíµÄ¶«Î÷µÄ¿ª·¢ÈËÔ±À´Ëµ£¬¸üÊÇÈç´Ë¡£ Ëæ×ÅMonoTouch¿ò¼Ü£¨NovellµÄMono ProjectµÄÒ»²¿·Ö£©µÄ³öÏÖ£¬ÕâÒ»Çж¼½«¸Ä±ä¡£Mono
ProjectÊÇ΢Èí.NETƽ̨µÄ¿ªÔ´ÊµÏÖ¡£ÆäÔÊÐíÄãÔÚ¼¸ºõÈÎºÎÆ½Ì¨ÉÏÔËÐÐ.NETÓ¦ÓóÌÐò£¬°üÀ¨Apple¡¢FreeBSD¡¢Linux¡¢UnixµÈµÈ¡£MonoTouchÊÇMono
ProjectµÄÐÂ×é³É²¿·Ö£¬ÈÃÄãÄܹ»ÓÃC#ºÍ.NETƽ̨±àд¿ÉÒÔÔËÐÐÔÚiPhoneÉϵÄÓ¦ÓóÌÐò¡£ ±¾ÆªÎÄÕµÄÄ¿µÄ£¬¾ÍÊÇÌṩMonoTouchƽ̨µÄÒ»¸öÍêÕû½éÉÜ£¬Èôó¼ÒÖªµÀµ½ÄÇÀï»ñÈ¡±ØÒªµÄ¹¤¾ß£¬MonoTouchÓÐʲôÑùµÄÏÞÖÆ£¬ÒÔ¼°ÈçºÎ¹¹½¨Ò»¸ö¼òµ¥µÄÓ¦ÓóÌÐò¡£
±³¾°ºÍÏÞÖÆ
¶ÔÓÚ´òËãΪiPhone¿ª·¢Ó¦ÓõÄ.NET¿ª·¢ÈËÔ±¶øÑÔ£¬MonoTouchµÄ³öÏÖÎÞÒÉÊÇÒ»¼þºÃÊ¡£È»¶ø£¬ÔÚ¾ö¶¨´´½¨Ó¦ÓóÌÐò֮ǰ£¬ÓÐһЩÏÞÖÆºÍ±³¾°ÖªÊ¶ÐèÒªÏÈÁ˽âÇå³þ¡£
ËüÈçºÎ¹¤×÷£¿
ÔÚ´´½¨MonoTouchÓ¦ÓóÌÐòµÄʱºò£¬´ó²¿·Ö·ÇUI·½ÃæµÄ.NET 3.5¹¦ÄÜÒÀ¾É¿ÉÓ㬻òÕßһЩ»¹´¦Óڼƻ®Ö®ÖУ¨Èç.NET
4.0µÄ¹¦ÄÜ£©Ò²ÄÒÀ¨ÆäÖС£ÕâÈÃÄã¿ÉÒÔʹÓúܶàÒµÒÑÊìϤµÄ.NET Framework¼¼ÊõÀ´±àдӦÓóÌÐò£¬°üÀ¨Windows
Communication Framework (WCF)¡¢Workflow Foundation (WF)µÈµÈ¡£Ò²°üÀ¨¼¸ºõËùÓеĻùÀà¿â£¨Base
Class Library£¬BCL£©£¬º¸ÇÖîÈçÀ¬»øÊÕ¼¯£¨Garbage Collection£©¡¢Ï̡߳¢Êýѧº¯Êý¡¢System.Net¡¢¼ÓÃܵȡ£ ¶ÔÓÚ¿ÉÓõıê×¼.NET³ÌÐò¼¯ÁÐ±í£¬¼ûhttp://monotouch.net/Documentation/Assemblies¡£MonoTouchÊÇÒ»ÖÖ»ù´¡.NETº¯Êý¿âµÄÌØ±ð¶¨Öư汾£¬ÕâÒ²ÀàËÆSilverlightºÍMoonlightµÄʵÏÖ·½Ê½¡£ ÕâÒâζ×Å£¬ÄãÄܹ»Ê¹ÓÃMonoTouchµÄºËÐijÌÐò¼¯À´±àÒë±ê×¼µÄ.NET 3.5´úÂë³ÉÏàÓ¦µÄº¯Êý¿â£¬²¢ÔÚÄãµÄÓ¦ÓóÌÐòÖÐʹÓÃËüÃÇ¡£Òò´Ë£¬Èç¹ûÄãÓÐÒ»¸öÓÃÓÚÆäËüÓ¦ÓóÌÐòµÄÌØ±ðº¯Êý¿â£¬Æä°üº¬×ÅһЩÓÃÓÚ¹¤³ÌÎÊÌâµÄ¸ß¼¶Êýѧº¯Êý£¬ÄÇôֻÐè¼òµ¥µØ°ÑÕâЩ´úÂë¿â¼ÓÈëµ½ÄãµÄMonoTouch½â¾ö·½°¸ÖУ¬²¢ÒýÓÃËü¡£ÔÚÄã¹¹½¨½â¾ö·½°¸µÄʱºò£¬±àÒëÆ÷¾ÍÀûÓÃMonoTouchºËÐĺ¯Êý¿â¶ÔÆä½øÐбàÒ룬½ÓמÍÄÜÔÚiPhoneÓ¦ÓóÌÐòÖÐʹÓÃËüÁË¡£ MonoTouchÒ²°üÀ¨Ò»Ð©ÔÉúiPhone APIµÄ°ü×°º¯Êý¿â£¬Èç·ÃÎÊλÖã¨Location£¬GPS£©¡¢¼ÓËټơ¢µØÖ·²¾µÈµÄº¯Êý¡£MonoTouchÒ²ÌṩÏàÓ¦µÄ¹¦ÄÜ£¬ÈÃÄãÄܹ»µ÷ÓÃÄÇЩÉÐδ½øÐаü×°µÄÔÉúObjective-Cº¯Êý¿â£¬ËùÒÔÄã¿ÉÒÔÖ±½ÓºÍÏÖ´æµÄObjective-C´úÂë½øÐл¥²Ù×÷¡£
ÎÒÈçºÎ´´½¨Óû§½çÃæ£¨UI£©£¬ÎÒÄÜʹÓÃSilverlightÂð£¿
MonoTouchÓ¦ÓóÌÐòµÄUIÐèҪʹÓÃÆ»¹ûµÄInterface Builder£¨½çÃæ´´½¨Æ÷£¬IB£©Ó¦ÓóÌÐòÀ´´´½¨£¬IBÁ¬Í¬iPhone
SDKÒ»ÆðÌṩ¡£Interface BuilderʹÓÃCocoa Touch£¨Æ»¹ûÓÃÓÚiPhoneµÄUI¿ò¼Ü£©¿Ø¼þ¶ÔÏó£¬ÕâЩ¿Ø¼þ¶ÔÏóÔÚiPhoneÉÏÔÉúÌṩµÄ¡£ÕâÒâζ×Å£¬ÄãÄÜÔÚÓ¦ÓóÌÐòÖÐʹÓÃËùÓеıê×¼
iPhone¿Ø¼þ£¬ÈçÑ¡ÔñÆ÷£¨Pickers£©¡¢»¬¶¯Ìõ£¨Sliders£©¡¢°´Å¥µÈµÈ¡£ ÄãÒ²ÄÜͨ¹ý´úÂëÀ´´´½¨½çÃæ£¬¼´ÊµÀý»¯Cocoa Touch¶ÔÏóºó£¬°ÑËüÃÇÌí¼Óµ½Ó¦ÓóÌÐòµÄÊÓͼ£¨Views£©ÖУ¨¹ØÓÚÊÓͼ£¬ºóÃæ»áÏêϸ½²Êö£©¡£ È»¶ø£¬Äã²»ÄÜÀûÓô«Í³µÄ.NET¼¼Êõ£¬ÈçSilverlight¡¢WPF¡¢WinFormsµÈÀ´´´½¨MonoTouch½çÃæ¡£ Cocoa TouchʹÓÃÒ»ÖÖÈÚºÏÁËMVC£¨Model View Controller£©Ä£Ê½Ë¼ÏëµÄ½á¹¹£¬ÎÒÃǽ«ÔÚºóÃæÒ»ÆªÎÄÕÂÖнéÉÜ¡£
ÎÒÈçºÎ·Ö·¢ÎÒµÄÓ¦Óã¿
MonoTouchÓ¦ÓóÌÐòµÄ·Ö·¢ÍêÈ«ºÍ´«Í³iPhoneÓ¦ÓóÌÐòµÄ·Ö·¢Ò»Ñù£¬¼È¿ÉÒÔͨ¹ýÆ»¹ûApp Store£¬Ò²¿ÉÒÔͨ¹ýÆóÒµ²¿Êð¡£ App StoreÊÇÒ»¸öÔÚÏß×ÊÔ´¿â£¬ÈÃÓû§¿ÉÒÔ¸¶·Ñ¹ºÂò£¨Èç¹û²»ÊÇÃâ·ÑµÄ»°£©ºÍÏÂÔØÓ¦ÓóÌÐò¡£¿ÉÒÔ´ÓiTunesÖзÃÎÊ£¬»òÖ±½Óͨ¹ýiPhone±¾ÉíÀ´·ÃÎÊ¡£ÎªÁ˵õ½Í¨¹ýApp
Store·Ö·¢Ó¦ÓõÄÐí¿É£¬Äã±ØÐëÏòÆ»¹û×¢²á£¬²¢Ö§¸¶Ã¿Äê99ÃÀÔªµÄÄê·Ñ¡£ ÆóÒµ²¿Êð·½Ê½¾ÍÊÇΪ¹«Ë¾¿ª·¢ÄÚ²¿Ó¦ÓóÌÐò£¬²¢·Ö·¢¸øÔ±¹¤µÈÈËԱʹÓã¬ÎÞÐè°ÑÓ¦ÓÃÔÚApp StoreÖÐÁгö¡£
ʲôÊÇÐí¿ÉÄ£ÐÍ£¿
²»ÏñMonoÄÇÑù£¬MonoTouch²»ÊÇ¿ªÔ´µÄ£¬ÇÒÊÇÒ»¸öÊշѲúÆ·¡£ÕâÒâζ×Å£¬Èç¹ûÄã´òË㿪·¢Ò»Ð©Êµ¼ÊµÄÓ¦Ó㬾ͱØÐ빺ÂòÈí¼þÐí¿É¡£ רҵ°æ£¨$399£©¡ª¡ªµ¥¸öµÄ¸öÈË¿ª·¢ÈËÔ±Ðí¿É£¬ÈÃÄã¿ÉÒÔ¿ª·¢Ó¦ÓóÌÐò£¬²¢Í¨¹ýÆ»¹ûApp StoreÀ´·Ö·¢ËüÃÇ¡£ ÆóÒµ°æ£¨$999£©¡ª¡ªµ¥¸öµÄÆóÒµ¿ª·¢ÈËÔ±Ðí¿É£¬ÈÃÄã¿ÉÒÔ¿ª·¢Ó¦ÓóÌÐò£¬²¢Í¨¹ýÆ»¹ûApp StoreÀ´·Ö·¢ËüÃÇ£¬»òÕß½øÐÐÆóÒµ²¿Êð¡£ ÆóÒµ°æ£¬5ÈË£¨$3999£©¡ª¡ªºÍÆóÒµ°æÒ»Ñù£¬Ö»ÊÇÌṩÁË5¸ö×øÏ¯µÄÊÚȨ¡£ ÒÔÉÏËùÓÐÑ¡Ïî¶¼°üÀ¨ÁËÒ»ÄêµÄÃâ·ÑÉý¼¶È¨Òæ¡£ »¹ÓÐÒ»¸öÆÀ¹À°æ±¾£¬ÄãÖ»ÄܰÑÓ¦Óò¿Êðµ½Ä£ÄâÆ÷ÖС£³öÓÚ½éÉܵÄÄ¿µÄ£¬ÎÒÃÇÖ»ÐèÒªÆÀ¹À°æ±¾¾ÍÐС£
MonoTouchÓÐÄÄЩÏÞÖÆ£¿
ûÓм´Ê±£¨JIT£©±àÒë
¸ù¾ÝÆ»¹ûµÄiPhoneÕþ²ß£¬ÈκÎÓ¦ÓóÌÐò¶¼²»Äܰüº¬ÐèÒªJIT±àÒëµÄ´úÂë¡£µ«ÊÇÉԵȣ¬.NETȷʵÄÜÕýÈ·¹¤×÷£¬ÊDz»£¿¶Ô£¬²»¹ýMonoTouchÊÇͨ¹ý°ÑÓ¦ÓóÌÐò±àÒëΪÔÉúµÄiPhone³ÌÐò¼¯À´Ìø¹ýÕâ¸öÏÞÖÆµÄ¡£µ«ÊÇ£¬ÕâÒ²´øÀ´Á˼¸¸öÏÞÖÆ¡£ ·ºÐÍ¡ª¡ª·ºÐÍÊÇÓÉJIT±àÒëÆ÷ÔÚÔËÐÐʱ½øÐÐʵÀý»¯µÄ£¬È»¶ø£¬Mono¾ß±¸Ò»ÖÖÌáǰ£¨Ahead of Time
£¬AOT£©±àÒëµÄģʽ£¬¿ÉÒÔΪÀàËÆList<T>ÕâÑùµÄ·ºÐͼ¯ºÏÉú³É·½·¨ºÍÊôÐÔ¡£¶ø·ºÐÍµÄÆäËûÓ÷¨£¬ÀýÈç·ºÐÍÐé·½·¨¡¢·ºÐÍÀàÐÍÉϵÄ
P/InvokesºÍDictionary<TKey, TValue>ÉϵÄÖµÀàÐÍ£¬¾Í²»±»Ö§³Ö£¨ËäÈ»´æÔÚDictionary<TKey,
TValue>µÄ´úÌæ·½·¨£©¡£ ¶¯Ì¬´úÂëÉú³É¡ª¡ªÒòΪ¶¯Ì¬´úÂëÉú³ÉÒÀÀµÓÚJIT±àÒëÆ÷£¬ËùÒÔ¶ÔÈκζ¯Ì¬ÓïÑÔ±àÒëµÄ¹ý³ÌÒ²²»ÄÜÖ§³Ö¡£°üÀ¨System.Reflection.Emit¡¢
RemotingºÍ¶¯Ì¬ÓïÑÔÔËÐÐʱ£¨DLR£©¡£
C#ÊÇΨһµÄÓïÑÔ
ÁíÍ⣬ĿǰÓÃÓÚ±àдMonoTouchÓ¦ÓóÌÐòµÄΨһ¿ÉÓÃÓïÑÔÊÇC#¡£Visual Basic.NETÓÐÍûÔÚMonoTouchδÀ´µÄ·¢²¼ÖÐÖ§³Ö£¬²»¹ý´Ëʱ´Ë¿ÌÎÒÃDZðÎÞÑ¡Ôñ¡£
ÈëÃÅ
Òª½øÈëΪiPhone´´½¨MonoTouchÓ¦ÓóÌÐòµÄ´óÃÅ£¬ÎÒÃÇÐèÒªÏÂÃæ¼¸Ñù¶«Î÷£º
Ò»¸öʹÓÃIntel CPUµÄMacµçÄÔ£¬ÆäÒª°²×°MacOSX 10.5»ò10.6 £¨Leopard»òSnow
Leopard£© Æ»¹ûµÄiPhone SDK 3.0»ò¸ü¸ß°æ±¾ MonoµÄµ±Ç°°æ±¾ MonoTouch SDK Ò»¸öIDE¹¤¾ß£¬ÈçMonoDevelop»òXCode£¬»òÒ»¸öÎı¾±à¼Æ÷³ÌÐò
°²×°×ÅLeopard»òSnow LeopardµÄMac
ÕâÊÇ×îÖØÒªÒ²ÊÇ×îÈÝÒ׺öÊÓµÄÐèÇó¡£¾¡¹Ü£¬ÀíÂÛÉÏÄãÄÜÔÚÈÎºÎÆ½Ì¨ÉÏ¿ª·¢´ó²¿·ÖÓ¦ÓóÌÐò£¬È»¶øiPhone SimulatorºÍInterface
BuilderÖ»ÄÜÔÚLeopardºÍSnow LeopardÉÏÔËÐС£ÁíÍ⣬±àÒëÆ÷±¾ÉíÓõ½ÁËÒ»Ð©ÌØ¶¨ÓÚIntel
Mac»úÆ÷µÄµ×²ã¹¦ÄÜ£¬ËùÒÔ¹ºÂòÕâÑùһ̨µçÄÔÊǾø¶Ô±ØÐëµÄ¡£
Æ»¹ûµÄiPhone SDK
iPhone SDK¿Éͨ¹ýhttp://developer.apple.com/iphone/À´Ãâ·ÑÏÂÔØ£¬²»¹ý±ØÐëÔÚÆ»¹ûÍøÕ¾ÉÏ×¢²á£¬²ÅÄÜ·ÃÎÊÕâ¸öµØÖ·¡£ ÔÚ°²×°ÁËiPhone SDKºó£¬ÒªÈ·±£ÄãÄÜÕý³£Æô¶¯iPhone Simulator¡£ÒªÆô¶¯Ëü£¬Ö»Ðè´ò¿ªSpotlight£¬¼üÈëiPhone
Simulator¡£
Mono
Ò»µ©Äã²âÊÔiPhone SimulatorÕý³££¬ÄÇô¾ÍÒª°²×°Mono for OSXµÄ×îа档 Mono¿ÉÒÔ´Óhttp://mono-project.com/DownloadsÏÂÔØ¡£¼ÇסҪµã»÷¡°Intel¡±°æ±¾µÄÁ´½Ó£¬²»ÒªµãCSDK°æ±¾¡£Í¬Ñù£¬°²×°MonoTouch
SDK֮ǰҲÐèÒª°²×°MonoµÄ¡£MonoµÄ°²×°°üÊÇ´ÅÅ̾µÏñµÄÐÎʽ£¬¹Ò½Ó¾µÏñ£¬Ë«»÷°²×°°ü£¬¸ù¾Ý°²×°Ïòµ¼Íê³É°²×°¹ý³Ì¡£
MonoTouch SDK
½ÓÏÂÀ´£¬ÏÂÔØºÍ°²×°×îеÄMonoTouch SDK¡£ Äã¼È¿ÉÒÔÔÚMonoTouchÉ̵꣨http://monotouch.net/Store£©¹ºÂò£¬¹ºÂòºó»áÊÕµ½Ò»¸öÏÂÔØÁ´½Ó£¬Ò²¿ÉÒÔ´Óhttp://monotouch.net/DownloadTrialÏÂÔØÆÀ¹À°æ¡£Èç¹û¹ºÂòÁËMonoTouch£¬Äã¾ÍÄܰÑÓ¦ÓóÌÐò²¿Êðµ½Ò»Ì¨ÕýÈ·ÅäÖÃÁ˵ÄiPhoneÉÏ£¬²»¹ýÒ²¿ÉÏñÎÒÕâÑù£¬½ö½öÔÚÄ£ÄâÆ÷ÖÐÔËÐС£ËùÒÔ£¬Ä¿Ç°¶øÑÔÊÔÓÃ/ÆÀ¹À°æ¾Í×ã¹»ÁË¡£
Îı¾±à¼Æ÷»ò¼¯³É¿ª·¢»·¾³£¨IDE£©
Èç¹ûÄã´òËã´´½¨MonoTouchÓ¦ÓóÌÐò£¬ËùÐèµÄËùÓж«Î÷¾ÍÊÇÇ°ÃæÌá¼°µÄ£¬ºÍÒ»¸öÎı¾±à¼Æ÷¡£ÄãÄÜ´´½¨ËùÓдúÂëÎļþ£¬²¢ÓÃÃüÁîÐУ¨ÖÕ¶Ë´°¿Ú£©À´ÊÖ¶¯±àÒë¡£ÕâÖÖ·½Ê½ËäÈ»¿ÉÐУ¬µ«ÊÇʵ¼Ê²Ù×÷ÆðÀ´¿ÉÄÜ»á·Ç³£Í´¿à£¬ËùÒÔÎÒÃÇ»¹ÊÇÐèҪʹÓÃÒ»¸öIDEÀ´¿ª·¢ÎÒÃǵÄÓ¦ÓóÌÐò¡£ Äã¿ÉÒÔ±à¼/hackÒ»ÏÂXCode£¨ËæiPhone SDKÒ»Æð°²×°£©À´ÀûÓÃMonoTouchµÄº¯Êý¿âºÍ±àÒëÆ÷£¬Ò²¿ÉÒÔʹÓÃMonoTouch°æµÄMonoDevelop£¬ÆäÒѾΪMonoTouchÓ¦ÓóÌÐò×öºÃËùÓÐÅäÖÃÁË¡£ÎÒÃÇÀíËùµ±È»ÒªÓÃMonoDevelop£¬ËùÒÔ·ÃÎÊÕâÀïhttp://monodevelop.com/Download/Mac_MonoTouchÀ´ÏÂÔØËü¡£Òª°²×°MonoDevelop£¬Ö»ÓðÑÏÂÔØÎļþÍϵ½Ó¦ÓóÌÐòĿ¼ÖоÍÐС£ Èç¹ûÄãÒѾÕýÈ·°²×°Mono£¬ÄÇôMonoDevelopÓ¦¸Ã¿ÉÒÔÕý³£Æô¶¯¡£
Hello WorldÓ¦ÓóÌÐò
ÏÖÔÚ£¬Ò»ÇÐÒѾ׼±¸Í×µ±£¬ÈÃÎÒÃÇ¿ªÊ¼À´³¢ÊÔ¿ª·¢µã¶«Î÷ÁË¡£
MonoDevelop
Ê×ÏÈ£¬Æô¶¯MonoDevelop¡£ÄãÓ¦¸Ã»á¿´µ½ºÍÏÂͼÀàËÆµÄ½çÃæ¡¾ÒëÕß×¢£ºÈç¹ûOSXµÄÊ×Ñ¡ÓïÑÔÊÇÖÐÎĵϰ£¬MonoDevelopµÄ²Ëµ¥ºÍ¹¤¾ßÀ¸µÄÎÄ×ÖÏÔʾ²»Õý³££¬ËùÒÔ×îºÃ°ÑEnglishÍϵ½ÓïÑÔÑ¡ÏîµÄµÚһλ¡¿£º

×÷Ϊһ¸ö±ê×¼µÄIDE£¬¿´ÉÏÈ¥»¹ÊÇÂùÊìϤµÄ¡£Ëü·Ç³£ÀàËÆVisual Studio¡¢SharpDevelop¡¢Visual
C# ExpressµÈµÈ¡£
ÎÒÃÇ´´½¨Ò»¸öнâ¾ö·½°¸£¬À´°üº¬iPhoneÏîÄ¿¡£ÕâÀïµÄ½â¾ö·½°¸ºÍVisual
StudioÖеĸÅÄîÒ»Ñù£¬Êµ¼ÊÉÏÄã¿ÉÒÔÔÚMonoDevelopÖдò¿ªVisual Studio´´½¨µÄ½â¾ö·½°¸¡£ÔÚMonoDevelopÖеÄÒ»¸ö²»Í¬µã¾ÍÊÇ£¬ÄãÄܹ»ÔÚÒ»¸öMonoDevelopʵÀýÖдò¿ª¶à¸ö½â¾ö·½°¸£¬ÕýÈçÏÂÃæµÄ½ØÍ¼Ëùʾ£º

ÕâÍêÈ«ÊÇÓÉÓÚÔÚOSXÖУ¬Äã²»ÄÜÆô¶¯MonoDevelopµÄ¶à¸öʵÀý£¨ÊÂʵÉÏ£¬ÈκγÌÐò¶¼²»ÐУ©£¬ÇÒûÓÐÈκαäͨ·½·¨¡£ËùÒÔ£¬Èç¹ûÄãÐèÒªÔÚ½â¾ö·½°¸¼äÇл»£¨ÀýÈ磬ÄãÏ£ÍûÁíÍâ´ò¿ªÒ»¸ö°üº¬Ê¾Àý´úÂëµÄ½â¾ö·½°¸£©£¬Äã¾ÍÄܼòµ¥µØÒ»´ÎÐÔ´ò¿ª¶à¸ö¡£
ÄÇô£¬ËµÁËÉÏÃæÕâô¶à£¬ÈÃÎÒÃÇÏÖÔÚÀ´´´½¨Ò»¸ö½â¾ö·½°¸°É¡£Ôڲ˵¥ÖУ¬µãFile£ºNew£ºSolution£º

ÎÒÃÇÒª´´½¨Ò»¸öÈçÏÂÃæ½ØÍ¼ËùʾµÄ¡°iPhone MonoTouch Project¡±¡£Ñ¡ÖУ¬ÃüÃûΪExample_HelloWorld_1¡£

ÕâÀïÔٴκÍVisual StudioÖд´½¨Ð½â¾ö·½°¸µÄ¶Ô»°¿òºÜÀàËÆ¡£µã»÷Forward
£¬ÏÔʾÏÂÒ»ÆÁ£¬Ö±½Óµã»÷OK£¬ÒòΪÎÒÃDz»ÐèÒªÕâЩ¹¦ÄÜ£º

ÄãÏÖÔÚÓ¦¸Ã¿ÉÒÔ¿´µ½ÈçÏÂËùʾµÄ½â¾ö·½°¸ÊÓͼÁË£¨×¢Ò⣬ÎÒÕ¹¿ªÁ˽â¾ö·½°¸ÖеĽڵ㣬ÒÔ±ãÏÔʾ³öËùÓÐÎļþºÍÒýÓóÌÐò¼¯£©£º

ÎÒÃÇÀ´¹ýÒ»±éÕâЩ¶«Î÷£º
References ¡ª¡ªÕâ¸öÎļþ¼Ð°üº¬MonoTouchÓ¦ÓóÌÐòÐèÒªµÄ»ù±¾ÒýÓá£MonoTouch³ÌÐò¼¯°üÀ¨Ìض¨ÓÚiPhoneµÄÈκζ«Î÷£¬Ò²°üÀ¨ÁËËùÓÐCocoa
Touch¿Ø¼þµÄ°ü×°Æ÷£¬ÒÔ¼°ÀàËÆÎ»Öá¢Êý¾ÝµÈºËÐÄiPhone½Ó¿Ú¡£ÒÔSystem.¿ªÍ·µÄ³ÌÐò¼¯ÊÇ.NETµÄ»ùÀà¿âºÍÔËÐÐʱ£¬Æä±»²Ã¼õ¹ýÒÔ±ãÄÜÔËÐÐÔÚ
iPhoneÉÏ¡£ Main.cs ¡ª¡ªÕâºÍ¿ØÖÆÌ¨Ó¦ÓóÌÐò¡¢WPFÓ¦ÓóÌÐòµÈÊÇÒ»Öµġ£ÔÚÕâÀïµ÷ÓõÄÊÇstatic void
main() £¬ÆäÊÇ×÷ΪӦÓóÌÐòµÄÈë¿Úµã¡£¹ýÒ»ÏÂÎÒÃÇ»á×ÐϸÑо¿Ò»ÏÂÕâ¸öÎļþ¡£ MainWindow.xibºÍMainWindow.xib.designer.cs ¡ª¡ªÕâ¸öºÍWinforms
Window»òWPF WindowÀàËÆ¡£xibÎļþʵ¼ÊÉÏÒªÔÚInterface BuilderÖнøÐб༣¬¶ødesigner.csÎļþ°üº¬Õâ¸ö´°ÌåµÄÊôÐÔ¡£ ÈÃÎÒÃÇÀ´×ÐϸÑо¿Ò»ÏÂMain.csÎļþÖеĴúÂ룺
using System;using System.Collections.Generic; using System.Linq; using MonoTouch.Foundation; using MonoTouch.UIKit; namespace Example_HelloWorld_1 { public class Application { static void Main (string[] args) { UIApplication.Main (args); } } // The name AppDelegate is referenced in the MainWindow.xib file. public partial class AppDelegate : UIApplicationDelegate { // This method is invoked when the application has loaded its UI and its ready to run public override bool FinishedLaunching (UIApplication app, NSDictionary options) { // If you have defined a view, add it here: //window.AddSubview(navigationController.View); window.MakeKeyAndVisible (); return true; } // This method is required in iPhoneOS 3.0 public override void OnActivated (UIApplication application) { } } } |
ÆäÖÐÓÐÁ½¸öÓÐȤµÄµØ·½¡£Ëü°üº¬Ò»¸öApplicationÀàºÍÒ»¸öAppDelegateÀà¡£´ÓÕâÀ↑ʼ£¬ºÍ´«Í³µÄ.NET
GUI¿ª·¢¾ÍÓÐËù²»Í¬ÁË¡£ iPhoneÓ¦ÓóÌÐòµÄ¹¤×÷·½Ê½ÊÇ£¬Ó¦ÓóÌÐòÀࣨ¼Ì³ÐÓÚUIApplication£©°üº¬ÁËËùÓд°¿Ú¡¢ÊÓͼ¡¢¿Ø¼þºÍ×ÊÔ´µÈµÈ£»Í¬Ê±Ó¦ÓóÌÐòίÍÐÀàÖУ¨¼Ì³ÐÓÚUIApplicationDelegate£©´¦ÀíÀ´×ÔiPhone
OSµÄ»Øµ÷£¬Êµ¼ÊÉÏ»á°üÀ¨Ó¦ÓóÌÐòÔËÐÐÖÜÆÚ£¨Lifecycle£©µÄʼþ£¨ÀýÈçÓ¦ÓóÌÐòÆô¶¯ºÍÓ¦ÓóÌÐòÖÕÖ¹£©ºÍ´óÁ¿µÄÔËÐÐʱʼþ£¨ÀýÈçµÍÄڴ汨¾¯£©¡£ ͨ¹ýÔÚÓ¦ÓóÌÐòίÍÐÀà´¦ÀíÕâЩʼþ£¬Äã¾ÍÄܹ»ÏìÓ¦ËüÃÇ¡£±ÈÈ磬ÔÚÓ¦ÓóÌÐò¹Ø±ÕµÄʱºò£¬WillTerminate()·½·¨½«±»µ÷Óã¬ÕâÑù¾ÍÓлú»áÈ¥±£´æÈκÎÓû§Êý¾Ý¡¢Ó¦ÓóÌÐò״̬µÈ¡£ ÔÚApplicationÀàÖУ¬¾ßÓÐÒ»¸öMain()·½·¨¡£µ÷ÓÃUIApplication.Main£¬Objective-CÔËÐÐʱ½«²éÕÒMainWindow.xibÎļþ£¨Ëü°üº¬ÁË
UIApplicationDelegateÀàµÄÃû³Æ£©£¬ÊµÀý»¯ApplicationÀࣨΪµ¥ÊµÀý£©ºó£¬¾Í½Ó×ŵ÷ÓÃAppDelegateÀàÖÐÔËÐÐÖÜÆÚʼþ¡£ Äã²»±Ø°ÑÖ÷´°ÌåµÄÃû³ÆÃüÃûΪ¡°MainWindow.xib¡±£¨¼´ËùνµÄÖ÷½çÃæÎļþ£©¡£Äã¿ÉÒÔÈÎÒâÃüÃûËü£¬Ö»Ðè¸æÖª±àÒëϵͳȥ²éÕÒÄĸöÎļþ¾ÍÐС£Èç¹ûÄãÏ£ÍûËüÈ¥²éÕÒ²»Í¬µÄÎļþ£¬ÔÚÏîÄ¿ÎļþÉÏÓÒ¼ü´ò¿ªÏîĿѡÏµã»÷Options
£¬½Ó×ÅÔÚBuild : iPhone Application : Main Interface FileÖм´¿ÉÉèÖÃÖ÷´°Ìå¶ÔÓ¦µÄÎļþ¡£ÔÚÓ¦ÓóÌÐòÆô¶¯µÄʱºò£¬Objective-CÔËÐÐʱ½«»á³¢ÊÔÈ¥¼ÓÔØÄǸöÎļþ£¬²¢¸ù¾ÝÕâ¸öÎļþÄÚµÄÉèÖÃÀ´²éÕÒÓ¦ÓóÌÐòίÍÐÀà¡£ ÁíÍ⣬ÄãÒ²¿ÉÒÔÈÎÒâÃüÃûÄãµÄÓ¦ÓóÌÐòίÍÐÀࡣĬÈÏÇé¿öÏ£¬ËüµÄÃû³ÆÎª¡°AppDelegate¡±¡£Òª¸Ä±äËü£¬ÔÚInterface
BuilderÖдò¿ªÖ÷½çÃæÎļþ£¬ÐÞ¸ÄApplication DelegateµÄÃû³Æ¡£ Ò»»áÎÒÃÇ»á»Øµ½Main.csÎļþÉÏÀ´£¬²»¹ýÊ×ÏÈÀ´ÉîÈëÑо¿ÏÂÓ¦ÓóÌÐòµÄʵ¼ÊGUI¡£
Interface Builder
ĿǰΪֹ£¬ÒѾ¶Áµ½ÁËÎÒÃǵÄiPhoneÓ¦ÓóÌÐòµÄ²¿·Ö´úÂ룬¿ÉÒÔÉîÈëÑо¿Ò»ÏÂÈçºÎ¹¹½¨ËüµÄ½çÃæÁË¡£Æ»¹ûµÄÓ¦ÓóÌÐòÉè¼Æ¹¤¾ß°ü³ÆÖ®ÎªInterface
Builder¡£Interface Builder¿ÉÒԺͿª·¢»·¾³ËÉñîºÏ¡£Ëü¿ÉÒÔ±à¼ÄÇЩ¶¨ÒåÓ¦ÓóÌÐòGUIµÄ.xibÎļþ¡£NIBºÍXIBµÄ±È½Ï£ºNibÎļþ°üº¬ÁË´°¿Ú¡¢¿Ø¼þµÈµÄXML±íʾ£¬ÀàËÆÓÚWPF/SilverlightÖеÄXAMLÄ£ÐÍ¡£ ²»¹ÜÊÇÔÚXCodeÖбàдObjective-C£¬»òÔÚMonoDevelopÖбàдC#£¬Interface
BuilderµÄÓ÷¨¶¼ÊÇÍêȫһÑùµÄ¡£ÄÜÕâÑù£¬ÍêÈ«ÊÇÒòΪMonoDevelopÄܹ»¼à²âNibÎļþµÄ±ä¸ü£¬²¢Ìí¼Ó/ɾ³ý¶ÔÓ¦ÓÚNibÎļþµÄÊʵ±´úÂëµ½
designer.csÎļþÖС£ Ä㵱Ȼ¿ÉÒÔ²»´ò¿ªInterface Builder£¬´¿´âͨ¹ý±à³ÌÀ´´´½¨Õû¸öGUI£¬ÓÐЩ¿ª·¢ÈËԱȷʵҲÊÇÕâÑù×öµÄ¡£ºÜ¶àÊÂÇéÔÚInterface
BuilderÒ²ÎÞ·¨Íê³É£¬¾Í´Ë¶øÑÔ£¬Ä㻹ÊÇÐèÒª±à³ÌÀ´Íê³ÉijЩÊÂÇé¡£Interface BuilderÒþ²ØÁËһЩ¸´ÔӵIJ¿·Ö£¬ÔÚÈëÃŵÄʱºò£¬ºÜÈÝÒ×ʹÓÃInterface
BuilderÀ´ÊìϤiPhoneÓ¦ÓóÌÐòGUIµÄһЩ¸ÅÄî¡£
ÄÇô£¬ËµÁËÕâô¶à£¬ÈÃÎÒÃÇÀ´×ÅÊÖ´´½¨½çÃæÁË¡£ÔÚMainWindow.xibÎļþÉÏË«»÷¡£Interface
Builder½«Æô¶¯£¬²¢ÄÜ¿´µ½ÈçÏÂͼËùʾµÄ¶«Î÷£º

ÈÃÎÒÃÇÖðÒ»Ñо¿Ò»ÏÂÕâЩ´°¿Ú¡£´Ó×óµ½ÓÒ£¬·Ö±ðÊÇ£ºDocument Window£¨Îĵµ´°¿Ú£©¡¢Design
Surface Window£¨Éè¼Æ½çÃæ´°¿Ú£©¡¢Library Window£¨¿Ø¼þ¿â´°¿Ú£©ºÍInspector
Window£¨¼ì²éÆ÷´°¿Ú£©¡£
Ê×ÏÈÈÃÎÒÃÇÀ´¿´Document Window£º

Õâ¸ö´°¿ÚÏÔʾÁËÔÚ.xibÎļþÖеÄËùÓжÔÏó¡£ÕâÊÇĬÈϵÄÊÓͼ£¬Äã»á·¢ÏÖËüËäÈ»Ñù×ÓÆ¯ÁÁ£¬µ«Ã»ÓÐÌ«´óÓô¦£¬ÒòΪÄãµÄ¶ÔÏóʵ¼ÊÉÏÊDz㼶ÅÅÁе쬶øÍ¼±êÊÓͼֻÄÜͬʱÏÔʾһ¼¶¡£ÔÚÎÒÃÇÌí¼Ó¿Ø¼þµ½½çÃæÉϵÄʱºò£¬Ëü²»»áÏÔʾÔÚÕâ¸öÊÓͼÖС£ËùÒÔ£¬ÎÒÃÇÐèҪͨ¹ýµã»÷View
Mode¹¤¾ßÌõÉÏÖмäµÄͼ±êÀ´¸Ä±äÁбíÊÓͼ¡£¸Ä±äºó£¬Ó¦¸Ã»áÏÔʾÈçϵÄÑù×Ó£º

ÏÂÒ»¸ö´°¿ÚÊÇÉè¼Æ½çÃæ¡£Ò²¾ÍÊÇ£¬ÎÒÃÇʵ¼ÊÍÏ×§Cocoa Touch¿Ø¼þÀ´Éè¼ÆÎÒÃǽçÃæµÄµØ·½£º

µ±È»£¬ÓÉÓÚÎÒÃÇÉÐδÌí¼ÓÈκοؼþµ½ÉÏÃæ£¬ËùÒÔÏÖÔÚ»¹ÊÇһƬ¿Õ°×¡£
ÏÂÒ»¸ö´°¿ÚÊÇLibrary¡£Library°üº¬ÁËËùÓÐÄÜÔÚÉè¼Æ½çÃæÉÏʹÓõÄCocoa
Touch¿Ø¼þ¡£Èç¹ûÄãÔËÐÐLeopard¡¾ÒëÕß×¢£ºÔÎÄÕâÀïΪSnow Leopard£¬Êµ¼ÊÊÇ´íÎóµÄ¡£¡¿£¬ÄÇôÄãµÄ¿Ø¼þ¿â´°¿ÚÈçÏÂËùʾ£º

Èç¹ûÄãÔËÐÐSnow Leopard¡¾ÒëÕß×¢£ºÔÎÄÕâÀïδLeopard£¬Êµ¼ÊÊÇ´íÎóµÄ¡£¡¿£¬ËüÓ¦¸ÃÊÇÕâ¸öÑù×Ó£º

×¢ÒâËüÃÇÁ½Õß»¹ÊǷdz£ÀàËÆµÄ¡£ÔÚSnow LeopardÀÓÐÒ»¸öÃûΪ¡°Classes¡±µÄ±êǩҳ£¬ÎÒÃǺóÃæ»á½²µ½Õâ¸ö¶«Î÷£¬²»¹ýÕâÒ²ÊÇΨһµÄ²»Í¬µã¡£
ÕâÊÇLibraryµÄĬÈÏÊÓͼ£¬²»¹ýÎÒϲ»¶ÉÔ΢²»Í¬µÄÑù×Ó£¬ÒÔ±ãÎÒÄÜһϿ´µ½¸ü¶àµÄ¿Ø¼þ¡£ÎªÁ˸ıäLibrary´°¿ÚÖеÄÊÓͼ£¬ÓÒ¼üµã»÷¿Ø¼þÊÓͼ£¬¿ÉÒÔÑ¡Ôñ²»Í¬µÄÏÔʾ·ç¸ñ¡£ÄãÒ²¿ÉÒÔµã»÷´°¿Ú×óϽǵÄGear£¨³ÝÂÖ£©°´Å¥¡£ÏÂͼÊÇLeopardÖеġ°icons
and labels¡±·ç¸ñ£º

¶øÔÚSnow LeopardÖÐÊÇ£º

×îºóÒ»¸ö´°¿ÚÊÇInspector Window£º

Inspector¾ßÓÐËÄÖÖ²»Í¬µÄÊÓͼ£¬¿ÉÒÔͨ¹ý´°¿Ú¶¥²¿µÄ±êÇ©À¸À´Ñ¡Ôñ¡£ÕâЩÊÓͼ·Ö±ðÊÇAttribute
Inspector¡¢Connections Inspector¡¢Size InspectorºÍIdentity
Inspector¡£Inspector´óÖºÍVisual StudioÖеÄProperty ExplorerÀàËÆ¡£ËüÏòÄãÏÔʾµ±Ç°Ñ¡ÖеÄCocoa
Touch¶ÔÏóµÄËùÓÐÊôÐÔ¡£Ò²¿ÉÒÔÓÃËüÀ´ÉèÖÿÉÊÓ»¯ÊôÐÔ¡¢²¼¾ÖµÈµÈ¡£ÔÚ´´½¨OutletsºÍActionsʱҲÓõÃ×ÅËü£¬Õâ¸öÖ÷ÌâºóÃæ»á̸µ½¡£ÔÚÏÂÃæµÄͼƬÖУ¬ÎÒÃÇÔÚDocument´°¿ÚÖÐÑ¡ÔñÁËWindow¶ÔÏó£¬ËùÒÔÎÒÃÇ¿ÉÒԲ鿴Õâ¸ö¶ÔÏóµÄÏà¹ØÊôÐÔ¡£
ÏÖÔÚ£¬ÎÒÃǶÔInterface Builder´°¿ÚÒѾ´óÖÂä¯ÀÀÁËÒ»±é£¬½ÓÏÂÀ´ÈÃÎÒÃÇʵ¼ÊµØ´´½¨Ò»Ð©¶«Î÷¡£ÎÒÃÇÒª´´½¨ÈçÏÂÕâÑùµÄ½çÃæ£º

Ê×ÏÈ£¬ÍÏÒ»¸ö¡°Round Rect Button£¨Ô²½Ç¾ØÐΰ´Å¥£©¡±£¨UIButton£©µ½´°¿ÚÉÏ¡£½Ó×Å£¬ÔÚ°´Å¥ÉÏË«»÷À´ÉèÖÃÎı¾¡£ÔÚÕâ¸ö¹ý³ÌÖÐÄã»á×¢Òâµ½£¬Äã»á»ñµÃÉÙÐíµÄÖ¸µ¼¡£ÕâЩָµ¼ÊÇ»ùÓÚÆ»¹ûµÄÈË»ú½»»¥Ïòµ¼£¨Human
Interface Guidelines£©µÄ£¬À´¸¨ÖúÄãÔÚÊÓͼÉÏÒÔÊʺϵļä¾àµÈÀ´¶¨Î»¿Ø¼þ¡£ ÔÚ´°¿ÚÉÏÌí¼ÓÁ˰´Å¥ºó£¬ÍÏÈëÒ»¸ö¡°Label£¨±êÇ©£©¡±£¨UILabel£©¿Ø¼þ¡£¸Ä±äËüµÄ³ß´çÒÔ±ã½Ó½ü´°¿ÚµÄ¿í¶È¡£½Ó×ÅË«»÷Õâ¸ölabel¿Ø¼þ£¬É¾³ýÎı¾ÒÔʹӦÓóÌÐòÆô¶¯µÄʱºò£¬±êÇ©µÄÄÚÈÝÊǿհ׵ġ£
Èç¹ûÄãÕýÈ·µØÍê³ÉÁËËùÓв½Ö裬ÄÇôÄãµÄDocument Window½«ÏÔʾÈçϵÄÑù×Ó£¨µã»÷¡°Window¡±ÅԱߵļýÍ·¾Í»á¿´µ½Ëü°üº¬µÄ×ӿؼþ£©£º

ÎÒÃÇÏÖÔÚ´´½¨Á˵ÚÒ»¸ö´°¿Ú½çÃæ¡£²»¹ý£¬²»Ïñ´«Í³µÄ.NET GUI¿ª·¢£¬Ä㻹²»Äܱà³Ì·ÃÎÊÕâЩ¿Ø¼þ¡£¼ÙÈçÕâÊÇÒ»¸öWPFÓ¦ÓóÌÐò£¬ÄãÒ»Í϶¯¿Ø¼þµ½Éè¼Æ½çÃæÉÏ£¬Äã¾ÍÄÜͨ¹ýthis.ControlNameÕâÑùµÄÐÎʽÀ´·ÃÎÊËü¡£Èç¹ûÄãÂíÉÏÈ¥²é¿´MainWindow.designer.csÎļþ£¬³ýÁË¡°window¡±ÊôÐÔÍ⣬Äã¿´²»µ½ÈÎºÎÆäËû´úÂ롣ΪÁËÈÃÕâЩ¶ÔÏóÄܱ»´úÂë·ÃÎÊ£¬ÎÒÃDZØÐëͨ¹ýOutlets°ÑËüÃǹØÁªÉÏ¡£ÄãÔÚInterface
BuilderÖд´½¨Ò»¸öOutlet£¨¶ÔÏó¹ØÁª¿Ú£©µÄʱºò£¬MonoDevelop½«ÔÚÕâ¸öÀàµÄdesigner.csÎļþÖÐÌí¼ÓÒ»¸öÆ¥ÅäµÄÊôÐÔ£¬ÈÃÄã¿ÉÒÔ±à³Ì·ÃÎÊÕâЩ¿Ø¼þ¡£
MonoTouch£ºÓÃ.NET¿ª·¢iPhoneÓ¦Óã¨Ï£©
|