﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-佳为好友-随笔分类-UI</title><link>http://www.cppblog.com/walkklookk/category/17724.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 02 Jan 2013 14:09:14 GMT</lastBuildDate><pubDate>Wed, 02 Jan 2013 14:09:14 GMT</pubDate><ttl>60</ttl><item><title>原： UISearchDisplayController重用 2</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196850.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:43:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196850.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196850.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196850.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196850.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196850.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2011.03.03</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><br />UISearchDisplayController重用<br /><br />如果2个页面使用同样的搜索逻辑和界面，<wbr>则可以考虑重用UISearchDisplayControll<wbr>er。<br />或者，如果你的搜索页面和平时显示的页面完全不同，<wbr>又不想把这两个逻辑放在一个ViewController里面，<wbr>则也可以使用这种方法。<br /><br />#<wbr>UISearchDisplayController一般都是通<wbr>过IB进行配置的。<wbr>加入SearchBar以及UISearchDisplayCo<wbr>ntroller。<br /><br />#<wbr>在Xib中加入重用的SearchResultViewCont<wbr>roller。<br /><br />#<wbr>在FileOwner中为SearchResultViewCo<wbr>ntroller加入一个IBOutlet。<br /><br />#<wbr>将SearchBar的delegate设定为SearchRe<wbr>sultViewController。<br /><br />#<wbr>将UISearchDisplayController的del<wbr>egate，tableViewDataSource，<wbr>TableViewDelegate设定为SearchResu<wbr>ltViewController。<br /><br />#<wbr>一定不要将UISearchDisplayController<wbr>的searchContentViewController设定<wbr>为SearchResultViewController，<wbr>而要设定为默认的self，否则无法显示Search页面。<wbr>多次测试才发现这个问题的。<br /><br /># 将SearchResultViewController的se<wbr>archDisplayController设定为UISear<wbr>chDisplayController。<br /><br /># 然后，就按照正常的操作进行控制吧。<br /><br />+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196850.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:43 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196850.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：Sizes of iPhone UI Elements</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196849.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:43:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196849.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196849.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196849.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196849.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196849.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2011.03.03</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://www.idev101.com/code/User_Interface/sizes.html" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://www.idev101.com/code/<wbr>User_Interface/sizes.html</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><h2>Sizes of iPhone UI Elements</h2><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p><img src="http://www.idev101.com/code/User_Interface/sizes.png" alt="" height="742" width="630" /></p><table><tbody><tr><th style="background-color: #eeeeee;">Element</th><th style="background-color: #eeeeee;">Size (in points)</th></tr><tr><td style="margin: 0px;">Window (including status bar)</td><td style="margin: 0px;">320 x 480 pts</td></tr><tr><td style="margin: 0px;">Status Bar<br />(<a href="http://www.idev101.com/code/User_Interface/UIStatusBar.html" target="_blank" style="color: #1155cc;">How to hide the status bar</a>)</td><td style="margin: 0px;">20 pts</td></tr><tr><td style="margin: 0px;">View inside window&nbsp;<br />(visible status bar)</td><td style="margin: 0px;">320 x 460</td></tr><tr><td style="margin: 0px;">Navigation Bar</td><td style="margin: 0px;">44 pts</td></tr><tr><td style="margin: 0px;">Nav Bar Image /<br />Toolbar Image</td><td style="margin: 0px;">up to 20 x 20 pts (transparent PNG)</td></tr><tr><td style="margin: 0px;">Tab Bar</td><td style="margin: 0px;">49 pts</td></tr><tr><td style="margin: 0px;">Tab Bar Icon</td><td style="margin: 0px;">up to 30 x 30 pts (transparent PNGs)</td></tr><tr><td style="margin: 0px;">Text Field</td><td style="margin: 0px;">31 pts</td></tr><tr><td style="margin: 0px;">Height of a view inside&nbsp;<br />a navigation bar</td><td style="margin: 0px;">416 pts</td></tr><tr><td style="margin: 0px;">Height of a view inside&nbsp;<br />a tab bar</td><td style="margin: 0px;">411 pts</td></tr><tr><td style="margin: 0px;">Height of a view inside&nbsp;<br />a navbar&nbsp;<em>and</em>&nbsp;a tab bar</td><td style="margin: 0px;">367 pts</td></tr><tr><td style="margin: 0px;">Portrait Keyboard height</td><td style="margin: 0px;">216 pts</td></tr><tr><td style="margin: 0px;">Landscape Keyboard height</td><td style="margin: 0px;">140 pts</td></tr></tbody></table><h3>Points vs. Pixels</h3><p>The iPhone 4 introduced a high resolution display with twice the pixels of previous iPhones. However you don't have to modify your code to support high-res displays; the coordinate system goes by points rather than pixels, and the dimensions in points of the screen and all UI elements remain the same.</p><p>iOS 4 supports high resolution displays (like the iPhone 4 display) via the&nbsp;scale&nbsp;property on UIScreen, UIView, UIImage, and CALayer classes. If the object is displaying high-res content, its scale property is set to 2.0. Otherwise it defaults to 1.0.</p><p>All you need to do to support high-res displays is to provide @2x versions of the images in your project. See the&nbsp;<a href="http://www.idev101.com/code/Distribution/updating_ios4.html#l2" target="_blank" style="color: #1155cc;">checklist for updating to iOS4</a>&nbsp;or Apple documentation for&nbsp;<a href="http://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/SupportingHiResScreens/SupportingHiResScreens.html" target="_blank" style="color: #1155cc;">Supporting High Resolution Screens</a>&nbsp;for more info.</p><h3>Adjusting Sizes</h3><p>Click here to see how to adjust&nbsp;<a href="http://www.idev101.com/code/User_Interface/view_frames_bounds.html" target="_blank" style="color: #1155cc;">View Frames and Bounds</a>.</p><h3>Additional References</h3><ul><li style="margin-left: 15px;">Apple Documentation:&nbsp;<a href="http://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html#//apple_ref/doc/uid/TP40010156-CH14-SW7" target="_blank" style="color: #1155cc;">Points vs. Pixels</a></li><li style="margin-left: 15px;">Apple Documentation:&nbsp;<a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIBarButtonItem_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40007519-CH3-SW3" target="_blank" style="color: #1155cc;">UIBarButtonItem Class Reference</a>&nbsp;says "Typically, the size of a toolbar and navigation bar image is 20 x 20 points."</li><li style="margin-left: 15px;">Apple Documentation:&nbsp;<a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITabBarItem_Class/Reference/Reference.html#//apple_ref/occ/instm/UITabBarItem/initWithTitle:image:tag:" target="_blank" style="color: #1155cc;">UITabBarItem Class Reference</a>&nbsp;says "The size of an tab bar image is typically 30 x 30 points."</li></ul><br clear="all" /><p><a style="color: #1155cc;">Top</a>&nbsp;&#8226;&nbsp;<a href="http://www.idev101.com/" target="_blank" style="color: #1155cc;">Home</a></p></div><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:43 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196849.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：UIScrollView使用Xib或IB布局</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196848.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:42:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196848.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196848.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196848.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196848.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196848.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2011.03.04</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">UIScrollView使用xib布局后，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">要代码里面设定contentSize。否则无法滚动。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">而且，在IB中也没有办法设定contentSize，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">因此只能通过代码设定。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196848.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:42 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196848.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转:Custom UIImagePickerController camera view -2</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196847.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:42:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196847.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196847.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196847.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196847.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196847.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：2011.04.02</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">【自：貌似这种方法，有时可能会被拒绝，有时候可以通过。<wbr>根据这篇文章：</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;"><a href="http://www.juicybitssoftware.com/2009/11/07/static-analysis-rejection/" target="_blank" style="color: #1155cc;">http://www.juicybitssoftware.<wbr>com/2009/11/07/static-<wbr>analysis-rejection/</a></span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">好像ios3.x就会被拒绝，而3.1以上就不会被拒绝。</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">原因是：在官方api中，只有在3.<wbr>1以上才有可以自定义界面的api。因此，苹果认为3.<wbr>1以下的自定义行为，都是非文档的。而3.1以上则就是正规的。<wbr>虽然，我们用的并不是正规方法，但是他们依然认为这是正规的。</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">】</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><br /><br />转:<a href="http://www.codza.com/custom-uiimagepickercontroller-camera-view" target="_blank" style="color: #1155cc;">http://www.codza.com/custom-<wbr>uiimagepickercontroller-<wbr>camera-view</a><br /><br /><h2><a href="http://www.codza.com/custom-uiimagepickercontroller-camera-view" title="custom UIImagePickerController camera view" target="_blank" style="color: #1155cc;">custom UIImagePickerController camera view</a></h2><div>January 12, 2009</div><div></div><h3><span style="color: #800000;">WARNING: While there are many apps (including some of mine) that use this technique, you should know some new apps and updates to existing apps have been rejected recently (april/2009). Please read the comments. So far I don&#8217;t know of any instances where the developer successfully argued Apple&#8217;s decision if the app was rejected.</span></h3><h3><span style="color: #800000;">With all that said, there&#8217;s still an outpour of apps that use this technique&#8230; so the decision is your.<br /></span></h3><p>Here is some information about inspecting and customizing the UIImagePickerController camera view. You can download the working xcode project with all the source code here:&nbsp;<a href="http://www.codza.com/files/customImagePicker.zip" target="_blank" style="color: #1155cc;">customImagePicker</a></p><p>I wanted to remove the top part of the interface (gray bacground and &#8220;Take Photo&#8221; label) for&nbsp;&nbsp;<a href="http://itunes.com/app/MeanPhoto" target="_blank" style="color: #1155cc;">Mean Photo</a>&nbsp;and&nbsp;<a href="http://itunes.com/app/NicePhoto" target="_blank" style="color: #1155cc;">Nice Photo</a>&nbsp;(version 1.2+). There is also a very annoying image shift between the camera view and the preview that I thought would be nice to fix.</p><p>You can download the&nbsp;<a href="http://www.codza.com/files/customImagePicker.zip" target="_blank" style="color: #1155cc;">customImagePicker</a>&nbsp;xcode project with all the source code that demonstrates these techniques. Run it on your iPhone in debug mode and check the log output for information.</p><p>CustomImagePicker is a subclass of UIImagePickerController. I override the<em>viewDidLoad:</em>&nbsp;method. When this method is called the view is ready to be customized (this approach was suggested in netsharc&#8217;s post&nbsp;<a href="http://netsharc.wordpress.com/2008/12/25/iphone-dev-creating-a-full-screen-camera-preview/" target="_blank" style="color: #1155cc;">here</a>.)</p><pre style="white-space: pre-wrap;">-(void) viewDidAppear: (BOOL)animated {<br />	// make sure to call the same method on the super class<br />	[super viewDidAppear:animated];<br /><br />	/* ... customize view here ... */<br />}</pre><p>The&nbsp;<em>inspectView::</em>&nbsp;method to recursively walks the view hierarchy and prints information about the views to the log: the class descriptions, the position and size and the path (talk about the path in a bit.) If you are interested in other information about the views, you can extend this method to print them. Here&#8217;s how this method is invoked:</p><pre style="white-space: pre-wrap;">[self inspectView:self.view depth:0 path:@""];</pre><p>You can uncomment this line in&nbsp;<em>viewDidLoad:</em>, but it&#8217;s also called from&nbsp;<em>previewCheck</em>every five seconds, so you can monitor the view hierarchy as it changes in the different states. So for example if you are interested what the view hierarchy is like in the preview mode, just take a photo and wait until the next dump appears in the log. The output looks something like this:</p><pre style="white-space: pre-wrap;"> .description: UILayoutContainerView: 0x125b90<br /> .frame: 0, 0, 320, 460<br /> .subviews: 2<br /><br /> --subview-- /0<br />   .description: UITransitionView: 0x1205a0<br />   .frame: 0, 0, 320, 460<br />   .subviews: 1<br /><br />     --subview-- /0/0<br />     .description: UIView: 0x125da0<br />     .frame: 0, 0, 320, 460<br />     .subviews: 1<br /><br />     --subview-- /0/0/0<br />       .description: PLCameraView: 0x125e50<br />       .frame: 0, 0, 320, 460<br />         .subviews: 4<br /><br />       --subview-- /0/0/0/0<br />         .description: UIView: 0x1264c0<br />         .frame: 0, 0, 320, 427<br />         .subviews: 0<br /><br />       --subview-- /0/0/0/1<br />         .description: UIImageView: 0x128850<br />           .class: UIImageView<br />         .frame: 10000, 10000, 320, 480<br />         .subviews: 0<br /><br />       --subview-- /0/0/0/2<br />         .description: UIView: 0x11b200<br />         .frame: 0, 0, 320, 33<br />         .subviews: 0<br />  <br />       --subview-- /0/0/0/3<br />         .description: PLCropOverlay: 0x127dc0<br />         .frame: 0, 0, 320, 460<br />         .subviews: 3<br /><br />         --subview-- /0/0/0/3/0<br />           .description: UIImageView: 0x12b2f0<br />             .class: UIImageView<br />           .frame: 0, 0, 320, 96<br />           .subviews: 0<br /><br />         --subview-- /0/0/0/3/1<br />           .description: PLCropLCDLayer: 0x12b350<br />           .frame: 0, 0, 320, 96<br />             .subviews: 0<br /><br />         --subview-- /0/0/0/3/2<br />           .description: TPBottomDualButtonBar: 0x12b5b0<br />           .frame: 0, 0, 320, 96<br />           .subviews: 2<br /><br />           --subview-- /0/0/0/3/2/0<br />               .description: TPPushButton: 0x12ba40<br />             .frame: 22, 22, 128, 47<br />             .subviews: 0<br /><br />           --subview-- /0/0/0/3/2/1<br />             .description: TPCameraPushButton: 0x12df10<br />               .frame: 170, 170, 128, 47<br />             .subviews: 1<br /><br />             --subview-- /0/0/0/3/2/1/0<br />               .description: UIImageView: 0x12e960<br />               .class: UIImageView<br />               .frame: 51, 51, 26, 19<br />                 .subviews: 0<br /><br /> --subview-- /1<br />   .description: UINavigationBar: 0x125a30<br />   .frame: 0, 0, 320, 44<br />   .subviews: 1<br /><br />   --subview-- /1/0<br />     .description: UINavigationItemView: 0x11abe0<br />       .frame: 160, 160, 0, 27<br />     .subviews: 0</pre><p>Confusing? It&#8217;s actually pretty simple (although not very pretty.)</p><p>Next to each subview you can see it&#8217;s path. For example&nbsp;<strong>/0/0/0/3</strong>&nbsp;means that it is subview #3 of subview #0 of subview #0 of subview #0. To look it up in the view hierarchy, just do this:</p><pre style="white-space: pre-wrap;">    UIView *theView = [[[[[[[[self.view subviews] objectAtIndex:0]<br />                                        subviews] objectAtIndex:0]<br />                                        subviews] objectAtIndex:0]<br />				        subviews] objectAtIndex:3];</pre><p>See the numbers next to&nbsp;<em>objectAtIndex:</em>? It&#8217;s&nbsp;<strong>/0/0/0/3</strong>&#8230; the path&#8230; So now you can look up any&nbsp;<em>UIView</em>&nbsp;from the hierarchy and modify it!</p><p>Even if the description shows that the class is part of the private iPhone libraries (eg.<em>PLCropLCDLayer</em>), it must be a subclass of&nbsp;<em>UIView</em>&nbsp;to be in the hierarchy. We don&#8217;t know (or at least not supposed to know) what methods the private library classes have, but they do have all the methods and properties of&nbsp;<em>UIView</em>. So we can make<em>theView</em>&nbsp;transparent or hidden like this (this is actually the path for the UI above the camera preview):</p><pre style="white-space: pre-wrap;">    [theView setAlpha:0.5];    // semi transparent<br />    [theView setHidden:YES];    // hidden</pre><p>I wanted to get rid of the gray bar and &#8220;Take Photo&#8221; label on top. The path for the gray background is&nbsp;<strong>/0/0/0/3/0</strong>, the label is&nbsp;<strong>/0/0/0/3/1</strong>. I look these up and animate their opacity (alpha) to 0:</p><pre style="white-space: pre-wrap;">    UIImageView *overlay = [[[[[[[[[[self.view subviews] objectAtIndex:0]<br />                                               subviews] objectAtIndex:0]<br />                                               subviews] objectAtIndex:0]<br />                                                 subviews] objectAtIndex:3]<br />                                               subviews] objectAtIndex:0];<br /><br />    UIView *label = [[[[[[[[[[self.view subviews] objectAtIndex:0]<br />                                          subviews] objectAtIndex:0]<br />                                        subviews] objectAtIndex:0]<br />                                        subviews] objectAtIndex:3]<br />                                        subviews] objectAtIndex:1];<br />  <br />    // animate their visibility (alpha) to 0 with a simple UIView animation<br />    //<br />    [UIView beginAnimations:nil context:nil];<br />    [overlay setAlpha:0.0];<br />    [label setAlpha:0.0];<br />    [UIView commitAnimations];</pre><p>Here&#8217;s what it looks like in&nbsp;<a href="http://itunes.com/app/NicePhoto" target="_blank" style="color: #1155cc;">Nice Photo</a>. The&nbsp;<a href="http://en.wikipedia.org/wiki/Love" target="_blank" style="color: #1155cc;"><strong>LOVE</strong></a>&nbsp;graphics is added in a separate view on top of the camera view.</p><div style="width: 234px;"><a href="http://itunes.com/app/nicephoto" target="_blank" style="color: #1155cc;"><img title="nicephotocamera" src="http://www.codza.com/wp-content/uploads/2009/01/nicephotocamera.jpg" alt="nicephotocamera" width="224" height="336" /></a><p>Nice Photo App with Camera UI tweaked</p></div><p>&nbsp;</p><p>The camera view is&nbsp;<strong>/0/0/0/0</strong>. To make it semi transparent (not sure why you would do this, but shows how to look it up):</p><pre style="white-space: pre-wrap;">    UIView *cameraView = [[[[[[[[self.view subviews] objectAtIndex:0]<br />                                           subviews] objectAtIndex:0]<br />                                           subviews] objectAtIndex:0]<br />                                             subviews] objectAtIndex:0];<br />    [cameraView setAlpha:0.5];</pre><p>You might be interested in button push events. The buttons are subclasses of<em>UIControl</em>, so you can easily add an action to them. For example to add an action to the camera button (TPCameraPushButton at&nbsp;<strong>/0/0/0/3/2/1</strong>):</p><pre style="white-space: pre-wrap;">    UIControl *captureButton = [[[[[[[[[[[[self.view subviews] objectAtIndex:0]<br />                                                     subviews] objectAtIndex:0]<br />                                                     subviews] objectAtIndex:0]<br />                                                       subviews] objectAtIndex:3]<br />                                                     subviews] objectAtIndex:2]<br />                                                     subviews] objectAtIndex:1];<br />  <br />    [captureButton addTarget:self action:@selector(<wbr>captureButtonAction:)<br />        forControlEvents:<wbr>UIControlEventTouchUpInside];</pre><p>(The&nbsp;<em>captureButtonAction:</em>&nbsp;method prints a message to the log when you tap the camera button in&nbsp;<a href="http://www.soymint.com/userfiles/file/soymint/customImagePicker.zip" target="_blank" style="color: #1155cc;">customImagePicker</a>.)</p><p>I wanted to fix the shift between the preview and the camera view. To do this, I have a timer calling the&nbsp;<em>previewCheck</em>&nbsp;method (I&#8217;m pretty sure there&#8217;s more elegant ways&#8230; but come ont, timers are cool!). The preview will be added to the UIView at&nbsp;<strong>/0/0/0/2</strong>. By default this view has no subviews, but subviews are added when in preview mode. Then I modify the transform of&nbsp;<strong>/0/0/0/2/0/0/0</strong>&nbsp;like such (btw this only makes sense in portrait mode):</p><pre style="white-space: pre-wrap;">    [previewImage setTransform:<wbr>CGAffineTransformTranslate(<br />        CGAffineTransformMakeScale(<wbr>320.0/1200, 320.0/1200),<br />                                   -12.0*1200/320,-17.0*1200/320)<wbr>];</pre><p>(Now you probably know why I was so interested in the view sizes&#8230; the view frames for the preview image are completely bizarre&#8230; hence the image shift. Are people allowed to drink on the job at&nbsp;<a href="http://finance.google.com/finance?client=ob&amp;q=NASDAQ:AAPL" target="_blank" style="color: #1155cc;">Apple</a>?)</p><p>You can experiment with other views. The&nbsp;<em>inspectView</em>&nbsp;method gives you a pretty good map of the hierarchy and it also works for other source types (like picking an image from the photo library.) Please look at the&nbsp;<a href="http://www.codza.com/files/customImagePicker.zip" target="_blank" style="color: #1155cc;">customImagePicker</a>&nbsp;xcode project, I added lots of comments (more than what I retyped here ;).</p><p>As always, feel free to&nbsp;<a title="contatc" href="http://www.codza.com/contact" target="_blank" style="color: #1155cc;">contact me</a>&#8230; and please check out&nbsp;<a href="http://www.meanvsnice.com/" target="_blank" style="color: #1155cc;">www.meanvsnice.com</a>&nbsp;for some shots taken with&nbsp;<a href="http://itunes.com/app/MeanPhoto" target="_blank" style="color: #1155cc;">Mean Photo</a>&nbsp;and&nbsp;<a href="http://itunes.com/app/NicePhoto" target="_blank" style="color: #1155cc;">Nice Photo</a>.</p><br />+++++</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196847.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:42 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196847.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：手势操作的一些规律</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196846.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:41:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196846.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196846.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196846.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196846.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196846.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.04.09</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">原：手势操作的一些规律</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*父view注册手势，则当手势操作在子view的时候，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">父view仍然能够收到消息。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*如果子view也注册了手势操作，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">则父view将无法收到手势操作了。可以猜测为，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果手势操作有下层拦截，则不会向上传递了。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">使用UINavigationController的push加</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">入子Controller，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">那么即使RootController注册了手势操作，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果在子Controller进行手势操作时，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Root也无法收到手势操作。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*在UITableView上注册手势操作也能成功。但是，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">由于UITableView自身有很多手势操作，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">因此可能会产生冲突，导致操作不受控制。例如，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果注册左右滑动的手势操作，则当进行左右操作时，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">很可能触发点击操作.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*如果某viewController覆盖了- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event等操作，则对于手势操作没有任何影响。</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">即仍然可以收到手势操作。同样，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果子view覆盖touchesBegan等函数，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">也不会妨碍父view接受手势操作的。总之，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">覆盖touchesBegan等函数，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">不会对手势操作有任何影响。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*一些基本步骤：</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">- (void)viewDidLoad {</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">handleSwipeGestureRecognizer:)</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; [recognizer setDirection:(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">UISwipeGestureRecognizerDirect</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">ionLeft)];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; recognizer.</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">numberOfTouchesRequired = 1;</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; [[self view] addGestureRecognizer:</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">recognizer];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; [recognizer release];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">handleSwipeGestureRecognizer:)</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; [recognizer setDirection:(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">UISwipeGestureRecognizerDirect</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">ionRight)];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; recognizer.</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">numberOfTouchesRequired = 1;</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; [[self view] addGestureRecognizer:</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">recognizer];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; [recognizer release];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">}</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">- (void)</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">handleSwipeGestureRecognizer:(</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">UISwipeGestureRecognizer *)recognizer {</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; NSLog(@"</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">SecondViewGestureRecognizer");</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">}</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196846.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:41 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196846.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：手势操作-点击的不同次数引发的问题 －Differentiating Tap Counts on iOS</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196845.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:41:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196845.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196845.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196845.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196845.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196845.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.04.09</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;">【自：也就是说，当同时注册点击1次，点击2次，<wbr>点击3次的时候，会引发这样一个问题。即当识别点击三次的时候，<wbr>对于点击1，2次也会响应。对于新的方法，要使用-<wbr>requireGestureRecognizerToFail<wbr>:，对于就的ios要使用延迟处理了。】</span><br style="font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff; color: #3333ff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://www.cimgf.com/2010/06/14/differentiating-tap-counts-on-ios/" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://www.cimgf.com/2010/<wbr>06/14/differentiating-tap-<wbr>counts-on-ios/</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">In your iPhone/iPad apps you often need to know how many times your user tapped in a view. This can be challenging because, though the user may have tapped twice, you will receive the event and it will look like they tapped once as well as twice. If the user triple-tapped, you will get the event for one tap, two taps, and three taps. It can get a little frustrating, but the trick is timing. You simply have to wait a period of time to see if another tap comes. If it does, you cancel the action spawned by the first tap. If it doesn&#8217;t you allow the action to run. There&#8217;s a few little nuances to getting it to work, but it can be done. Here is how.</p><h2>Overriding Touch Event Handlers</h2><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">In order to know how many times your user tapped, you listen for the events in the various touch handlers. Let start with -touchesEnded. This is where we will determine how many taps we received and respond accordingly. Consider the following code.</p><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><table><tbody><tr><td style="margin: 0px;"><pre style="white-space: pre-wrap;">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></pre></td><td style="margin: 0px;"><pre style="white-space: pre-wrap;"><span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span>touchesEnded<span style="color: #002200;">:</span><span style="color: #002200;">(</span><span style="color: #400080;">NSSet</span><span style="color: #002200;">*</span><span style="color: #002200;">)</span>tou<wbr>ches withEvent<span style="color: #002200;">:</span><span style="color: #002200;">(</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">)</span>event <br /> <span style="color: #002200;">{</span><br />  <span style="color: #a61390;">if</span><span style="color: #002200;">(</span>touches.count <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">)</span><br />   <span style="color: #002200;">{</span>  <br />    <span style="color: #a61390;">if</span><span style="color: #002200;">(</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>touches anyObject<span style="color: #002200;">]</span> tapCount<span style="color: #002200;">]</span> <span style="color: #002200;">==</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">)</span><br />     <span style="color: #002200;">{</span><br />      <span style="color: #002200;">[</span>self handleDoubleTap<span style="color: #002200;">]</span>;<br />    <span style="color: #002200;">}</span><br />     <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">(</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>touches anyObject<span style="color: #002200;">]</span> tapCount<span style="color: #002200;">]</span> <span style="color: #002200;">==</span> <span style="color: #2400d9;">3</span><span style="color: #002200;">)</span><br />     <span style="color: #002200;">{</span><br />      <span style="color: #002200;">[</span>self handleTripleTap<span style="color: #002200;">]</span>;<br />    <span style="color: #002200;">}</span><br />     <span style="color: #a61390;">else</span><br />    <span style="color: #002200;">{</span><br />      <span style="color: #002200;">[</span>self handleSingleTap<span style="color: #002200;">]</span>; <br />     <span style="color: #002200;">}</span><br />  <span style="color: #002200;">}</span><br /><span style="color: #002200;">}</span></pre></td></tr></tbody></table></div><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">If you place a breakpoint inside each of the code blocks for the three tap counts, you will find that in the case where you triple tap, it will break in all three. If you double tap, it will break in both the double tap and single tap and of course if you single tap, it will break in the single tap branch.</p><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">In most cases, this is not desirable. You will likely want a clean differentiation between each touch as each tap count will likely mean something different. So how can we fix this? The trick is to use&nbsp;<em>-peformSelector:withObject:<wbr>afterDelay</em>&nbsp;and then canceling the perform action if a new action occurs. Got it?</p><h2>Wait For It&#8230;</h2><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">If you call the method directly as we did in the sample code above, there is no way to delay when it runs nor is there a way to cancel it should another tap be received. Both of these things are necessary. If you think about it, waiting to run our&nbsp;<em>-handleSingleTap</em>&nbsp;method until a certain amount of time passes helps make sure it actually was a double tap. If the user taps once and nothing else occurs, we&#8217;re safe to run the&nbsp;<em>-handleSingleTap</em>&nbsp;code. If another tap is received in the mean time, however, we can cancel the action from the first tap. The way we do this is by changing our&nbsp;<em>-touchesEnded:</em>&nbsp;code to something like this:</p><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><table><tbody><tr><td style="margin: 0px;"><pre style="white-space: pre-wrap;">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></pre></td><td style="margin: 0px;"><pre style="white-space: pre-wrap;"><span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span>touchesEnded<span style="color: #002200;">:</span><span style="color: #002200;">(</span><span style="color: #400080;">NSSet</span><span style="color: #002200;">*</span><span style="color: #002200;">)</span>tou<wbr>ches withEvent<span style="color: #002200;">:</span><span style="color: #002200;">(</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">)</span>event <br /> <span style="color: #002200;">{</span><br />  <span style="color: #a61390;">if</span><span style="color: #002200;">(</span>touches.count <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">)</span><br />   <span style="color: #002200;">{</span>  <br />    <span style="color: #a61390;">if</span><span style="color: #002200;">(</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>touches anyObject<span style="color: #002200;">]</span> tapCount<span style="color: #002200;">]</span> <span style="color: #002200;">==</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">)</span><br />     <span style="color: #002200;">{</span><br />      <span style="color: #002200;">[</span>self performSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>hand<wbr>leDoubleTap<span style="color: #002200;">)</span><br />                  withObject<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><br />                 afterDelay<span style="color: #002200;">:</span><span style="color: #2400d9;">0.35</span><span style="color: #002200;">]</span>; <br />     <span style="color: #002200;">}</span><br />    <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">(</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>touches anyObject<span style="color: #002200;">]</span> tapCount<span style="color: #002200;">]</span> <span style="color: #002200;">==</span> <span style="color: #2400d9;">3</span><span style="color: #002200;">)</span><br />     <span style="color: #002200;">{</span><br />      <span style="color: #002200;">[</span>self handleTripleTap<span style="color: #002200;">]</span>;<br />    <span style="color: #002200;">}</span><br />     <span style="color: #a61390;">else</span><br />    <span style="color: #002200;">{</span><br />      <span style="color: #002200;">[</span>self performSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>hand<wbr>leSingleTap<span style="color: #002200;">)</span><br />                  withObject<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><br />                 afterDelay<span style="color: #002200;">:</span><span style="color: #2400d9;">0.35</span><span style="color: #002200;">]</span>; <br />     <span style="color: #002200;">}</span><br />  <span style="color: #002200;">}</span><br /><span style="color: #002200;">}</span></pre></td></tr></tbody></table></div><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Notice that we are delaying 350 milliseconds to see if another event occurs. You should also notice that we still call&nbsp;<em>-handleTripleTap</em>&nbsp;directly without using&nbsp;<em>-performSelector:withObject:<wbr>afterDelay</em>. This is because it has now been isolated as a distinct event. If we get a triple tap, we&#8217;re pretty well assured now that a double or single tap event was not actually run as those events will have been cancelled. So how does that work? How do we cancel them?</p><h2>Canceling The Action</h2><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Now that we are waiting around to see if another tap event occurs, we need to override the&nbsp;<em>-touchesBegan:</em>&nbsp;method. It will look something like this:</p><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><table><tbody><tr><td style="margin: 0px;"><pre style="white-space: pre-wrap;">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></pre></td><td style="margin: 0px;"><pre style="white-space: pre-wrap;"><span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span>touchesBegan<span style="color: #002200;">:</span><span style="color: #002200;">(</span><span style="color: #400080;">NSSet</span><span style="color: #002200;">*</span><span style="color: #002200;">)</span>tou<wbr>ches withEvent<span style="color: #002200;">:</span><span style="color: #002200;">(</span>UIEvent<span style="color: #002200;">*</span><span style="color: #002200;">)</span>event<br /> <span style="color: #002200;">{</span><br />  <span style="color: #002200;">[</span><span style="color: #400080;">NSObject</span> cancelPreviousPerformRequestsW<wbr>ithTarget<span style="color: #002200;">:</span>self<br />                                            selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>handleSingl<wbr>eTap<span style="color: #002200;">)</span><br />                                              object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">]</span>;<br />&nbsp;<br />  <span style="color: #002200;">[</span><span style="color: #400080;">NSObject</span> cancelPreviousPerformRequestsW<wbr>ithTarget<span style="color: #002200;">:</span>self<br />                                            selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>handleDoubl<wbr>eTap<span style="color: #002200;">)</span><br />                                              object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">]</span>;<br /><span style="color: #002200;">}</span></pre></td></tr></tbody></table></div><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">The method&nbsp;<em>-<wbr>cancelPreviousPerformRequestsW<wbr>ithTarget:selector:object:</em>&nbsp;is able to determine which action you want to cancel and then cancel it preventing the selectors,&nbsp;<em>-handleSingleTap</em>&nbsp;or&nbsp;<em>-handleDoubleTap</em>&nbsp;from being called&#8211;assuming the second or third taps occurred within the allocated 350 milliseconds. That&#8217;s all there is to it.</p><h2>There *Is* a Catch</h2><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">That is all there is to it, however, you have to be careful if you intend to pass parameters to your selectors. If you use a selector that takes a parameter so that you have to call something with&nbsp;<em>-performSelector:withObject:<wbr>afterDelay:</em>&nbsp;passing an object to the second parameter, you will need&nbsp;<em>that</em>&nbsp;object or one identical to it in your call to cancel the action with&nbsp;<em>-<wbr>cancelPreviousPerformRequestsW<wbr>ithTarget:selector:object:</em>. It must be able to evaluate to true when&nbsp;<em>equals</em>&nbsp;is called on the object passed into the&nbsp;<em>object</em>&nbsp;parameter. This can be tricky, but you can overcome it in one of two ways using an ivar:</p><ul style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><li style="margin-left: 15px;"><p>Create an ivar to hold onto the variable that you will use as a parameter to the cancel when you first pass it to the&nbsp;<em>-performSelector:withObject:<wbr>afterDelay:</em>&nbsp;call.</p></li><li style="margin-left: 15px;"><p>Create an ivar to hold onto the variable when you first enter touches ended and call&nbsp;<em>-performSelector:withObject:<wbr>afterDelay</em>&nbsp;passing it nil for the&nbsp;<em>object</em>parameter. Then, grab the ivar when you need it in your handler code. The cancel call can then take nil for its&nbsp;<em>object</em>&nbsp;parameter.</p></li></ul><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">These points are crucial if you are intending to pass parameters as the cancel will fail if you try to pass a parameter and it doesn&#8217;t match what you used in your call to&nbsp;<em>-performSelector:withObjecct:<wbr>afterDelay:</em>. The only parameter that doesn&#8217;t matter is the&nbsp;<em>afterDelay:</em>&nbsp;param.</p><h2>Conclusion</h2><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">I&#8217;m finding the need to differentiate tap counts more and more often so this post is really as much a way for me to keep a journal of things I need to do frequently as it is to help others figure things out too. I hope it&#8217;s been helpful to you. Until next time.</p><h1>Update</h1><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">So, apparently Gesture Recognizers do address this issue. I had looked at them as a possible solution, but ran into the same differentiation problems, hence this blog post. However,&nbsp;<a href="http://twitter.com/aclark" target="_blank" style="color: #1155cc;">Ashley Clark</a>&nbsp;pointed me to the&nbsp;<em><a href="http://developer.apple.com/iphone/library/documentation/uikit/reference/UIGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/instm/UIGestureRecognizer/requireGestureRecognizerToFail:" target="_blank" style="color: #1155cc;">-<wbr>requireGestureRecognizerToFail<wbr>:</a></em>&nbsp;method, which apparently enables you to have this cancellation functionality by creating a dependency between recognizers. The code to take advantage of it looks something like this:</p><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><table><tbody><tr><td style="margin: 0px;"><pre style="white-space: pre-wrap;">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></pre></td><td style="margin: 0px;"><pre style="white-space: pre-wrap;">UITapGestureRecognizer <span style="color: #002200;">*</span>tripleTap <span style="color: #002200;">=</span> <br /><span style="color: #002200;">[</span><span style="color: #002200;">[</span>UITapGestureRecognizer alloc<span style="color: #002200;">]</span><br />  initWithTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>handleTripleT<wbr>ap<span style="color: #002200;">:</span><span style="color: #002200;">)</span><span style="color: #002200;">]</span>;<br /> &nbsp;<br /><span style="color: #002200;">[</span>tripleTap setNumberOfTapsRequired<span style="color: #002200;">:</span><span style="color: #2400d9;">3</span><span style="color: #002200;">]</span>;<br /> <span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> addGestureRecognizer<span style="color: #002200;">:</span>tripleTap<span style="color: #002200;"><wbr>]</span>;<br /> <span style="color: #002200;">[</span>tripleTap release<span style="color: #002200;">]</span>;<br />&nbsp;<br />UITapGestureRecognizer <span style="color: #002200;">*</span>doubleTap <span style="color: #002200;">=</span> <br /> <span style="color: #002200;">[</span><span style="color: #002200;">[</span>UITapGestureRecognizer alloc<span style="color: #002200;">]</span><br /> initWithTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>handleDoubleT<wbr>ap<span style="color: #002200;">:</span><span style="color: #002200;">)</span><span style="color: #002200;">]</span>;<br /> &nbsp;<br /><span style="color: #002200;">[</span>doubleTap setNumberOfTapsRequired<span style="color: #002200;">:</span><span style="color: #2400d9;">2</span><span style="color: #002200;">]</span>;<br /> <span style="color: #002200;">[</span>doubleTap requireGestureRecognizerToFail<span style="color: #002200;"><wbr>:</span>tripleTap<span style="color: #002200;">]</span>;<br /><span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> addGestureRecognizer<span style="color: #002200;">:</span>doubleTap<span style="color: #002200;"><wbr>]</span>;<br /> <span style="color: #002200;">[</span>doubleTap release<span style="color: #002200;">]</span>;<br />&nbsp;<br />UITapGestureRecognizer <span style="color: #002200;">*</span>singleTap <span style="color: #002200;">=</span> <br /> <span style="color: #002200;">[</span><span style="color: #002200;">[</span>UITapGestureRecognizer alloc<span style="color: #002200;">]</span><br /> initWithTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>handleSingleT<wbr>ap<span style="color: #002200;">:</span><span style="color: #002200;">)</span><span style="color: #002200;">]</span>;<br /> &nbsp;<br /><span style="color: #002200;">[</span>singleTap setNumberOfTapsRequired<span style="color: #002200;">:</span><span style="color: #2400d9;">1</span><span style="color: #002200;">]</span>; <span style="color: #11740a; font-style: italic;">// Unnecessary since it's the default</span><br /> <span style="color: #002200;">[</span>singleTap requireGestureRecognizerToFail<span style="color: #002200;"><wbr>:</span>doubleTap<span style="color: #002200;">]</span>;<br /><span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> addGestureRecognizer<span style="color: #002200;">:</span>singleTap<span style="color: #002200;"><wbr>]</span>;<br /> <span style="color: #002200;">[</span>singleTap release<span style="color: #002200;">]</span>;</pre></td></tr></tbody></table></div><p style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">So, if your project is 3.2 and later, use gesture recognizers. The effect is about the same, but the code is quite a bit cleaner.</p><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196845.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:41 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196845.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：UIWebView自动换行</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196844.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:40:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196844.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196844.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196844.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196844.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196844.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.04.12</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">UIWebView自动换行</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" />这个问题不是UIWebView能解决的，<wbr>需要改动HTML文件。可以修改如下：<br /><br />&lt;div style="word-wrap:break-word; width:20px;"&gt;<wbr>abcdefghijklmnabcdefghijklmnab<wbr>cdefghijklmn111111111&lt;/div&gt;<br /><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 控制好width可实现固定宽度，自动换行。<br /><br />＋＋＋＋＋<img src ="http://www.cppblog.com/walkklookk/aggbug/196844.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:40 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196844.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：UIImageView不响应手指操作GesutureRecognizer</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196843.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:40:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196843.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196843.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196843.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196843.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196843.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.04.13</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://stackoverflow.com/questions/3907397/gesuturerecognizer-on-uiimageview" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://stackoverflow.com/<wbr>questions/3907397/<wbr>gesuturerecognizer-on-<wbr>uiimageview</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Check that userInteractionEnabled is YES on the UIImageView. Then you can add a gesture recognizer.</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;"><code><span style="background-color: #ff6666;">imageView</span><span style="background-color: #ff6666;">.</span><span style="background-color: #ff6666;">userInteractionEnabl<wbr>ed </span><span style="background-color: #ff6666;">=</span><span style="background-color: #ff6666;"> YES</span><span style="background-color: #ff6666;">;</span><br /> UIPinchGestureRecognizer *pgr = [[UIPinchGestureRecognizer alloc] <br /> &nbsp; &nbsp; initWithTarget:self action:@selector(handlePinch:)<wbr>];<br /> pgr.delegate = self;<br /> [imageView addGestureRecognizer:pgr];<br />[pgr release];<br /> :<br />:<br />- (void)handlePinch:(UIPinchGest<wbr>ureRecognizer *)pinchGestureRecognizer<br /> {<br />&nbsp; //handle pinch...<br />}<br /><br />＋＋＋＋＋</code></pre><img src ="http://www.cppblog.com/walkklookk/aggbug/196843.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:40 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196843.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：导航栏加入阴影</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196842.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:40:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196842.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196842.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196842.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196842.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196842.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2011.04.18</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">导航栏没有办法加入阴影。因此，可以使用替代的方法，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">即单独做一个阴影的图片，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">然后在每个页面的最上面最上层加入该阴影图片。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">PS：当然，如果你使用代码创建View的话，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">那么当你的背景的位置的y设定为负数的时候，有可能成功。但是，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">这个工作量太大，因此，不如使用上面介绍的方法。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196842.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:40 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196842.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：添加自定义的UITableViewCell －4</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196841.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:39:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196841.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196841.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196841.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196841.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196841.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：100721</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：101221</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：110418</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div><div><br />添加自定义的UITableViewCell有2种方法，<wbr>其一是使用contextView；<wbr>其二是使用UITableViewCell的派生类。<br />对于第一种，则只需要产生0－1个新文件。所以，<wbr>我只介绍第一种。<br />对于第二种，则一定要产生2－3个新文件。所以，我不喜欢使用。<wbr>但是，可以参考CookBook第二版的&#8220;自定义Cell&#8221;<wbr>的介绍。<br /><br /><br />1，首先创建自定义的contentView。<wbr>使用xib文件创建。创建分两种情况：其一，<wbr>如果你的UITableView有自己的xib文件，<wbr>则可以在改xib文件中，加入新的一个view，<wbr>作为contentView。其二，<wbr>如果UITableView没自己的xib文件，<wbr>则需要创建一个xib文件，<wbr>用于放置新的contentView。<br /><br />新的contentView的宽度是cell的宽度，<wbr>根据我的经验，应该是284。高度则根据情况自定义。<br />对于需要修改内容的控件，如文本框等，则需要指定一个tag。<br /><br />2，<wbr>在自定义的UITableViewController的派生类<wbr>中，<br /><br />- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(<wbr>NSIndexPath *)indexPath {<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp; static NSString *CellIdentifier = @"<wbr>OptionViewModuleListController<wbr>Cell";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentif<wbr>ier:CellIdentifier];<br />&nbsp;&nbsp;&nbsp; if (cell == nil) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cell = [[[UITableViewCell alloc] initWithStyle:<wbr>UITableViewCellStyleDefault reuseIdentifier:<wbr>CellIdentifier] autorelease];<br /><br />// &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; UIView *subView = [[[NSBundle mainBundle] loadNibNamed:@"<wbr>OptionViewModuleListController<wbr>CellViewXibFile"&nbsp;<br />// &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; owner:self options:NULL] lastObject];&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UIView *subView = nil;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (id oneObject in nib)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ([oneObject isKindOfClass:[UIView class]])<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subView = (UIView *)oneObject;<br /><br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [(UIButton *)[subView viewWithTag:104] addTarget: self action:@selector(<wbr>onBuyButtonPressed:) forControlEvents:<wbr>UIControlEventTouchUpInside];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [cell.contentView addSubview:subView];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CGRect subViewFrame = subView.frame;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; subViewFrame.origin = CGPointMake(10, 10); //&nbsp; 对于group类型的cell，则圆角范围，大约是10像素。<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; subView.frame = subViewFrame;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp; // Set up the cell...<br />&nbsp;&nbsp;&nbsp; UIView *subView = [cell.contentView.subviews objectAtIndex:0];<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp; UILabel *titleLabel = (UILabel *)[subView viewWithTag:101];&nbsp;<br />&nbsp;&nbsp;&nbsp; UILabel *descriptionLabel = (UILabel *)[subView viewWithTag:103];&nbsp;<br />&nbsp;&nbsp;&nbsp; UILabel *buyStatusLabel = (UILabel *)[subView viewWithTag:102];<br /><br />//.......................<br />//.......................<br />}<br /><br />- (CGFloat)tableView:(<wbr>UITableView *)tableView heightForRowAtIndexPath:(<wbr>NSIndexPath *)indexPath {<br />&nbsp;&nbsp;&nbsp; return 140.0; // 这个高度大约是contentView的高度＋10＊2像素。 这10像素就是cell的圆角空间。<br />}<br /><br />2010-12-21补充：<br />如果你在cell上加入了一个button。<wbr>则在button的响应函数中，<wbr>如果想得到对应的cell和indexPath，则可以：<br /><pre style="white-space: pre-wrap;"><code>- (IBAction)buttonWasPressed:(id<wbr>)sender<br />   {<br />&nbsp; &nbsp; NSIndexPath *indexPath =<br /> &nbsp; &nbsp; &nbsp; &nbsp; [self.myTableView<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;indexPathForCell:(UITableView<wbr>Cell *)[[sender superview] superview]];<br />   &nbsp; &nbsp; NSUInteger row = indexPath.row;<br /> <br />&nbsp; &nbsp; // Do something with row index<br />}<br /></code></pre>注意，<wbr>如果你的button不是直接加入到contentView中，<wbr>则superview的关系可能不是仅仅2层，<wbr>这个就需要具体问题，具体分析了。<br /><br />＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝<br />2011.04.18补充：<br />上述方法虽然使用文件较少，但是有个弊端。<wbr>如果该Cell的控件较多，那么导致使用tag，<wbr>以及获取viewWithTag的太多，很麻烦，也很乱。<wbr>此时的一个做法是：<br />创建类，例如CustomView。<br />然后，在xib中，<wbr>将该View的类型改为CustomView。<wbr>然后进行IBOutlet的关联。<br />然后，在使用上述方法，得到该CustomView。同时，<wbr>也得到了相应的IBOutlet。<br />这种方法，跟CookBook的方法差不多。<wbr>但是有个本质的区别，就是，CookBook中，<wbr>CustomView的类型是UITableViewCell。<wbr>这样，在执行LoadNib之后，直接就可以使用该Cell了，<wbr>不必在[cell.contentView addSubview:aCustom]了。但是，<wbr>这种方法的缺点很大，很大。最重要的缺点是：<wbr>无法使用Cell的Reuse功能了。<wbr>因为整个Cell都是通过LoadNib得到的，而非[[<wbr>UITableViewCell alloc] initWithStyle:<div>x reuseIdentifier:x];,<wbr>因此无法使用reuse机制。<br />因此，我们不使用Cookbook的方法。</div><br />+++++</div></div></div><img src ="http://www.cppblog.com/walkklookk/aggbug/196841.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:39 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196841.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：MPMoviePlayerController 手势操作 单击无效，双击可以</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196839.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:38:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196839.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196839.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196839.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196839.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196839.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.05.12</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">MPMoviePlayerController 的player的view加入到某个view的时候，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">无法注册UITapGestureRecognizer的单击事</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">件，但是双击，甚至三击都可以。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">处理方法是：在play.</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">view上面加入一个同样的大小的子view，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">然后把手势操作注册到这个view上。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; UIView *aView = [[UIView alloc] initWithFrame:mPlayer.view.</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">bounds];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; [mPlayer.view addSubview:aView];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; [aView release];</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">这么写，该view就自动透明了，真奇怪。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196839.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:38 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196839.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：导航栏向左的带箭头的按钮</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196838.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:38:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196838.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196838.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196838.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196838.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196838.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; text-align: right; white-space: nowrap; background-color: #ffffff;">11-5-14<br /><br /></span><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</span><a href="http://stackoverflow.com/questions/227078/creating-a-left-arrow-button-like-uinavigationbars-back-style-on-a-uitoolbar" target="_blank" style="color: #1155cc; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">http://stackoverflow.com/<wbr>questions/227078/creating-a-<wbr>left-arrow-button-like-<wbr>uinavigationbars-back-style-<wbr>on-a-uitoolbar</a><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">【自：101号button就是向左的箭头。】</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><pre style="white-space: pre-wrap; color: #222222; line-height: normal; background-color: #ffffff;"><code>// create button<br />UIButton* backButton = [UIButton buttonWithType:101]; // left-pointing shape!<br /> [backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEven<wbr>tTouchUpInside];<br /> [backButton setTitle:@"Back" forState:UIControlStateNormal]<wbr>;<br /> <br />// create button item -- possible because UIButton subclasses UIView!<br />UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]<wbr>;<br /> <br />// add to toolbar, or to a navbar (you should only have one of these!)<br />[toolbar setItems:[NSArray arrayWithObject:backItem]];<br /> navItem.leftBarButtonItem = backItem;<br /></code></pre><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196838.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:38 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196838.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：UILineBreakMode的各种情况分析</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196837.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:37:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196837.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196837.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196837.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196837.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196837.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2011.05.22</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">typedef enum {</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeWordWrap = 0,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeCharacterWrap,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeClip,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeHeadTruncation,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeTailTruncation,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeMiddleTruncatio</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">n,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">} UILineBreakMode;</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeWordWrap = 0,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; 以单词为单位换行，以单位为单位截断。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeCharacterWrap,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; 以字符为单位换行，以字符为单位截断。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeClip,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; 以单词为单位换行。以字符为单位截断。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeHeadTruncation,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; 以单词为单位换行。如果是单行，则开始部分有省略号。</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果是多行，则中间有省略号，省略号后面有4个字符。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeTailTruncation,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; 以单词为单位换行。无论是单行还是多行，都是末尾有省略号。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; UILineBreakModeMiddleTruncatio</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">n,</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;&nbsp; 以单词为单位换行。无论是单行还是多行，都是中间有省略号，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">省略号后面只有2个字符。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196837.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:37 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196837.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：Getting MPMoviePlayerController to Work with iOS4, 3.2 (iPad) and Earlier Versions of iPhone SDK</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196832.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 03:21:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196832.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196832.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196832.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196832.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196832.html</trackback:ping><description><![CDATA[日期：2011.06.03<br /><br />[自：此次升级的主要差别在于：<br />1，旧版本只能全屏。而新版可以在局部内显示。<br />2，新版本必须把view加入到某个view上才能看到。<wbr>否则只有声音。<br />3，新版全屏播放的类的名字，<wbr>应该是MPMoviePlayerViewController<br />4，The notification MPMoviePlayerContentPreloadDid<wbr>FinishNotification has been deprecated. This notification was used in earlier versions to notify observers that a movie was loaded and ready to play.]<br /><br />转：<a href="http://iphonedevelopertips.com/video/getting" target="_blank" style="color: #1155cc;">http://iphonedevelopertips.<wbr>com/video/getting</a>- mpmovieplayercontroller- to-cooperate-with-ios4-3-2-<wbr>ipad-and-earlier-versions-of-<wbr>iphone-sdk.html<br /><br /><br /><h1><a href="http://iphonedevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html" rel="bookmark" title="Permanent Link: Getting         MPMoviePlayerController to Work with iOS4, 3.2 (iPad) and         Earlier Versions of iPhone SDK" target="_blank" style="color: #1155cc;">Getting MPMoviePlayerController to Work with iOS4, 3.2 (iPad) and Earlier Versions of iPhone SDK</a></h1><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>Posted on July 8, 2010 by&nbsp;<a href="http://iphonedevelopertips.com/author/admin" title="Posts by John Muchow" target="_blank" style="color: #1155cc;">John Muchow</a>&nbsp;in&nbsp;<a href="http://iphonedevelopertips.com/category/video" title="View all posts in Video" rel="category tag" target="_blank" style="color: #1155cc;">Video</a></div><br /><br /><div style="float: right; width: 215px; min-height: 200px;"></div><div style="float: left; width: 169px; min-height: 76px; margin: 0px;"></div><p>The API and overall approach for working with<strong>MPMoviePlayerController</strong>&nbsp;has changed just enough in the 3.2 SDK (iPad) and iOS4 SDK to cause working applications in earlier releases to be problematic when running on later SDKs. In this post I&#8217;ll walk through a short example of a movie player application that will work with 3.x, 3.2 and 4.0 SDKs.</p><p>In the next post,&nbsp;<a href="http://iphonedevelopertips.com/video/display-iphone-movies-in-portrait-mode-updated.html" target="_blank" style="color: #1155cc;">Display iPhone Movies in Portrait Mode</a>, I&#8217;ll show how to create a movie player that runs in a view that is&nbsp;<em>not</em>&nbsp;fullscreen as well as how to show a few lines of code to display a movie in portrait mode &#8211; the one caveat here is that both of the tips in the second post will apply only to OS versions 3.2 and up.<br /></p><h5>What&#8217;s Changed with MPMoviePlayerController in 3.2 and 4.0?</h5><p>There are any number of changes in the&nbsp;<strong>MPMoviePlayerController</strong>, however, a few standout as potential roadblocks to getting a movie to display:</p><p>- In 3.1 and earlier versions,&nbsp;<strong>MPMoviePlayerController</strong>&nbsp;was full-screen only. Playing a movie was straight-forward, create a player, initialize with a file (path or URL) and call a method to start playback &#8211; the rest was taken care of for you.</p><p>- With 3.2 and later, movies can playback in fullscreen or a custom view, as well as portrait or landscape.</p><p>- The notification&nbsp;<strong>MPMoviePlayerContentPreloadDid<wbr>FinishNotification</strong>&nbsp;has been deprecated. This notification was used in earlier versions to notify observers that a movie was loaded and ready to play.</p><h5>The Movie Application</h5><p>The application in this post is quite simple, it consists of a view controller with nothing more than a button to start playback and a second view controller to manage a<strong>MPMoviePlayerController</strong>&nbsp;and the&nbsp;<strong>NSURL</strong>&nbsp;of the movie. The two views are shown in the figures below:</p><p><img src="https://mail.google.com/mail/u/0/?ui=2&amp;ik=f710b2434e&amp;view=att&amp;th=130534b96e0ab093&amp;attid=0.1.1&amp;disp=emb&amp;zw&amp;atsh=1"  alt="" /></p><h5>Primary View Controller</h5><p>The interface definition for the primary view is shown below:</p><div><pre style="white-space: pre-wrap;"><span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span> &nbsp; <span style="color: #a61390;">@class</span> CustomMoviePlayerViewControlle<wbr>r; &nbsp; <span style="color: #a61390;">@interface</span> TestViewController <span style="color: #002200;">:</span> UIViewController <span style="color: #002200;">{</span>   CustomMoviePlayerViewControlle<wbr>r  <span style="color: #002200;">*</span>moviePlayer;   UIButton  <span style="color: #002200;">*</span>playButton; <span style="color: #002200;">}</span> &nbsp; <span style="color: #a61390;">@end</span></pre></div><p><strong>CustomMoviePlayerViewControlle<wbr>r</strong>&nbsp;is the controller for managing the movie, we&#8217;ll look at that code in a moment.</p><p>In the code below we create the view, add a play button, create a method for processing a button press event and within&nbsp;<strong>loadMoviePlayer</strong>, we get a reference to the movie file and create an instance of the&nbsp;<strong>CustomMoviePlayerViewControlle<wbr>r</strong>, which will load and play the movie.</p><div><pre style="white-space: pre-wrap;"><span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span>loadView <span style="color: #002200;">{</span>   <span style="color: #11740a; font-style: italic;">// Setup the view</span>   <span style="color: #002200;">[</span>self setView<span style="color: #002200;">:</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>UIView alloc<span style="color: #002200;">]</span> initWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>UIScreen mainScreen<span style="color: #002200;">]</span> applicationFrame<span style="color: #002200;">]</span><span style="color: #002200;">]</span> autorelease<span style="color: #002200;">]</span><span style="color: #002200;">]</span>;   <span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> setBackgroundColor<span style="color: #002200;">:</span><span style="color: #002200;">[</span>UIColor grayColor<span style="color: #002200;">]</span><span style="color: #002200;">]</span>;   <span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> setUserInteractionEnabled<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">]</span><wbr>; &nbsp;   <span style="color: #11740a; font-style: italic;">// Add play button </span>   playButton <span style="color: #002200;">=</span> <span style="color: #002200;">[</span><span style="color: #002200;">[</span>UIButton alloc<span style="color: #002200;">]</span> initWithFrame<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">(</span><span style="color: #2400d9;">53</span>, <span style="color: #2400d9;">212</span>, <span style="color: #2400d9;">214</span>, <span style="color: #2400d9;">36</span><span style="color: #002200;">)</span><span style="color: #002200;">]</span>;       <span style="color: #002200;">[</span>playButton setBackgroundImage<span style="color: #002200;">:</span><span style="color: #002200;">[</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">"playButton.png"</span><span style="color: #002200;">]</span> forState<span style="color: #002200;">:</span>UIControlStateNormal<span style="color: #002200;">]</span><wbr>;   <span style="color: #002200;">[</span>playButton addTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>buttonPressed<span style="color: #002200;"><wbr>:</span><span style="color: #002200;">)</span> forControlEvents<span style="color: #002200;">:</span> UIControlEventTouchUpInside<span style="color: #002200;">]</span>;       <span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> addSubview<span style="color: #002200;">:</span>playButton<span style="color: #002200;">]</span>;   <span style="color: #002200;">}</span> &nbsp; <span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span>buttonPressed<span style="color: #002200;">:</span><span style="color: #002200;">(</span>UIButton <span style="color: #002200;">*</span><span style="color: #002200;">)</span>button <span style="color: #002200;">{</span>   <span style="color: #11740a; font-style: italic;">// If pressed, play movie</span>   <span style="color: #a61390;">if</span> <span style="color: #002200;">(</span>button <span style="color: #002200;">==</span> playButton<span style="color: #002200;">)</span>     <span style="color: #002200;">[</span>self loadMoviePlayer<span style="color: #002200;">]</span>;	 <span style="color: #002200;">}</span> &nbsp; <span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span>loadMoviePlayer <span style="color: #002200;">{</span>     <span style="color: #11740a; font-style: italic;">// Play movie from the bundle</span>   <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">]</span> pathForResource<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">"Movie-1"</span> ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">"mp4"</span> inDirectory<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">]</span>; &nbsp;   <span style="color: #11740a; font-style: italic;">// Create custom movie player   </span>   moviePlayer <span style="color: #002200;">=</span> <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #002200;">[</span>CustomMoviePlayerViewContro<wbr>ller alloc<span style="color: #002200;">]</span> initWithPath<span style="color: #002200;">:</span>path<span style="color: #002200;">]</span> autorelease<span style="color: #002200;">]</span>; &nbsp;   <span style="color: #11740a; font-style: italic;">// Show the movie player as modal</span>   <span style="color: #002200;">[</span>self presentModalViewController<span style="color: #002200;">:</span>mov<wbr>iePlayer animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">]</span>; &nbsp;   <span style="color: #11740a; font-style: italic;">// Prep and play the movie</span>   <span style="color: #002200;">[</span>moviePlayer readyPlayer<span style="color: #002200;">]</span>;     <span style="color: #002200;">}</span></pre></div><p>Notice that the movie for this example is loaded from the application bundle. Also, once the custom movie player is created, the view is shown as a modal view.</p><h5>Custom Movie Player View Controller</h5><p>The interface definition for the movie view controller is below:</p><div><pre style="white-space: pre-wrap;"><span style="color: #a61390;">@interface</span> CustomMoviePlayerViewControlle<wbr>r <span style="color: #002200;">:</span> UIViewController  <span style="color: #002200;">{</span>   MPMoviePlayerController <span style="color: #002200;">*</span>mp;   <span style="color: #400080;">NSURL</span>  <span style="color: #002200;">*</span>movieURL; <span style="color: #002200;">}</span> &nbsp; <span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">id</span><span style="color: #002200;">)</span>initWithPath<span style="color: #002200;">:</span><span style="color: #002200;">(</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">)</span>moviePath; <span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span>readyPlayer; &nbsp; <span style="color: #a61390;">@end</span></pre></div><p>The initialization code is where the movie player and associated URL are created. The primary goal of the initialization is to create the&nbsp;<strong>NSURL</strong>&nbsp;needed by the movie player.</p><div><pre style="white-space: pre-wrap;"><span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">id</span><span style="color: #002200;">)</span>initWithPath<span style="color: #002200;">:</span><span style="color: #002200;">(</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">)</span>moviePath <span style="color: #002200;">{</span>   <span style="color: #11740a; font-style: italic;">// Initialize and create movie URL</span>   <span style="color: #a61390;">if</span> <span style="color: #002200;">(</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">[</span>super init<span style="color: #002200;">]</span><span style="color: #002200;">)</span>   <span style="color: #002200;">{</span>     movieURL <span style="color: #002200;">=</span> <span style="color: #002200;">[</span><span style="color: #400080;">NSURL</span> fileURLWithPath<span style="color: #002200;">:</span>moviePath<span style="color: #002200;">]</span>;         <span style="color: #002200;">[</span>movieURL retain<span style="color: #002200;">]</span>;   <span style="color: #002200;">}</span>   <span style="color: #a61390;">return</span> self; <span style="color: #002200;">}</span></pre></div><p>The code to create the player and setup the notifications is where we start to deal with the differences in how the movie player works on various OS versions. Notice below the call to&nbsp;<strong>respondsToSelector</strong>, this is the Apple recommended way to check for feature availability, versus looking for a specific OS version.</p><p>For devices running 3.2 and above, the movie player controller has a method named<strong>loadstate</strong>, if this exists we can access a few additional methods to set the player to fullscreen as well as request the movie to begin preloading.</p><p>Equally important is the distinction of which notification to setup &#8211; see lines 16 and 24.</p><p>You can read more about managing different OS version in this post&nbsp;<a href="http://iphonedevelopertips.com/xcode/base-sdk-and-iphone-os-deployment-target-developing-apps-with-the-4-x-sdk-deploying-to-3-x-devices.html" target="_blank" style="color: #1155cc;">Developing iPhone Apps with iOS4 SDK, Deploying to 3.x Devices</a></p><div><table><tbody><tr><td style="margin: 0px;"><pre style="white-space: pre-wrap;">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 </pre></td><td style="margin: 0px;"><pre style="white-space: pre-wrap;"><span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span> readyPlayer <span style="color: #002200;">{</span>    mp <span style="color: #002200;">=</span>  <span style="color: #002200;">[</span><span style="color: #002200;">[</span>MPMoviePlayerController alloc<span style="color: #002200;">]</span> initWithContentURL<span style="color: #002200;">:</span>movieURL<span style="color: #002200;">]</span>; &nbsp;   <span style="color: #11740a; font-style: italic;">// For 3.2 devices and above</span>   <span style="color: #a61390;">if</span> <span style="color: #002200;">(</span><span style="color: #002200;">[</span>mp respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>l<wbr>oadState<span style="color: #002200;">)</span><span style="color: #002200;">]</span><span style="color: #002200;">)</span>    <span style="color: #002200;">{</span>     <span style="color: #11740a; font-style: italic;">// Set movie player layout</span>     <span style="color: #002200;">[</span>mp setControlStyle<span style="color: #002200;">:</span>MPMovieControl<wbr>StyleFullscreen<span style="color: #002200;">]</span>;     <span style="color: #002200;">[</span>mp setFullscreen<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">]</span>; &nbsp;     <span style="color: #11740a; font-style: italic;">// May help to reduce latency</span>     <span style="color: #002200;">[</span>mp prepareToPlay<span style="color: #002200;">]</span>; &nbsp;     <span style="color: #11740a; font-style: italic;">// Register that the load state changed (movie is ready)</span>     <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #400080;">NSNotificationCenter</span> defaultCenter<span style="color: #002200;">]</span> addObserver<span style="color: #002200;">:</span>self          selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>moviePlayer<wbr>LoadStateChanged<span style="color: #002200;">:</span><span style="color: #002200;">)</span>          name<span style="color: #002200;">:</span>MPMoviePlayerLoadStateDid<wbr>ChangeNotification          object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">]</span>;   <span style="color: #002200;">}</span>     <span style="color: #a61390;">else</span>   <span style="color: #002200;">{</span>     <span style="color: #11740a; font-style: italic;">// Register to receive a notification when the movie is in memory and ready to play.</span>     <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #400080;">NSNotificationCenter</span> defaultCenter<span style="color: #002200;">]</span> addObserver<span style="color: #002200;">:</span>self          selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>moviePreloa<wbr>dDidFinish<span style="color: #002200;">:</span><span style="color: #002200;">)</span>          name<span style="color: #002200;">:</span>MPMoviePlayerContentPrelo<wbr>adDidFinishNotification          object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">]</span>;   <span style="color: #002200;">}</span> &nbsp;   <span style="color: #11740a; font-style: italic;">// Register to receive a notification when the movie has finished playing. </span>   <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #400080;">NSNotificationCenter</span> defaultCenter<span style="color: #002200;">]</span> addObserver<span style="color: #002200;">:</span>self          selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">(</span>moviePlayBa<wbr>ckDidFinish<span style="color: #002200;">:</span><span style="color: #002200;">)</span>          name<span style="color: #002200;">:</span>MPMoviePlayerPlaybackDidF<wbr>inishNotification          object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">]</span>; <span style="color: #002200;">}</span></pre></td></tr></tbody></table></div><p>The next two chunks of code are for each of the selectors, one for each notification. The code below is for earlier OS versions &#8211; nothing more than removing the notification and asking the movie to play.</p><div><pre style="white-space: pre-wrap;"><span style="color: #11740a; font-style: italic;">/*----------------------------<wbr>------------------------------<wbr>----------------- * For 3.1.x devices * For 3.2 and 4.x see moviePlayerLoadStateChanged:  *-----------------------------<wbr>------------------------------<wbr>---------------*/</span> <span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span> moviePreloadDidFinish<span style="color: #002200;">:</span><span style="color: #002200;">(</span><span style="color: #400080;">NSNotif<wbr>ication</span><span style="color: #002200;">*</span><span style="color: #002200;">)</span>notification  <span style="color: #002200;">{</span>   <span style="color: #11740a; font-style: italic;">// Remove observer</span>   <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #400080;">NSNotificationCenter</span> 	defaultCenter<span style="color: #002200;">]</span>      removeObserver<span style="color: #002200;">:</span>self     name<span style="color: #002200;">:</span>MPMoviePlayerContentPrelo<wbr>adDidFinishNotification     object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">]</span>; &nbsp;   <span style="color: #11740a; font-style: italic;">// Play the movie</span>    <span style="color: #002200;">[</span>mp play<span style="color: #002200;">]</span>; <span style="color: #002200;">}</span></pre></div><p>For the notification generated in 3.2 and above, there are a few more details to tend to:</p><div><pre style="white-space: pre-wrap;"><span style="color: #11740a; font-style: italic;">/*----------------------------<wbr>------------------------------<wbr>----------------- * For 3.2 and 4.x devices * For 3.1.x devices see moviePreloadDidFinish: *-----------------------------<wbr>------------------------------<wbr>---------------*/</span> <span style="color: #002200;">-</span> <span style="color: #002200;">(</span><span style="color: #a61390;">void</span><span style="color: #002200;">)</span> moviePlayerLoadStateChanged<span style="color: #002200;">:</span><span style="color: #002200;">(</span><span style="color: #400080;">N<wbr>SNotification</span><span style="color: #002200;">*</span><span style="color: #002200;">)</span>notification  <span style="color: #002200;">{</span>   <span style="color: #11740a; font-style: italic;">// Unless state is unknown, start playback</span>   <span style="color: #a61390;">if</span> <span style="color: #002200;">(</span><span style="color: #002200;">[</span>mp loadState<span style="color: #002200;">]</span> <span style="color: #002200;">!=</span> MPMovieLoadStateUnknown<span style="color: #002200;">)</span>   <span style="color: #002200;">{</span>     <span style="color: #11740a; font-style: italic;">// Remove observer</span>     <span style="color: #002200;">[</span><span style="color: #002200;">[</span><span style="color: #400080;">NSNotificationCenter</span> defaultCenter<span style="color: #002200;">]</span>        removeObserver<span style="color: #002200;">:</span>self       name<span style="color: #002200;">:</span>MPMoviePlayerLoadStateDid<wbr>ChangeNotification        object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">]</span>; &nbsp;     <span style="color: #11740a; font-style: italic;">// When tapping movie, status bar will appear, it shows up</span>     <span style="color: #11740a; font-style: italic;">// in portrait mode by default. Set orientation to landscape</span>     <span style="color: #002200;">[</span><span style="color: #002200;">[</span>UIApplication sharedApplication<span style="color: #002200;">]</span> setStatusBarOrientation<span style="color: #002200;">:</span>UIInte<wbr>rfaceOrientationLandscapeRight animated<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">]</span>; &nbsp;     <span style="color: #11740a; font-style: italic;">// Rotate the view for landscape playback</span>     <span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> setBounds<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">(</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">480</span>, <span style="color: #2400d9;">320</span><span style="color: #002200;">)</span><span style="color: #002200;">]</span>;     <span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> setCenter<span style="color: #002200;">:</span>CGPointMake<span style="color: #002200;">(</span><span style="color: #2400d9;">160</span>, <span style="color: #2400d9;">240</span><span style="color: #002200;">)</span><span style="color: #002200;">]</span>;     <span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> setTransform<span style="color: #002200;">:</span>CGAffineTransform<wbr>MakeRotation<span style="color: #002200;">(</span>M_PI <span style="color: #002200;">/</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">)</span><span style="color: #002200;">]</span>;  &nbsp;     <span style="color: #11740a; font-style: italic;">// Set frame of movie player</span>     <span style="color: #002200;">[</span><span style="color: #002200;">[</span>mp view<span style="color: #002200;">]</span> setFrame<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">(</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">480</span>, <span style="color: #2400d9;">320</span><span style="color: #002200;">)</span><span style="color: #002200;">]</span>; &nbsp;     <span style="color: #11740a; font-style: italic;">// Add movie player as subview</span>     <span style="color: #002200;">[</span><span style="color: #002200;">[</span>self view<span style="color: #002200;">]</span> addSubview<span style="color: #002200;">:</span><span style="color: #002200;">[</span>mp view<span style="color: #002200;">]</span><span style="color: #002200;">]</span>;    &nbsp;     <span style="color: #11740a; font-style: italic;">// Play the movie</span>     <span style="color: #002200;">[</span>mp play<span style="color: #002200;">]</span>;   <span style="color: #002200;">}</span> <span style="color: #002200;">}</span></pre></div><p>Beyond removing the notification, we also adjust the status bar, rotate the view, set the frame of the movie player, add the movie player as a subview in the view controller and wrap it all up by asking the movie to play.</p><p><strong>Note:</strong>&nbsp;MPMoviePlayerViewController is also an option over creating your own view controller as I&#8217;ve done here.</p><h5>Source Code</h5><p>The easiest way to see all this working is to&nbsp;<a href="http://iphonedevelopertips.com/wp-content/uploads/2010/07/MoviePlayer-ios4.zip" target="_blank" style="color: #1155cc;">download the source code</a>&nbsp;and step through the code in the debugger.</p></div><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" />＋＋＋＋＋<img src ="http://www.cppblog.com/walkklookk/aggbug/196832.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 11:21 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196832.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：iPhone编程小经验 -6</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196828.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 02:26:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196828.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196828.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196828.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196828.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196828.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.04.29</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.05.26</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.06.09</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.06.16</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.06.27</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">日期：2011.06.29</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*自定义的类型，进行传递的时候，尽量使用retain的方式。</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">否则，每次使用copy</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">的方式，每次添加新的变量，都要更新copy协议的内容， 很麻烦。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*成员变量的访问函数，最好不要处理的很复杂，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">尽量使用系统的就可以了。如</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">果需要复杂的操作，那么最好是使用 另外一个函数名和函数。例如，对于</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">MediaFile的attachment的set函数，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">因为要自动的根据1024*768缩放，因此重写了</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">系统的行为。但是，后来又要求对于来 自相机的要进行960＊768的缩放，因此要</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">针对另外一个变量mIsComeFromCamera来决定行为</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">。这样，在NSCopy协议的函数中</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">就引起问题了。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">总之，如果操作另类的话，还是单独做个函数吧。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*UI的切换销毁等等，经常由于切换过快导致异常。</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">其原因常常是，A页面在Load数据，但是还没有Load完，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">但是，由于页面切换，导致A页面被释放了。而后，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">ALoad完毕数据之后，进行页面更新，导致访问异常。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">正常来说，应该不会出现这种情况，比如，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">在Load的时候锁死页面不允许切换，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">或者开启另外的线程进行切换，但是处理好对象的引用。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">但是，实际上可能不会那么完美，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">很可能在你下载数据之时和锁死页面之间，用户的快速操作，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">导致了A的释放。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">一个比较好的方法是：使用一个数组保存要释放对象，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">然后定义一个timer，每10s或30s进行一次操作，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">删除已经被废弃很久的对象。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">当然，保存的时候，要保留当时的时间，用于比对。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">UITabBarController的UITabBarIte</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">m的标题通常可以在xib中设定。但是有时候发</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">现，当点击某个index后，该 index的标题变化了。这是因为，这个index的标题是</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">会根据当前ViewController的title变化的，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">因此如果你在代码中设定 了</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">viewcontroller的self.title = @"xxxx"，那么标题就会变为xxxx。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果你希望VC的title和item的title不相同，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">那么不要使用self.title而使用：</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">self.navigationController.</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">navigationBar.topItem.title = @"My Title";</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＊NSOperationManager最好不要同时存在多个。</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">因为，如果同时存在多个，则</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＊＊不能控制线程数量。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＊＊相同的请求无法取消了。比如，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">恰好有2个请求相同图片的请求，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">则很可能两个Manager同时请求服务器，导致多出一次请求。</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">并且，因为命名，位置等等原因还可能产生bug。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＊＊Op的优先级也无法保证了。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">*网站客户端软件中，如果要有持续化的操作的话，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">则一定要持续话最终的内存数据，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">而不要直接缓存网络请求的返回内容（通常是个Json值）。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">因为一旦这么做了，那么会产生一些问题。众所周知，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">网站客户端软件比普通的Safari网页的优势在于：</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">1，暂时不需要看到的内容可以暂时不下载，即使是在一个页面中，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">例如爱拍动态页面的各个图片，只有下载看到时，才会下载。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">2，如果只更新了部分内容，如评论信息，则不需要更改全部页面，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">只需要更改某条记录即可。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">3，如果删除了某些内容，则也不必重新下载全部页面。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">综上，也就是说，在最初返回的缓存内容之后，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">用户很可能会进行一些修改和删除等操作，</span><wbr style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果直接缓存Json值，则导致这个数值并不是最后的结果。</span><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">+++++</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196828.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 10:26 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196828.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：CookBook SDK3.0 Note</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/30/196827.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sun, 30 Dec 2012 02:22:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/30/196827.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196827.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/30/196827.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196827.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196827.html</trackback:ping><description><![CDATA[创建：2011.05.16<br style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;" /><br />CookBook SDK3.0 Note<br /><br />==第17章 使用CoreLocation和MapKit==<br />＊GPS，Wifi，基站，因特网提供商定位。<br />＊无论精确度设定为多高，这些技术都会被用到。因此，<wbr>仍需要在回调的时候，进行精确度判断。<br />因此，想要进行精确的平均速度，要执行如下步骤：<br />#1,<wbr>使用最高的精确度kCLLocationAccuracyBes<wbr>t<br />#2,多次回调，取平均值<br />#3,过滤掉误差太大的值<br />＊distanceFilter，移动多少米，<wbr>才发送一次定位回调。<br />＊desiredAccuracy精确度<br />＊<wbr>locationServicesEnabled是否开启了定位<br />＊一次请求，10s－1min<br />＊平均速度：2.23693629*distance/<wbr>dTime<br />＊speed不准。<br />*北向，略。<br />＊逆向地址编码：从经纬度得到人类可用的地址信息。<wbr>使用的是MapKit中google的服务。<wbr>MKReverseGeocoder。<br />*MapKit显示范围可以指定为米，也可以为经纬度数。<br /><br />＊取得比较精确的位置：设定一个10s的timer，<wbr>在10s内取得精度最高的经纬度值。<br />＊showsUserLocation显示当前位置，<wbr>是使用CoreLocation定位的。<br /><br /><br /><br />+++++<img src ="http://www.cppblog.com/walkklookk/aggbug/196827.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-30 10:22 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/30/196827.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：ios Map App的一些内容</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196795.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 03:12:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196795.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196795.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196795.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196795.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196795.html</trackback:ping><description><![CDATA[<div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">关于调用：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p>+ (void)<wbr>navigationToMapAppFromCurrentT<wbr>oBranch:(BranchInfo *)info {</p><p>&nbsp; &nbsp; NSString* urlString = [NSString stringWithFormat:@"<a href="http://maps.google.com/maps?saddr=%@&amp;daddr=%@,%@" target="_blank" style="color: #1155cc;">http://<wbr>maps.google.com/maps?saddr=%@&amp;<wbr>daddr=%@,%@</a>",[<wbr>BranchLocatorGlobal currentLocationStringForCurren<wbr>tLanguage] , info.lat, info.lon];</p><p>&nbsp; &nbsp; NSString* urlString2 = [urlString stringByAddingPercentEscapesUs<wbr>ingEncoding:<wbr>NSUTF8StringEncoding];</p><p>&nbsp; &nbsp; NSURL* url = [[NSURL alloc]initWithString:<wbr>urlString2];</p><p>&nbsp; &nbsp; [[UIApplication sharedApplication] openURL:url];</p><p>}</p><p>关于参数：</p><p>在ios下，对于saddr可以指定为<span style="line-height: 19px; font-size: 13px; font-family: sans-serif;">"Current%<wbr>20Location"，这样可以指定Map使用本机的地址。</span></p><p><span style="line-height: 19px; font-size: 13px; font-family: sans-serif;">但是这个功能有个bug，参见：</span></p><p>&nbsp;</p><p><a href="http://www.martip.net/blog/localized-current-location-string-for-iphone-apps" target="_blank" style="color: #1155cc;">http://www.martip.net/blog/<wbr>localized-current-location-<wbr>string-for-iphone-apps</a></p><p><br /></p><p>&nbsp;</p><p><span style="line-height: 19px; font-size: 13px; font-family: sans-serif;"><br /></span></p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">关于参数，可以参见：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><a href="http://mapki.com/wiki/Google_Map_Parameters" target="_blank" style="color: #1155cc;">http://mapki.com/wiki/Google_<wbr>Map_Parameters</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><a href="https://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html" target="_blank" style="color: #1155cc;">https://developer.apple.com/<wbr>library/ios/#featuredarticles/<wbr>iPhoneURLScheme_Reference/<wbr>Articles/MapLinks.html</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196795.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 11:12 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196795.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：自定义UIPageControl的indicator的image</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196793.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 03:11:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196793.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196793.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196793.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196793.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196793.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.03.01</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：来自F。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＝＝＝CustomPageControl.h＝＝＝</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p>#import&nbsp;&lt;Foundation/Foundation.h&gt;</p><p>#import&nbsp;&lt;UIKit/UIKit.h&gt;</p><p><br /></p><p>@interface&nbsp;CustomPageControl :&nbsp;UIPageControl&nbsp;{</p><p>&nbsp; &nbsp;&nbsp;UIImage* imageNormal;</p><p>&nbsp; &nbsp;&nbsp;UIImage* imageCurrent;</p><p>}</p><p><br /></p><p>@property&nbsp;(nonatomic,&nbsp;retain)&nbsp;UIImage* imageNormal;</p><p>@property&nbsp;(nonatomic,&nbsp;retain)&nbsp;UIImage* imageCurrent;</p><p>@end</p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＝＝＝CustomPageControl.m＝＝＝</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p>#import&nbsp;"CustomPageControl.h"</p><p><br /></p><p>@interface&nbsp;CustomPageControl(Private)</p><p>- (void) updateDots;</p><p>@end</p><p><br /></p><p>@implementation&nbsp;CustomPageControl</p><p>@synthesize&nbsp;imageNormal,imageCurrent;</p><p><br /></p><p><br /></p><p>/** override to update dots */</p><p>- (void) setCurrentPage:(NSInteger)<wbr>currentPage</p><p>{</p><p>&nbsp; &nbsp; [super&nbsp;setCurrentPage:currentPage];</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp;&nbsp;// update dot views</p><p>&nbsp; &nbsp; [self&nbsp;updateDots];</p><p>}</p><p><br /></p><p>/** override to update dots */</p><p>- (void) updateCurrentPageDisplay</p><p>{</p><p>&nbsp; &nbsp; [super&nbsp;updateCurrentPageDisplay];</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp;&nbsp;// update dot views</p><p>&nbsp; &nbsp; [self&nbsp;updateDots];</p><p>}</p><p><br /></p><p>/** Override setImageNormal */</p><p>- (void) setImageNormal:(UIImage*)image</p><p>{</p><p>&nbsp; &nbsp; [imageNormal&nbsp;release];</p><p>&nbsp; &nbsp;&nbsp;imageNormal&nbsp;= [image&nbsp;retain];</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp;&nbsp;// update dot views</p><p>&nbsp; &nbsp; [self&nbsp;updateDots];</p><p>}</p><p><br /></p><p>/** Override setImageCurrent */</p><p>- (void) setImageCurrent:(UIImage*)<wbr>image</p><p>{</p><p>&nbsp; &nbsp; [imageCurrent&nbsp;release];</p><p>&nbsp; &nbsp;&nbsp;imageCurrent&nbsp;= [image&nbsp;retain];</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp;&nbsp;// update dot views</p><p>&nbsp; &nbsp; [self&nbsp;updateDots];</p><p>}</p><p><br /></p><p>- (void) endTrackingWithTouch:(UITouch*<wbr>)touch withEvent:(UIEvent*)event&nbsp;</p><p>{</p><p>&nbsp; &nbsp; [super&nbsp;endTrackingWithTouch:touch&nbsp;withEvent:event];</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; [self&nbsp;updateDots];</p><p>}</p><p><br /></p><p>#pragma mark -</p><p>#pragma mark updateDots</p><p><br /></p><p>- (void) updateDots</p><p>{</p><p>&nbsp; &nbsp;&nbsp;if(imageNormal&nbsp;||&nbsp;imageCurrent)</p><p>&nbsp; &nbsp; {</p><p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;// Get subviews</p><p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;NSArray* dotViews =&nbsp;self.subviews;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;for(int&nbsp;i =&nbsp;0; i &lt; dotViews.count; ++i)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;UIImageView* dot = [dotViews&nbsp;objectAtIndex:i];</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;// Set image</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dot.image&nbsp;= (i ==&nbsp;self.currentPage) ?&nbsp;imageCurrent&nbsp;:&nbsp;imageNormal;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; }</p><p>}</p><p>#pragma mark-</p><p>#pragma mark dealloc</p><p>- (void) dealloc</p><p>{</p><p>&nbsp; &nbsp; [imageNormal&nbsp;release];</p><p>&nbsp; &nbsp;&nbsp;imageNormal&nbsp;=&nbsp;nil;</p><p>&nbsp; &nbsp; [imageCurrent&nbsp;release];</p><p>&nbsp; &nbsp;&nbsp;imageCurrent&nbsp;=&nbsp;nil;</p><p>&nbsp;&nbsp; &nbsp;</p><p>[super&nbsp;dealloc];</p><p>}</p><p><br /></p><p>@end</p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196793.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 11:11 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196793.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：禁用UITableViewCell</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196788.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 03:08:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196788.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196788.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196788.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196788.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196788.html</trackback:ping><description><![CDATA[<span style="color: #222222; background-color: #ffffff;">创建：2011.10.25</span><br style="color: #222222; background-color: #ffffff;" /><br style="color: #222222; background-color: #ffffff;" /><span style="line-height: 18px;">禁用UITableViewCell：cell.<wbr>userInteractionEnabled = NO;<div><div>- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(<wbr>NSIndexPath *)indexPath {</div><div>&nbsp; &nbsp; return nil;</div><div>}<br /></div></div></span><span style="color: #222222; background-color: #ffffff;">设定cell为灰色，没有什么直接的办法，只能：</span><br style="color: #222222; background-color: #ffffff;" /><span style="color: #222222; background-color: #ffffff;">一：为cell.contentView加入一个子view，<wbr>让该子view的背景颜色为灰色。</span><br style="color: #222222; background-color: #ffffff;" /><span style="color: #222222; background-color: #ffffff;">二：<wbr>也可以直接放cell上的textField的字体设定为灰色。</span><br style="color: #222222; background-color: #ffffff;" /><br style="color: #222222; background-color: #ffffff;" /><br style="color: #222222; background-color: #ffffff;" /><span style="color: #222222; background-color: #ffffff;">＋＋＋＋＋</span><img src ="http://www.cppblog.com/walkklookk/aggbug/196788.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 11:08 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196788.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：去掉UITableView的分割线</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196786.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 03:07:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196786.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196786.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196786.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196786.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196786.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.03.15</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果是UITableViewStylePlain类型的UIT<wbr>ableView，则可以直接调用</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">tableview.separatorStyle = UITableViewCellSeparatorStyleN<wbr>one;</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">tableview.separatorColor&nbsp;= [UIColor clearColor];</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果是UITableViewStyleGrouped类型，<wbr>则除了上面的调用外，<wbr>还需要把cell的contentView的color设定为c<wbr>learColor。可能还需要设定opaque为透明。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196786.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 11:07 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196786.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：修改UIModalPresentationFormSheet风格的model view controller的宽高</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196785.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 03:06:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196785.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196785.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196785.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196785.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196785.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.03.16</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：<a href="http://stackoverflow.com/questions/2457947/how-to-resize-a-uipresentationformsheet" target="_blank" style="color: #1155cc;">http://stackoverflow.com/<wbr>questions/2457947/how-to-<wbr>resize-a-<wbr>uipresentationformsheet</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><span style="line-height: 18px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">You are able to adjust the frame of a modal view after presenting it:</span></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><pre style="white-space: pre-wrap; padding: 5px; border-width: 0px; max-height: 600px; width: auto; margin-bottom: 10px; vertical-align: baseline; line-height: 18px; overflow: auto; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin-top: 0px;"><code style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #2b91af;">MyModalViewController</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">*</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">targetController </span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">=</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">[[[</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #2b91af;">MyModalViewController</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"> alloc</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">]</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"> init</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">]</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"> autorelease</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">];</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"><br /> targetController</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">modalPresenta<wbr>tionStyle </span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">=</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #2b91af;">UIModalPresentationFormSheet</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">;</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"><br /> targetController</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">modalTransiti<wbr>onStyle </span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">=</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #2b91af;">UIModalTransitionStyleFlipHori<wbr>zontal</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">;</span>&nbsp;<span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: gray;">//transition shouldn't matter</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"><br /> </span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">[</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">self presentModalViewController</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">:</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">tar<wbr>getController animated</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">:</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">YES</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">];</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"><br /> targetController</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">view</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">supervie<wbr>w</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">frame </span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">=</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #2b91af;">CGRectMake</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">(</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #800000;">0</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">,</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #800000;">0</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">,</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #800000;">200</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">,</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #800000;">200</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">);</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: gray;">//it's important to do this after presentModalViewController</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"><br /> targetController</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">view</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">supervie<wbr>w</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">center </span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">=</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"> self</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">view</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">center</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">;</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: gray;">//self.view assumes the base view is doing the launching, if not you might need self.view.superview.center etc.</span></code></pre></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>It works also for me on iPad, but... If I rotate the device, the view is not centered &#8211; Mauro Delrio Aug 25 '11 at 17:56</div><div></div><div></div><div>@MauroDelrio To make it work correctly from landscape you need to flip the center coordinates. ex:</div><div>&nbsp;CGPoint center = self.view.center; targetController.view.<wbr>superview.center = {isPortrait} ? center : CGPointMake(center.y, center.x);</div><div>&nbsp;&#8211; Nate Weiner Jan 6 at 1:36</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196785.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 11:06 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196785.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：让UIWebView背景透明</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196784.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 03:06:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196784.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196784.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196784.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196784.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196784.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.03.22</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;<span style="line-height: 18px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;">I recommend:</span></div><pre style="white-space: pre-wrap; color: #222222; background-color: #ffffff; padding: 5px; border-width: 0px; max-height: 600px; width: auto; margin-bottom: 10px; vertical-align: baseline; line-height: 18px; overflow: auto; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin-top: 0px;"><code style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">webView</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">opaque </span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">=</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"> NO</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">;</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"><br /> webView</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">backgroundColor </span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">=</span> <span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">[</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #2b91af;">UIColor</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"> clearColor</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">];</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"><br /> </span></code></pre><p style="color: #222222; background-color: #ffffff; padding: 0px; border-width: 0px; margin: 0px 0px 1em; clear: both; vertical-align: baseline; line-height: 18px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; word-wrap: break-word;">(for some reason it didn't work to set those properties via IB) and include this into your HTML code:</p><pre style="white-space: pre-wrap; color: #222222; background-color: #ffffff; padding: 5px; border-width: 0px; max-height: 600px; width: auto; margin-bottom: 10px; vertical-align: baseline; line-height: 18px; overflow: auto; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin-top: 0px;"><code style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">&lt;</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">body style</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">=</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #800000;">"background-color: transparent;"</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">&gt;</span></code></pre><pre style="white-space: pre-wrap; color: #222222; background-color: #ffffff; padding: 5px; border-width: 0px; max-height: 600px; width: auto; margin-bottom: 10px; vertical-align: baseline; line-height: 18px; overflow: auto; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin-top: 0px;"><code style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;"><br /> </span></code></pre>［自：注意：<wbr>设置opaque和backgroundColor时不能在XI<wbr>B中进行，在ios4中，在xib配置将不起作用。<wbr>不过在ios5中却正常。<div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">后面的html内容根据情况来看，有时候不加也可以的。］<pre style="white-space: pre-wrap; padding: 5px; border-width: 0px; max-height: 600px; width: auto; margin-bottom: 10px; vertical-align: baseline; line-height: 18px; overflow: auto; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin-top: 0px;"><span style="background-color: transparent;"><br /></span></pre><pre style="white-space: pre-wrap; padding: 5px; border-width: 0px; max-height: 600px; width: auto; margin-bottom: 10px; vertical-align: baseline; line-height: 18px; overflow: auto; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin-top: 0px;"><span style="background-color: transparent;"><br /></span></pre><pre style="white-space: pre-wrap; padding: 5px; border-width: 0px; max-height: 600px; width: auto; margin-bottom: 10px; vertical-align: baseline; line-height: 18px; overflow: auto; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin-top: 0px;"><span style="background-color: transparent;">＋＋＋＋＋</span></pre></div><img src ="http://www.cppblog.com/walkklookk/aggbug/196784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 11:06 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196784.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：UITextField的键盘在 "form sheet" style的 model view controller中不会自动消失</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196781.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:59:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196781.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196781.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196781.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196781.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196781.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.03.29</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：<a href="http://stackoverflow.com/questions/8379205/uitextfields-keyboard-wont-dismiss-no-really" target="_blank" style="color: #1155cc;">http://stackoverflow.com/<wbr>questions/8379205/<wbr>uitextfields-keyboard-wont-<wbr>dismiss-no-really</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p style="padding: 0px; border-width: 0px; margin: 0px 0px 1em; clear: both; vertical-align: baseline; line-height: 18px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; word-wrap: break-word;">The Apple docs&nbsp;<a href="http://developer.apple.com/library/IOS/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/ManageTextFieldTextViews/ManageTextFieldTextViews.html" target="_blank" style="color: #4a6b82; margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; text-decoration: initial;">describe this exception</a>:</p><blockquote style="margin-top: 0px; margin-right: 0px; margin-left: 0px; padding-top: 10px; padding-bottom: 1px; border-width: 0px; vertical-align: baseline; background-color: #eeeeee; quotes: none; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px;"><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">On the iPad, if a view controller modally presents its view using the "form sheet" style, the keyboard, once shown, is not hidden until the user taps the dismiss key or the modal view controller is programmatically dismissed. The purpose of this behavior is to avoid excessive animations as a user moves between views that are largely, but not entirely, text fields.</p></blockquote><p style="padding: 0px; border-width: 0px; margin: 0px 0px 1em; clear: both; vertical-align: baseline; line-height: 18px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; word-wrap: break-word;">Which happens to apply here (modal form sheet on iPad). It's apparently just not possible to dismiss the keyboard in this case. Super. :\</p><p style="padding: 0px; border-width: 0px; margin: 0px 0px 1em; clear: both; vertical-align: baseline; line-height: 18px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; word-wrap: break-word;"><br /></p><p style="padding: 0px; border-width: 0px; margin: 0px 0px 1em; clear: both; vertical-align: baseline; line-height: 18px; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; word-wrap: break-word;">＋＋＋＋＋</p></div><img src ="http://www.cppblog.com/walkklookk/aggbug/196781.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:59 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196781.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：UIWindowLevelAlert导致UIAlertView无法显示</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196778.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:58:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196778.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196778.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196778.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196778.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196778.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.04.08</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">Loading页面放到了一个自定义的window下，<wbr>该window的windowLevel&nbsp;=UIWindowLevelAlert;<wbr>会导致后来弹出的Alert无法显示。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改方法是，将windowLevel设置为UIWindowL<wbr>evelStatusBar。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196778.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:58 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196778.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：UILabel的字模糊</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196773.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:55:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196773.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196773.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196773.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196773.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196773.html</trackback:ping><description><![CDATA[<div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.04.30</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：<a href="http://stackoverflow.com/questions/8065892/blurry-uilabel-when-added-programatically" target="_blank" style="color: #1155cc;">http://stackoverflow.com/<wbr>questions/8065892/blurry-<wbr>uilabel-when-added-<wbr>programatically</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">原因是：UILabel的frame中有浮点值，<wbr>或者是UILabel的superview的frame有浮点值<wbr>。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">解决方法是：将所有的浮点值变为整数值。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">可以使用<span style="color: #2b91af; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; line-height: 18px;">CGRectIntegral</span>函数，例如：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 10px; padding: 5px; border-width: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px;"><code style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">[</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">loadingText setFrame</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">:</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent; color: #2b91af;">CGRectIntegral</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">(</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">loadin<wbr>gText</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">.</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">frame</span><span style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; background-color: transparent;">)];</span></code></pre><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 10px; padding: 5px; border-width: 0px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px;"><code style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><br /> </code></pre><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 10px; padding: 5px; border-width: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; line-height: 18px;"><code style="margin: 0px; padding: 0px; border-width: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;">＋＋＋＋＋</code></pre></div><img src ="http://www.cppblog.com/walkklookk/aggbug/196773.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:55 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196773.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：为UIButton加入重叠背景图片</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196768.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:51:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196768.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196768.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196768.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196768.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196768.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：120630</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">为UIButton加入背景图片很容易，<wbr>但是如果背景图片是以重叠方式加入的，而非一个完整的图片，<wbr>则比较困难。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">思路是建立一个sublayer加入到button的layer<wbr>上。该sublayer负责加入背景图片。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">同时，layer的borderColor设定边框，<wbr>sublayer的borderColor设定内部边框。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">同时要注意：初始的button的宽高一定要很长，<wbr>否则无法正确加载图片和边框。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">同时，textLabel一定要重新调整到最前方，否则，<wbr>无法在显示文字。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p>@implementation&nbsp;UIButton (ContextualAction)</p><p><br /></p><p>- (void)setContextualActionStyle</p><p>{</p><p>&nbsp; &nbsp;&nbsp;UIButton&nbsp;*button =&nbsp;self;</p><p>&nbsp; &nbsp;&nbsp;CGRect&nbsp;oldFrame = button.frame;</p><p>&nbsp; &nbsp;&nbsp;button.frame&nbsp;=&nbsp;CGRectMake(0.0f,&nbsp;0.0f,&nbsp;1000.0f,&nbsp;1000.0f);&nbsp;// width and height must be bigger enough.</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp;&nbsp;CALayer&nbsp;*layer = button.layer;</p><p>&nbsp; &nbsp; layer.cornerRadius&nbsp;=&nbsp;5.0f;</p><p>&nbsp; &nbsp; layer.masksToBounds&nbsp;=&nbsp;YES;</p><p>&nbsp; &nbsp; layer.borderWidth&nbsp;=&nbsp;1.0f;</p><p>&nbsp; &nbsp; layer.borderColor&nbsp;= [UIColor&nbsp;lightGrayColor].CGColor;</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp;&nbsp;CALayer&nbsp;*shineLayer = [CALayer&nbsp;layer];</p><p>&nbsp; &nbsp; shineLayer.frame&nbsp;= button.layer.bounds;</p><p>&nbsp; &nbsp;&nbsp;UIImage&nbsp;*lightGrayBackgroundImage = [UIImage&nbsp;imageNamed:@"texture_light.<wbr>png"]; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; shineLayer.backgroundColor&nbsp;=&nbsp; [UIColor&nbsp;colorWithPatternImage:<wbr>lightGrayBackgroundImage].CGCo<wbr>lor;</p><p>&nbsp; &nbsp;&nbsp;shineLayer.borderWidth&nbsp;=&nbsp;2.0f;&nbsp;// 1.0f px will be cover by layer.border.</p><p>&nbsp; &nbsp;&nbsp;shineLayer.borderColor&nbsp;= [UIColor&nbsp;whiteColor].CGColor;</p><p>&nbsp; &nbsp; [button.layer&nbsp;addSublayer:shineLayer];</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; button.titleLabel.textAlignmen<wbr>t&nbsp;=&nbsp;UITextAlignmentCenter;</p><p>&nbsp; &nbsp; button.titleLabel.font&nbsp;= [UIFont&nbsp;boldSystemFontOfSize:10];</p><p>&nbsp; &nbsp; [button&nbsp;setTitleColor:[UIColor&nbsp;colorWithRed:102.0f/255.0f&nbsp;green:102.0f/255.0fblue:102.0f/255.0f&nbsp;alpha:1.0f]&nbsp;forState:UIControlStateNormal]<wbr>;</p><p>&nbsp; &nbsp; [button&nbsp;setTitleShadowColor:[UIColor&nbsp;whiteColor]&nbsp;forState:UIControlStateNormal]<wbr>;</p><p>&nbsp; &nbsp; button.titleLabel.shadowOffset&nbsp;=&nbsp;CGSizeMake(0.0f,&nbsp;1.0f);</p><p>&nbsp; &nbsp;&nbsp;[button bringSubviewToFront:button.<wbr>titleLabel]; // must add. otherwise the title won't show.</p><p><br /></p><p>&nbsp; &nbsp;&nbsp;button.frame = oldFrame;</p><p>}</p><p><br /></p><p><br /></p><p>@end</p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196768.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:51 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196768.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：Enabling Remote Debugging via Private APIs in Mobile Safari</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196767.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:51:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196767.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196767.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196767.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196767.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196767.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.08.06</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">转：<a href="http://atnan.com/blog/2011/11/17/enabling-remote-debugging-via-private-apis-in-mobile-safari/" target="_blank" style="color: #1155cc;">http://atnan.com/blog/2011/<wbr>11/17/enabling-remote-<wbr>debugging-via-private-apis-in-<wbr>mobile-safari/</a></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><h1>Enabling Remote Debugging via Private APIs in Mobile Safari</h1><p style="margin: 0px; padding: 0px; border: 0px; font-size: 0.9em; font: inherit; vertical-align: baseline; color: #aaaaaa; font-family: 'PT Sans', 'Helvetica Neue', Arial, sans-serif; text-transform: uppercase;">NOV 17<span style="margin: 0px; padding: 0px; border: 0px; font-size: 17px; font: inherit; vertical-align: baseline;">TH</span>, 2011</p><div style="margin: 0px; border: 0px; font: inherit; vertical-align: baseline; font-family: 'PT Serif', Georgia, Times, 'Times New Roman', serif; line-height: 27.58333396911621px; background-color: #f8f8f8;"><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">The WebKit Web Inspector in Safari &amp; Chrome is part of every decent web developer&#8217;s toolkit, but unfortunately it&#8217;s unavailable in Mobile Safari.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Or is it?</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">While I was researching my previous article on&nbsp;<a href="http://atnan.com/blog/2011/11/03/enabling-and-using-webgl-on-ios/" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">enabling WebGL on iOS via private WebKit APIs</a>, another API caught my eye while I was&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">class-dump</code>ing the private&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">WebKit.framework</code>.</p><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline;">Private WebView API</span><div style="margin: 0px; font-size: 18px; font: inherit; vertical-align: baseline; background-color: #002b36; overflow-y: hidden; overflow-x: auto; border: 1px solid #05232b !important;"><table style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; border-collapse: collapse; border-spacing: 0px;"><tbody style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><tr style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; border-top-style: none; border-bottom-style: none; border-left-style: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; line-height: 1.45em; color: #93a1a1; overflow: auto; text-align: right; padding: 0.8em !important; border-right-width: 1px !important; border-right-style: solid !important; border-right-color: #00232c !important; background-image: url(http://atnan.com/images/noise.png?1330576444) !important; background-color: #073642 !important;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">1</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">2</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">3</span> </pre></td><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle; width: 758px;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; background-image: none; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em; line-height: 1.45em; color: #93a1a1; overflow: auto;"><code style="margin: 0px; border: 0px; font: inherit; vertical-align: baseline; overflow-y: hidden; display: block; overflow-x: auto; line-height: 1.45em; background-color: #000000; padding: 0.8em !important; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace !important;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">@interface</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #d33682 !important;">WebView</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #859900 !important;">(WebPrivate)</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">+</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">void</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">_enableRemoteInspector</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">;</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">@end</span> </span></code></pre></td></tr></tbody></table></div><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">I did a little bit of research and found an article by Pavel Feldman (<a href="https://twitter.com/repenaxa" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">@repenaxa</a>) on the Surfin&#8217; Safari blog about&nbsp;<a href="http://www.webkit.org/blog/1620/webkit-remote-debugging/" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">WebKit&#8217;s remote debugging feature</a>. This private&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">+[WebView _enableRemoteInspector]</code>API enables those same features in mobile WebKit.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><strong style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">Note:&nbsp;</strong>This API is available as of iOS 5.0. To use it, you&#8217;ll need a copy of Xcode with the iOS 5.0 SDK. You&#8217;ll also need to make sure that if you&#8217;ve got the iOS 4.0 SDK installed alongside the iOS 5.0 SDK, that you&#8217;ve selected iOS 5.0 in the iPhone Simulator via the&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">Hardware &#8594; Version</code>&nbsp;menu. Hat tip to Phil Oye (<a href="https://twitter.com/philoye" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">@philoye</a>) for pointing that out.</p><h2>Enabling remote debugging in a&nbsp;<code style="margin: 0px; padding: 0px; border: 0px; font-size: 28px; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace;">UIWebView</code></h2><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">To see if I could get it working, I checked out a copy of my&nbsp;<a href="https://github.com/atnan/UIWebViewWebGL" target="_blank" style="color: #751590; margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;">UIWebViewWebGL</a>&nbsp;project, and called the private API in&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">application:<wbr>didFinishLaunchingWithOptions</code>:</p><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline;">Enabling the remote inspector on launch</span><div style="margin: 0px; font-size: 18px; font: inherit; vertical-align: baseline; background-color: #002b36; overflow-y: hidden; overflow-x: auto; border: 1px solid #05232b !important;"><table style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; border-collapse: collapse; border-spacing: 0px;"><tbody style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><tr style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; border-top-style: none; border-bottom-style: none; border-left-style: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; line-height: 1.45em; color: #93a1a1; overflow: auto; text-align: right; padding: 0.8em !important; border-right-width: 1px !important; border-right-style: solid !important; border-right-color: #00232c !important; background-image: url(http://atnan.com/images/noise.png?1330576444) !important; background-color: #073642 !important;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">1</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">2</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">3</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">4</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">5</span> </pre></td><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle; width: 900px;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; background-image: none; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em; line-height: 1.45em; color: #93a1a1; overflow: auto;"><code style="margin: 0px; border: 0px; font: inherit; vertical-align: baseline; overflow-y: hidden; display: block; overflow-x: auto; line-height: 1.45em; background-color: #000000; padding: 0.8em !important; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace !important;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">-</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">BOOL</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #859900 !important;">application:</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">UIApplicati<wbr>on</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">*</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">application</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #859900 !important;">didFinishLaunchingWithOptions:</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><wbr>(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">NSDictionary</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">*</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">launchOptions</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">{</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">  <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #586e75 !important;">// ...Snipped...</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">  <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">[</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">NSClassFromString</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">(</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">@"WebView"</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">)</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">_enableRemoteInspector</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">];</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">  <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #586e75 !important;">// ...Snipped...</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">}</span> </span></code></pre></td></tr></tbody></table></div><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">The Surfin&#8217; Safari article said the remote debugger runs on port&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">9222</code>, but connecting to&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;"><a href="http://localhost:9222/" target="_blank" style="color: #1155cc;">http://localhost:9222</a></code>&nbsp;while the app was running in the simulator didn&#8217;t seem to work.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Using&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">lsof</code>&nbsp;showed that&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">UIWebViewWebGL.app</code>&nbsp;was actually listening on port&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">9999</code>:</p><pre style="white-space: pre-wrap;"><code style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace;">$ sudo lsof -i TCP -a -p $(pidof UIWebViewWebGL) -P COMMAND    PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME UIWebView 3748 nathan    9u  IPv6 0xffffff800fa25d80      0t0  TCP localhost:9999 (LISTEN) UIWebView 3748 nathan   13u  IPv6 0xffffff80111ba340      0t0  TCP localhost:9999-&gt;localhost:<wbr>52483 (ESTABLISHED) </code></pre><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Now when I pointed my browser at&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;"><a href="http://localhost:9999/" target="_blank" style="color: #1155cc;">http://localhost:9999</a></code>, it worked!</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><img src="http://atnan.com/downloads/WebKit_Remote_Debugger.png" style="margin: 0px auto 1.5em; padding: 0px; border: 0.5em solid white; font-size: 18px; font: inherit; vertical-align: baseline; max-width: 100%; min-height: auto; border-top-left-radius: 0.3em; border-top-right-radius: 0.3em; border-bottom-right-radius: 0.3em; border-bottom-left-radius: 0.3em; display: block;"  alt="" /></p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Logging&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">document.location.href</code><wbr>&nbsp;in the web inspector console shows I&#8217;m successfully inspecting the web content from&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">UIWebViewWebGL.app</code>&nbsp;<wbr>running in the iPhone Simulator.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Huzzah!</p><h2>Enabling remote debugging in Mobile Safari</h2><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Enabling the web inspector in an embedded&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">UIWebView</code>&nbsp;is handy, but what about content running in Mobile Safari?</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">To do that, we need to call the&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">+[WebView _enableRemoteInspector]</code>&nbsp;API from within the Mobile Safari app. The easiest way to do that is by launching Mobile Safari in the iPhone Simulator, and then use&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">gdb</code>&nbsp;to attach to it and call the private API.</p><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline;">Script to enable the remote inspector in Mobile Safari</span><div style="margin: 0px; font-size: 18px; font: inherit; vertical-align: baseline; background-color: #002b36; overflow-y: hidden; overflow-x: auto; border: 1px solid #05232b !important;"><table style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline; border-collapse: collapse; border-spacing: 0px;"><tbody style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><tr style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; border-top-style: none; border-bottom-style: none; border-left-style: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; line-height: 1.45em; color: #93a1a1; overflow: auto; text-align: right; padding: 0.8em !important; border-right-width: 1px !important; border-right-style: solid !important; border-right-color: #00232c !important; background-image: url(http://atnan.com/images/noise.png?1330576444) !important; background-color: #073642 !important;"><span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">1</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">2</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">3</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">4</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">5</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">6</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">7</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">8</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">9</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">10</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">11</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">12</span> <span style="margin: 0px; padding: 0px; border: 0px; font-size: 13px; font: inherit; vertical-align: baseline; color: #586e75 !important;">13</span> </pre></td><td style="font-family: arial, sans-serif; margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: middle; width: 750px;"><pre style="white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: none; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; background-image: none; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em; line-height: 1.45em; color: #93a1a1; overflow: auto;"><code style="margin: 0px; border: 0px; font: inherit; vertical-align: baseline; overflow-y: hidden; display: block; overflow-x: auto; line-height: 1.45em; background-color: #000000; padding: 0.8em !important; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace !important;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #268bd2 !important;">MobileSafari_PID</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">=</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">$(</span>ps x | grep <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">"MobileSafari"</span> | grep -v grep | awk <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">'{ print $1 }'</span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">)</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">if</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">[</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">"$MobileSafari_PID"</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">==</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">""</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; font-weight: bold !important;">]</span>; <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">then</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #859900 !important;">echo</span> <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">"Mobile Safari.app must be running in the Simulator to enable the remote inspector."</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">else</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;">  </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"> cat <span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">&lt;&lt;EOM | gdb -quiet &gt; /dev/null</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">  attach $MobileSafari_PID</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">  p (void *)[WebView _enableRemoteInspector]</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">  detach</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #2aa198 !important;">EOM</span> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"> </span><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font: inherit; vertical-align: baseline; color: #cb4b16 !important;">fi</span> </span></code></pre></td></tr></tbody></table></div><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Browsing to&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;"><a href="http://localhost:9999/" target="_blank" style="color: #1155cc;">http://localhost:9999</a></code>&nbsp;will show an index page listing the URL of each tab open in Mobile Safari. This allows you to have a remote inspector open for each tab in Mobile Safari.</p><h2>Summing Up</h2><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">I haven&#8217;t used the remote inspector in anger yet, but so far it&#8217;s been incredibly useful.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">Note that you can&#8217;t use&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">gdb</code>&nbsp;to inject code on a device, so enabling remote debugging in Mobile Safari is limited to the Simulator. Hopefully Apple will provide the option to enable it, much like the debug console in&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">Settings &#8594; Safari &#8594; Advanced &#8594; Debug Console</code>.</p><p style="margin: 0px 0px 1.5em; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;"><strike style="margin: 0px; padding: 0px; border: 0px; font-size: 18px; font: inherit; vertical-align: baseline;">In the meantime, you can load your web content in an embedded UIWebView.</strike>&nbsp;Enabling the remote inspector on a&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">UIWebView</code>&nbsp;in an app running on the device doesn&#8217;t seem to work. Using&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">nmap</code>shows that my iPhone only has port&nbsp;<code style="padding: 0px 0.3em; border: 1px solid #dddddd; font-size: 0.8em; font: inherit; vertical-align: baseline; font-family: Menlo, Monaco, 'Andale Mono', 'lucida console', 'Courier New', monospace; display: inline-block; background-color: #ffffff; line-height: 1.5em; color: #555555; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em;">62078</code>&nbsp;open for OTA syncing, so it&#8217;s likely there&#8217;s a firewall preventing connections to the remote inspector port.</p></div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196767.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:51 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196767.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：自定义UITableViewCell的旋转问题</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196766.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:49:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196766.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196766.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196766.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196766.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196766.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.08.20</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">自定义UITableViewCell的旋转时，无法旋转。<wbr>解决办法有3种：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">第一种：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">1）<wbr>在didRotateFromInterfaceOrienta<wbr>tion中，调用reloadData</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">2）准备2个xib文件，一个是横屏，一个是竖屏。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">3) &nbsp;在cellForRowAtIndexPath中，<wbr>根据不同的方向，选择不同的xib。注意，<wbr>不使用dequeueReusableCellWithIden<wbr>tifier，而是每次都创建新的cell。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">第二种：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">1）<wbr>在didRotateFromInterfaceOrienta<wbr>tion中，调用reloadData</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">2）在cellForRowAtIndexPath中，<wbr>根据不同的方向，改变frame的值。注意：<wbr>不需要改变cell的值，<wbr>只需要改变cell里面的view的值。例如：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><p>&nbsp; &nbsp;&nbsp;UIView&nbsp;*contentView = [cell.subviews&nbsp;objectAtIndex:0]; &nbsp; &nbsp;</p><p>&nbsp; &nbsp;&nbsp;if&nbsp;(UIDeviceOrientationIsLandscap<wbr>e([UIApplication&nbsp;sharedApplication].statusBarOr<wbr>ientation))</p><p>&nbsp; &nbsp; {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; contentView.frame&nbsp;=&nbsp;CGRectMake(0,&nbsp;0,&nbsp;480, cell.frame.size.height);</p><p>&nbsp; &nbsp; }</p><p>&nbsp; &nbsp;&nbsp;else&nbsp;{</p><p>&nbsp; &nbsp; &nbsp; &nbsp; contentView.frame&nbsp;=&nbsp;CGRectMake(0,&nbsp;0,&nbsp;320, cell.frame.size.height); &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; }&nbsp;</p><p><br /></p><p>第三种：</p><p>不使用自定义的cell，而是使用普通的cell，<wbr>然后使用contentView来进行配置。</p><p>注意：这种方法我没有试验过，不知道是否可以，只是猜测而已。<wbr>因为普通的cell的旋转是没有问题的。</p><p><br /></p><p><br /></p></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196766.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:49 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196766.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：关于Custom Container View Controller -2012.08.23</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196765.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:49:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196765.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196765.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196765.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196765.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196765.html</trackback:ping><description><![CDATA[<div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：2012.08.22</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：2012.08.23</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div></div><div>参考：</div>WON'T SOMEBODY PLEASE THINK OF THE CHILDREN?!?<div><a href="http://blog.devnos.com/wont-somebody-please-think-of-the-children" target="_blank" style="color: #1155cc;">http://blog.devnos.com/wont-<wbr>somebody-please-think-of-the-<wbr>children</a></div><div></div><div>Containing ViewControllers</div><div><a href="http://www.cocoanetics.com/2012/04/containing-viewcontrollers/" target="_blank" style="color: #1155cc;">http://www.cocoanetics.com/<wbr>2012/04/containing-<wbr>viewcontrollers/</a></div><br /><div></div><div>iOS5加入了几个函数用于自定义ContainerVC。</div><div>原来的ContainerVC没有办法接受到旋转，<wbr>内存不足等消息。</div><div></div><div>＊加入子VC的方法：</div><div><div>[self addChildViewController:self.<wbr>childVC];</div><div>[self.view addSubview:self.childVC.view];</div><div>[self.childVC didMoveToParentViewController:<wbr>self];</div><div></div></div><div></div><div>注意：</div><div>1）<wbr>要手动调用didMoveToParentViewContro<wbr>ller: 这是SDK说的。</div><div>2）要手动调用addSubview:</div><div></div><div>＊去掉子VC的方法：</div><div><div>[self.childVC willMoveToParentViewController<wbr>:nil];&nbsp;</div><div>[self.childVC.view removeFromSuperview];</div><div>[self.childVC removeFromParentViewController<wbr>];</div></div><div></div><div>注意：</div><div>1）<wbr>要手动调用willMoveToParentViewContr<wbr>oller:nil&nbsp;这是SDK说的。</div><div>2）要手动调用removeFromSuperview。</div><div>3）有人说，<wbr>不要在子VC中调用removeFromParentViewC<wbr>ontroller，否则会出现异常行为，我没测试过。</div><div></div><div></div><div>＊切换子VC</div>transitionFromViewController:<wbr>toViewController:duration:<wbr>options:animations:completion:<div></div><div>子VC可以并存于父VC中，可以只存在一个，<wbr>这个和普通的子VC没有什么差别。</div><div>唯一要注意的是：<wbr>transitionFromViewController:<wbr>toViewController:duration:<wbr>options:animations:<wbr>completion函数会自动删掉上一个子VC的view，<wbr>并加入新的子VC的view而已。－－这是我猜测</div><div>另外，这个函数我没有用过，看看其他人的建议吧：</div><div><ol><li style="margin-left: 15px;">You can only transition to views that have been explicitly added / contained using AddChildViewController</li><li style="margin-left: 15px;">UIVIewAnimationOptions have some new additions, check them out!</li><li style="margin-left: 15px;">The "animations" and "completionHandler" parameters are both delegates. This means all your pre-animation targets and post-animation events all accessible within one expression, cool stuff!</li><li style="margin-left: 15px;">As with most things, make sure to call base.Transition(..) [super transisionFromViewController:.<wbr>.] if you override this, or you'll get weird behavior.</li></ol></div><div></div><div></div><div></div><div>＋＋＋＋＋</div></div><img src ="http://www.cppblog.com/walkklookk/aggbug/196765.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:49 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196765.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>原：viewDidLoad中的初始化过程 -120823</title><link>http://www.cppblog.com/walkklookk/archive/2012/12/29/196764.html</link><dc:creator>佳为好友</dc:creator><author>佳为好友</author><pubDate>Sat, 29 Dec 2012 02:48:00 GMT</pubDate><guid>http://www.cppblog.com/walkklookk/archive/2012/12/29/196764.html</guid><wfw:comment>http://www.cppblog.com/walkklookk/comments/196764.html</wfw:comment><comments>http://www.cppblog.com/walkklookk/archive/2012/12/29/196764.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/walkklookk/comments/commentRss/196764.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/walkklookk/services/trackbacks/196764.html</trackback:ping><description><![CDATA[<span style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">创建：120628</span><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：120628</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">修改：120823</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"><div>- (void)viewDidLoad</div><div>{</div><div>&nbsp; &nbsp; [super viewDidLoad];</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; if (!self.isNotFirstRun) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;[self configureDataAsDefault];</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp;</div><div>&nbsp; &nbsp; [self configureUIComponentsAsDefault<wbr>];</div><div></div><div>&nbsp; &nbsp; [self restoreUIComponents];</div><div><p>&nbsp;</p><div>&nbsp; &nbsp; if (!self.isNotFirstRun) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;[self&nbsp;<wbr>startLoadingDataIfNeed];</div><div>&nbsp; &nbsp; }</div><p>&nbsp;</p><p>&nbsp; &nbsp;&nbsp;self.isNotFirstRun = YES;</p></div><div>}</div></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">***</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">&nbsp;[self configureDataAsDefault];</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">用于创建一些只创建一次的数据。它们不会被释放。<wbr>通常要使用isNotFirstRun来保证只创建一次。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">它相当于在VC的init中进行的操作。但是，<wbr>由于VC的init不能保证在xib的情况下，也被调用，<wbr>而且还需要重写2个或更多的init函数，因此显得不方便，<wbr>因此，才使用isNotFirstRun的方式来实现。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">***</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">[self configureUIComponentsAsDefault<wbr>];</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">用于创建和配置一些UI组件，<wbr>它们的属性在程序运行期间是固定的值，<wbr>不会因为用户的任何操作而被改变。它们是对XIB配置的补充。<wbr>它们可能会因为内存不足而被释放，需要重新创建。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">***</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">[self restoreUIComponents];</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">用于恢复那些因为内存不足和释放的UI组件，<wbr>它们的属性会根据用户的选择而变化。因此，程序的Data中，<wbr>通常有保存它们即时状态的Data。例如，<wbr>用户当前选中的segement的index，<wbr>或者ScrollView当前的位置，等等。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">它是跟ViewDidUnload执行相反的操作的。<wbr>通常使用另外的一组变量来记录View在内存不足释放前的状态。<wbr>例如：</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">currentSelectedIndex_restore;</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">currentRangeTimeTag_restore;</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;"></div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">***</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">[self&nbsp;startLoadingDataIfNeed];</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">如果ViewController在第一次进入的时候，<wbr>需要Loading一些数据以更新页面，<wbr>则在此函数中才开始发出Loading数据的请求。<wbr>之所以放在最后，是避免Loading数据过快，<wbr>导致UI还没有构建成功。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">另外，如果VC是从内存不足中恢复过来的，<wbr>则可能不需要重新Load数据。因此，<wbr>此函数还需要检查是否是第一次进入VC。</div><div style="color: #222222; font-family: arial, sans-serif; font-size: 14.399999618530273px; line-height: normal; background-color: #ffffff;">＋＋＋＋＋</div><img src ="http://www.cppblog.com/walkklookk/aggbug/196764.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/walkklookk/" target="_blank">佳为好友</a> 2012-12-29 10:48 <a href="http://www.cppblog.com/walkklookk/archive/2012/12/29/196764.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>