??xml version="1.0" encoding="utf-8" standalone="yes"?>尹人香蕉久久99天天拍,国产日韩久久免费影院,久久精品人人做人人爽电影http://m.shnenglu.com/wanghaiguang/category/20888.html逆水行舟Q不q则退zh-cnThu, 05 Mar 2015 08:52:36 GMTThu, 05 Mar 2015 08:52:36 GMT60UISearchBar控gQ{载)http://m.shnenglu.com/wanghaiguang/archive/2015/03/04/209924.html王v?/dc:creator>王v?/author>Wed, 04 Mar 2015 11:23:00 GMThttp://m.shnenglu.com/wanghaiguang/archive/2015/03/04/209924.htmlhttp://m.shnenglu.com/wanghaiguang/comments/209924.htmlhttp://m.shnenglu.com/wanghaiguang/archive/2015/03/04/209924.html#Feedback0http://m.shnenglu.com/wanghaiguang/comments/commentRss/209924.htmlhttp://m.shnenglu.com/wanghaiguang/services/trackbacks/209924.html阅读全文

]]>
iOS 解决NSString转换为NSURL时包含中文字W?/title><link>http://m.shnenglu.com/wanghaiguang/archive/2014/08/18/208048.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Mon, 18 Aug 2014 01:45:00 GMT</pubDate><guid>http://m.shnenglu.com/wanghaiguang/archive/2014/08/18/208048.html</guid><wfw:comment>http://m.shnenglu.com/wanghaiguang/comments/208048.html</wfw:comment><comments>http://m.shnenglu.com/wanghaiguang/archive/2014/08/18/208048.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/wanghaiguang/comments/commentRss/208048.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/wanghaiguang/services/trackbacks/208048.html</trackback:ping><description><![CDATA[<span style="color: #362e2b; font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 14pt;">NSString中如果包括中文字W,在{换ؓNSURL时得到的gؓnil<br /><br /></span><div><span style="color: #362e2b; font-family: Verdana; line-height: 26px; background-color: #ffffff; font-size: 14pt;">解决办法Q?/span></div> <div> <div style="background-color: #eeeeee; font-size: 13px; border-left-color: #cccccc; padding: 4px 5px 4px 4px; width: 98%; word-break: break-all;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="font-family: Verdana; font-size: 14pt;">NSString *urlString = [NSString stringWithFormat:@"http://api.openweathermap.org/data/2.5/weather?q=%@&units=imperial",cityName];</span><br /> <span style="color: red; font-family: Verdana; font-size: 14pt;">urlString </span><span style="color: red; font-family: Verdana; font-size: 14pt;">=</span><span style="color: red; font-family: Verdana; font-size: 14pt;"> [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];</span><br /><span style="font-family: Verdana; font-size: 14pt;"> NSURL *url = [NSURL URLWithString:urlString];</span><br /><span style="font-family: Verdana; font-size: 14pt;"> NSLog(@"%@", url);</span></div> </div><img src ="http://m.shnenglu.com/wanghaiguang/aggbug/208048.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2014-08-18 09:45 <a href="http://m.shnenglu.com/wanghaiguang/archive/2014/08/18/208048.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>iOS 监听 Home键(转蝲Q?/title><link>http://m.shnenglu.com/wanghaiguang/archive/2014/08/01/207884.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Fri, 01 Aug 2014 05:31:00 GMT</pubDate><guid>http://m.shnenglu.com/wanghaiguang/archive/2014/08/01/207884.html</guid><wfw:comment>http://m.shnenglu.com/wanghaiguang/comments/207884.html</wfw:comment><comments>http://m.shnenglu.com/wanghaiguang/archive/2014/08/01/207884.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/wanghaiguang/comments/commentRss/207884.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/wanghaiguang/services/trackbacks/207884.html</trackback:ping><description><![CDATA[<span style="background-color: #ececec; color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; font-size: 14px; line-height: 25px;">W一?</span><br /> <span style="color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; background-color: #ececec;">创徏2个NSNotificationCenter监听</span><br style="line-height: 25px; color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #ececec;" /> <pre class="prettyprint" name="code" style="white-space: pre-wrap; word-wrap: break-word; line-height: 25px; padding: 2px; border: 1px solid #888888; color: #626262; background-color: #ececec;"><span id="ouuwmcu" class="pun" style="color: #666600;">[[</span><span id="gmuswqk" class="typ" style="color: #660066;">NSNotificationCenter</span><span id="imiwqkg" class="pln" style="color: #000000;"> defaultCenter</span><span id="kuoquiy" class="pun" style="color: #666600;">]</span><span id="kwoscky" class="pln" style="color: #000000;"> addObserver</span><span id="ueyswca" class="pun" style="color: #666600;">:</span><span id="myqcemk" class="kwd" style="color: #000088;">self</span><span id="kseqayy" class="pln" style="color: #000000;"> selector</span><span id="iaesyem" class="pun" style="color: #666600;">:</span><span id="acmwqow" class="lit" style="color: #006666;">@selector</span><span id="ikmiaao" class="pun" style="color: #666600;">(</span><span id="seoiaiy" class="pln" style="color: #000000;">applicationWillResignActive</span><span id="kceauay" class="pun" style="color: #666600;">:)</span> <span id="umisems" class="pln" style="color: #000000;">name</span><span id="wikmowe" class="pun" style="color: #666600;">:</span><span id="skwiaaq" class="typ" style="color: #660066;">UIApplicationWillResignActiveNotification</span><span id="kkoiaag" class="pln" style="color: #000000;"> </span><span id="wakwgwc" class="kwd" style="color: #000088;">object</span><span id="uwqcusq" class="pun" style="color: #666600;">:</span><span id="aumgqqg" class="kwd" style="color: #000088;">nil</span><span id="iakoggm" class="pun" style="color: #666600;">];</span><span id="smwicag" class="pln" style="color: #000000;"> </span><span id="iicgige" class="com" style="color: #880000;">//监听是否触发home键挂L?</span> <span id="acwakqy" class="pln" style="color: #000000;"> </span> <span id="macuyec" class="pun" style="color: #666600;">[[</span><span id="wyicwus" class="typ" style="color: #660066;">NSNotificationCenter</span><span id="agcwiww" class="pln" style="color: #000000;"> defaultCenter</span><span id="ewysuks" class="pun" style="color: #666600;">]</span><span id="qsewqom" class="pln" style="color: #000000;"> addObserver</span><span id="aaegqgw" class="pun" style="color: #666600;">:</span><span id="oiuwaye" class="kwd" style="color: #000088;">self</span><span id="iugqaiq" class="pln" style="color: #000000;"> selector</span><span id="ikoqmka" class="pun" style="color: #666600;">:</span><span id="wacegec" class="lit" style="color: #006666;">@selector</span><span id="suoisqq" class="pun" style="color: #666600;">(</span><span id="amwqkaa" class="pln" style="color: #000000;">applicationDidBecomeActive</span><span id="mqaewmk" class="pun" style="color: #666600;">:)</span> <span id="ismwiyu" class="pln" style="color: #000000;">name</span><span id="acwgiiw" class="pun" style="color: #666600;">:</span><span id="yaseqec" class="typ" style="color: #660066;">UIApplicationDidBecomeActiveNotification</span><span id="skwgsag" class="pln" style="color: #000000;"> </span><span id="muyqssi" class="kwd" style="color: #000088;">object</span><span id="koyakaq" class="pun" style="color: #666600;">:</span><span id="egykmci" class="kwd" style="color: #000088;">nil</span><span id="oykeyec" class="pun" style="color: #666600;">];</span><span id="gakegeu" class="pln" style="color: #000000;"> </span><span id="gskoggw" class="com" style="color: #880000;">//监听是否重新q入E序E序.</span> <p style="margin: 0px 0px 10px; padding: 0px;"> </p> </pre> <br style="line-height: 25px; color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #ececec;" /> <span style="color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; background-color: #ececec;">W二?</span><br style="line-height: 25px; color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #ececec;" /> <span style="color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; background-color: #ececec;">实现2个NSNotificationCenter所触发的事件方?/span><br style="line-height: 25px; color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #ececec;" /> <pre class="prettyprint" name="code" style="white-space: pre-wrap; word-wrap: break-word; line-height: 25px; padding: 2px; border: 1px solid #888888; color: #626262; background-color: #ececec;"><span id="wosmock" class="pun" style="color: #666600;">-</span><span id="uwoauiy" class="pln" style="color: #000000;"> </span><span id="eyakwuc" class="pun" style="color: #666600;">(</span><span id="ceqakai" class="kwd" style="color: #000088;">void</span><span id="uugicqo" class="pun" style="color: #666600;">)</span><span id="umqiksa" class="pln" style="color: #000000;">applicationWillResignActive</span><span id="ewqueus" class="pun" style="color: #666600;">:(</span><span id="iiugagg" class="typ" style="color: #660066;">NSNotification</span><span id="uoismki" class="pln" style="color: #000000;"> </span><span id="iscwqmk" class="pun" style="color: #666600;">*)</span><span id="ysueygw" class="pln" style="color: #000000;">notification</span> <span id="yaceqou" class="pun" style="color: #666600;">{</span> <span id="qismqge" class="pln" style="color: #000000;"> printf</span><span id="ysuysyw" class="pun" style="color: #666600;">(</span><span id="ameqksg" class="str" style="color: #008800;">"按理说是触发home按下\n"</span><span id="ggkmwws" class="pun" style="color: #666600;">);</span> <span id="uokwymk" class="pun" style="color: #666600;">}</span> <span id="iewauka" class="pun" style="color: #666600;">-</span><span id="gikmyww" class="pln" style="color: #000000;"> </span><span id="oyskmua" class="pun" style="color: #666600;">(</span><span id="kuwgage" class="kwd" style="color: #000088;">void</span><span id="kegqcao" class="pun" style="color: #666600;">)</span><span id="amwgsig" class="pln" style="color: #000000;">applicationDidBecomeActive</span><span id="ewyiecq" class="pun" style="color: #666600;">:(</span><span id="wicegow" class="typ" style="color: #660066;">NSNotification</span><span id="wgkeywc" class="pln" style="color: #000000;"> </span><span id="cwgsuay" class="pun" style="color: #666600;">*)</span><span id="gqumqwe" class="pln" style="color: #000000;">notification</span> <span id="smgickg" class="pun" style="color: #666600;">{</span> <span id="iwakmua" class="pln" style="color: #000000;"> printf</span><span id="uoyceci" class="pun" style="color: #666600;">(</span><span id="yacegmu" class="str" style="color: #008800;">"按理说是重新q来后响应\n"</span><span id="woqsmcc" class="pun" style="color: #666600;">);</span> <span id="akogkyy" class="pun" style="color: #666600;">}</span> <p style="margin: 0px 0px 10px; padding: 0px;"> </p> </pre> <br style="line-height: 25px; color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #ececec;" /> <span style="color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; background-color: #ececec;">? 在home键触发后,AppDelegate响应的方法ؓ:</span><br style="line-height: 25px; color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: #ececec;" /> <pre class="prettyprint" name="code" style="white-space: pre-wrap; word-wrap: break-word; line-height: 25px; padding: 2px; border: 1px solid #888888; color: #626262; background-color: #ececec;"><p style="margin: 0px 0px 10px; padding: 0px;"><span id="qsuoyym" class="pun" style="color: #666600;">-</span><span id="woieywk" class="pln" style="color: #000000;"> </span><span id="icmoqqw" class="pun" style="color: #666600;">(</span><span id="wgicmmk" class="kwd" style="color: #000088;">void</span><span id="ckoaeca" class="pun" style="color: #666600;">)</span><span id="wioukiy" class="pln" style="color: #000000;">applicationDidEnterBackground</span><span id="wsuwgwm" class="pun" style="color: #666600;">:(</span><span id="uuoquay" class="typ" style="color: #660066;">UIApplication</span><span id="iueqiig" class="pln" style="color: #000000;"> </span><span id="ysmwygo" class="pun" style="color: #666600;">*)</span><span id="gcwqkgg" class="pln" style="color: #000000;">application</span> <span id="akcegec" class="pun" style="color: #666600;">{</span> <span id="yakeoms" class="pln" style="color: #000000;"> </span><span id="mwamouk" class="com" style="color: #880000;">/*</span> <span id="eqkmwum" class="com" style="color: #880000;"> Use this method to release shared resources, save user data, invalidate timers, </span> </p> <p style="margin: 0px 0px 10px; padding: 0px;"><span id="umwqkig" class="com" style="color: #880000;"> and store enough application state information to restore your application to its current state in case it is terminated later.</span> <span id="ceqamig" class="com" style="color: #880000;"> If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.</span> <span id="moqimky" class="com" style="color: #880000;"> */</span> <span id="cewasqo" class="pun" style="color: #666600;">}</span></p> </pre> <span style="color: #626262; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; background-color: #ececec;">本文转自Q?/span>http://blog.csdn.net/sqc3375177/article/details/9466687 <div><br /> </div> <div>其他相关信息Q?/div> <div> <div style="line-height: 25px; color: #323e32; background-color: #ffffff; font-family: Monaco, 'DejaVu sans Mono', 'Bitstream Vera sans Mono', Consolas, 'Courier new', monospace; font-size: 12px; width: 679px; overflow: auto; margin-left: 9px; padding: 1px; word-break: break-all; word-wrap: break-word;"> <ol start="1" style="line-height: 1.4em; margin: 0px 0px 1px; padding: 2px 0px; border: 1px solid #d1d7dc; list-style: none; font-size: 1em; color: #2b91af;"> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">- <wbr style="line-height: 21px;">(BOOL)application:(UIApplication <wbr style="line-height: 21px;">*)application <wbr style="line-height: 21px;">didFinishLaunchingWithOp<wbr style="line-height: 21px;">tions:(NSDictionary <wbr style="line-height: 21px;">*)launchOptions <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">{ <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"><span style="word-wrap: normal; word-break: normal; color: #008200;">// <wbr style="line-height: 21px;">Override <wbr style="line-height: 21px;">point <wbr style="line-height: 21px;">for <wbr style="line-height: 21px;">customization <wbr style="line-height: 21px;">after <wbr style="line-height: 21px;">application <wbr style="line-height: 21px;">launch.</span> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;">NSLog(@<span style="word-wrap: normal; word-break: normal; color: blue;">"\n <wbr style="line-height: 21px;">===> <wbr style="line-height: 21px;">E序开?nbsp;<wbr style="line-height: 21px;">!"</span>); <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"><span style="word-wrap: normal; word-break: normal; color: #7f0055; font-weight: bold;">return</span> <wbr style="line-height: 21px;">YES; <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">} <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">- <wbr style="line-height: 21px;">(<span style="word-wrap: normal; word-break: normal; color: #7f0055; font-weight: bold;">void</span>)applicationWillResignAct<wbr style="line-height: 21px;">ive:(UIApplication <wbr style="line-height: 21px;">*)application <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">{ <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;">NSLog(@<span style="word-wrap: normal; word-break: normal; color: blue;">"\n <wbr style="line-height: 21px;">===> <wbr style="line-height: 21px;">E序暂行 <wbr style="line-height: 21px;">!"</span>); <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">} <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">- <wbr style="line-height: 21px;">(<span style="word-wrap: normal; word-break: normal; color: #7f0055; font-weight: bold;">void</span>)applicationDidEnterBackg<wbr style="line-height: 21px;">round:(UIApplication <wbr style="line-height: 21px;">*)application <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">{ <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;">NSLog(@<span style="word-wrap: normal; word-break: normal; color: blue;">"\n <wbr style="line-height: 21px;">===> <wbr style="line-height: 21px;">E序q入后台 <wbr style="line-height: 21px;">!"</span>); <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">} <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">- <wbr style="line-height: 21px;">(<span style="word-wrap: normal; word-break: normal; color: #7f0055; font-weight: bold;">void</span>)applicationWillEnterFore<wbr style="line-height: 21px;">ground:(UIApplication <wbr style="line-height: 21px;">*)application <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">{ <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;">NSLog(@<span style="word-wrap: normal; word-break: normal; color: blue;">"\n <wbr style="line-height: 21px;">===> <wbr style="line-height: 21px;">E序q入前台 <wbr style="line-height: 21px;">!"</span>); <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">} <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">- <wbr style="line-height: 21px;">(<span style="word-wrap: normal; word-break: normal; color: #7f0055; font-weight: bold;">void</span>)applicationDidBecomeActi<wbr style="line-height: 21px;">ve:(UIApplication <wbr style="line-height: 21px;">*)application <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">{ <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;">NSLog(@<span style="word-wrap: normal; word-break: normal; color: blue;">"\n <wbr style="line-height: 21px;">===> <wbr style="line-height: 21px;">E序重新Ȁz?nbsp;<wbr style="line-height: 21px;">!"</span>); <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">} <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">- <wbr style="line-height: 21px;">(<span style="word-wrap: normal; word-break: normal; color: #7f0055; font-weight: bold;">void</span>)applicationWillTerminate<wbr style="line-height: 21px;">:(UIApplication <wbr style="line-height: 21px;">*)application <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">{ <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;">NSLog(@<span style="word-wrap: normal; word-break: normal; color: blue;">"\n <wbr style="line-height: 21px;">===> <wbr style="line-height: 21px;">E序意外暂行 <wbr style="line-height: 21px;">!"</span>); <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;">UIDevice <wbr style="line-height: 21px;">*device <wbr style="line-height: 21px;">= <wbr style="line-height: 21px;">[UIDevice <wbr style="line-height: 21px;">currentDevice]; <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> <li style="line-height: 18px; margin: 0px 0px 0px 38px; padding: 0px 0px 0px 10px; border-width: 0px 0px 0px 1px; list-style: decimal; font-size: 1em; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa;"><span style="word-wrap: normal; word-break: normal; color: black;">} <wbr style="line-height: 21px;"> <wbr style="line-height: 21px;"></span></li> </ol> </div> <span style="line-height: 25px; color: #323e32; font-size: 16px; background-color: #ffffff; word-wrap: normal; word-break: normal; font-family: Helvetica, Tahoma, Arial, sans-serif;"> <wbr style="line-height: 28px;"></span> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; color: #ff0000;">首次q行</span>Q?/p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOp<wbr style="line-height: 28px;">tions:(NSDictionary *)launchOptions</p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;">- (void)applicationDidBecomeActi<wbr style="line-height: 28px;">ve:(UIApplication *)application</p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;"> <wbr style="line-height: 28px;"></p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; color: #ff0000;">首次关闭QhomeQ:</span></p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;">- (void)applicationWillResignAct<wbr style="line-height: 28px;">ive:(UIApplication *)application</p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;">- (void)applicationDidEnterBackg<wbr style="line-height: 28px;">round:(UIApplication *)application</p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;"> <wbr style="line-height: 28px;"></p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; color: #ff0000;">再次q行Q?/span></p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;">- (void)applicationWillEnterFore<wbr style="line-height: 28px;">ground:(UIApplication *)application</p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;">- (void)applicationDidBecomeActi<wbr style="line-height: 28px;">ve:(UIApplication *)application</p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;"> <wbr style="line-height: 28px;"></p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; color: #ff0000;">再次关闭Q?/span></p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;">- (void)applicationWillResignAct<wbr style="line-height: 28px;">ive:(UIApplication *)application</p> <p style="margin: 0px; padding: 0px; color: #323e32; font-family: simsun; font-size: 16px; background-color: #ffffff; border: 0px; list-style: none; word-wrap: normal; word-break: normal;">- (void)applicationDidEnterBackg<wbr style="line-height: 28px;">round:(UIApplication *)application</p> </div> <div><br /> </div> <div>本文转自Qhttp://friendlysong.blog.163.com/blog/static/3225243920128144251666/</div><img src ="http://m.shnenglu.com/wanghaiguang/aggbug/207884.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2014-08-01 13:31 <a href="http://m.shnenglu.com/wanghaiguang/archive/2014/08/01/207884.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UIGestureRecognizer学习W记Q{载)——手势识别功?/title><link>http://m.shnenglu.com/wanghaiguang/archive/2014/07/29/207854.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Tue, 29 Jul 2014 05:35:00 GMT</pubDate><guid>http://m.shnenglu.com/wanghaiguang/archive/2014/07/29/207854.html</guid><wfw:comment>http://m.shnenglu.com/wanghaiguang/comments/207854.html</wfw:comment><comments>http://m.shnenglu.com/wanghaiguang/archive/2014/07/29/207854.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/wanghaiguang/comments/commentRss/207854.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/wanghaiguang/services/trackbacks/207854.html</trackback:ping><description><![CDATA[     摘要: UIGestureRecognizer 是一个具体手势的基类Q提供了较ؓ单的手势实现方式  The concrete subclasses of UIGestureRecognizer are the following:UITapGestureRecognizerUIPinchGestureRecognizerUIRotationGestureRecog...  <a href='http://m.shnenglu.com/wanghaiguang/archive/2014/07/29/207854.html'>阅读全文</a><img src ="http://m.shnenglu.com/wanghaiguang/aggbug/207854.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2014-07-29 13:35 <a href="http://m.shnenglu.com/wanghaiguang/archive/2014/07/29/207854.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>iOS dlibxml2.dylb ? 找不?lt;libxml/tree.h> 头文?/title><link>http://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207651.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Tue, 15 Jul 2014 05:50:00 GMT</pubDate><guid>http://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207651.html</guid><wfw:comment>http://m.shnenglu.com/wanghaiguang/comments/207651.html</wfw:comment><comments>http://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207651.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/wanghaiguang/comments/commentRss/207651.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/wanghaiguang/services/trackbacks/207651.html</trackback:ping><description><![CDATA[<span style="font-size: 14pt; font-family: Verdana;">?/span><span style="color: #333333; font-family: Verdana; background-color: #ffffff; font-size: 14pt;">“Header Search Paths” 中添?/span><span style="color: #333333; font-family: Verdana; font-size: 14pt; background-color: #ffffff;">“/usr/include/libxml2″ <br /></span><span style="color: #333333; font-family: Verdana; font-size: 14pt; background-color: #ffffff;">?/span><span style="color: #333333; font-family: Verdana; background-color: #ffffff; font-size: 14pt;">“Other Linker Flags”d</span><span style="color: #333333; font-family: Verdana; font-size: 14pt; background-color: #ffffff;">“-lxml2″ <br /></span><span style="color: #333333; font-family: Verdana; font-size: 14pt; background-color: #ffffff;">q行后出现错误找不到</span><span style="font-size: 14pt; font-family: Verdana;"><libxml/tree.h><br /><br /></span><span style="font-size: 14pt; font-family: Verdana;"> 解决办法Q?/span><span style="font-size: 14pt; font-family: Verdana;">?/span><span style="color: #333333; font-family: Verdana; background-color: #ffffff; font-size: 14pt;">“Header Search Paths” 中添?/span><span style="background-color: #ffffff;"> </span><span style="color: red; font-family: Verdana; font-size: 14pt; background-color: #ffffff;">${SDKROOT}</span><span style="color: #333333; font-family: Verdana; font-size: 14pt; background-color: #ffffff;"><strong>/usr/include/libxml2</strong></span><img src ="http://m.shnenglu.com/wanghaiguang/aggbug/207651.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2014-07-15 13:50 <a href="http://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207651.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>iOS UIButtonW记http://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207650.html王v?/dc:creator>王v?/author>Tue, 15 Jul 2014 05:37:00 GMThttp://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207650.htmlhttp://m.shnenglu.com/wanghaiguang/comments/207650.htmlhttp://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207650.html#Feedback0http://m.shnenglu.com/wanghaiguang/comments/commentRss/207650.htmlhttp://m.shnenglu.com/wanghaiguang/services/trackbacks/207650.html创徏两种ҎQ?/span>
Q?Q常规的initWithFrame的方?nbsp;
UIButton *btn1 = [[UIButton alloc]initWithFrame:CGRectMake(100, 50, 100, 75)];

[btn1 setTitle:@"close" forState:UIControlStateNormal];
btn1.backgroundColor = [UIColor greenColor];//button的背景颜?/span>
[btn1 setBackgroundImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal];//button的背景图?/span>

Q?QUIButton 的一个类ҎQ也可以说是静态方法)buttonWithType 
UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn2.frame = CGRectMake(200, 20, 50, 60);
btn2.backgroundColor = [UIColor blackColor];
[btn2 setTitle:@"clicke" forState:UIControlStateNormal];
[self.window addSubview:btn1];
[self.window addSubview:btn2];
 
能够定义的buttoncd?U?/span>
typedef enum 

    UIButtonTypeCustom = 0,         // 自定义,无风?nbsp;
    UIButtonTypeRoundedRect,      // 白色圆角矩ŞQ类似偏好设|表格单元或者地址卡?nbsp;
    UIButtonTypeDetailDisclosure, // 蓝色的披露按钮,可放在Q何文字旁 
    UIButtonTypeInfoLight,            // 微g(widget)使用的小圆圈信息按钮Q可以放在Q何文字旁 
    UIButtonTypeInfoDark,            // 白色背景下用的p圆圈信息按钮 
    UIButtonTypeContactAdd,       // 蓝色加号(+)按钮Q可以放在Q何文字旁 
} UIButtonType; 
 
[btn1 setTitle:@"BTN1" forState:UIControlStateNormal];                                                                   //讄按钮的标?br /> 
[btn1 setTitle:@"高亮状? forState:UIControlStateHighlighted];                                                        //高亮状态按钮title?br />
[btn2 setImage:[UIImage imageNamed:@"pic"] forState:UIControlStateNormal];                             //你也可以为按钮的某一状态设|ؓ?nbsp;

[btn1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];                                            //讄标题颜色 

[btn1 setTitleShadowColor:[UIColor grayColor] forState:UIControlStateNormal ];                             //阴媄 

[btn1 setBackgroundImage:[UIImage imageNamed:@"PIC"] forState:UIControlStateHighlighted];  //背景囑փ 

btn1.titleLabel.font = [UIFont fontWithNameQ@“test” size:18];                                                       //讄按钮字体大小

[btn1 setTag:101] ;                                                                                                                            //讄tag?/span>

btn1.layer.cornerRadius = 4.5;                                                                                                          //讄圆角——四个圆角半径 
btn1.layer.borderWidth = 0.5;                                                                                                          // 按钮Ҏ宽度
                   
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();                                                   // 讄颜色I间为rgbQ用于生成ColorRef
CGColorRef borderColorRef = CGColorCreate(colorSpace,(CGFloat[]){ 0, 0, 0, 1 });                        // 新徏一个红色的ColorRefQ用于设|边框(四个数字分别?r, g, b, alphaQ?/span>
btn1.layer.borderColor = borderColorRef;                                                                                        // 讄Ҏ颜色

更多属性参考链接:http://www.cocoachina.com/wiki/index.php?title=UIButton&variant=zh-cn

参数 forState . q个参数军_了标题、图像或其他属性将在何U状态下昄。你可以~程令按钮在那个状态变?nbsp;
enum { 
    UIControlStateNormal       = 0,                    // 常?nbsp;                     
    UIControlStateHighlighted  = 1 << 0,          // 高亮 
    UIControlStateDisabled     = 1 << 1,           // 用 
    UIControlStateSelected     = 1 << 2,           // 选中 
    UIControlStateApplication  = 0x00FF0000,  // 当应用程序标志用时 
    UIControlStateReserved     = 0xFF000000  // 为内部框枉留的 
}; 
typedef NSUInteger UIControlState; 
 
你只要掌握前四种状态就好了?/span>
当按钮高亮或者禁用,UIButton cd以调整自q外观Q下面几个属性可以让你按照需要对按钮的外观进行微调:
adjustsImageWhenHighlighted
默认情况下,在按钮被用Ӟ囑փ会被ȝ颜色׃些。要用此功能,请将q个属性设|ؓNOQ?/span>
btn1.adjustsImageWhenHighlighted = NO; 

adjustsImageWhenDisabled
默认情况下,按钮在被用Ӟ囑փ会被ȝ颜色淡一些。要用此功能,请将q个属性设|ؓNOQ?/span>
btn1.adjustsImageWhenDisabled = NO; 

showsTouchWhenHighlighted
q个属性设|ؓYESQ可令按钮在按下时发光。这可以用于信息按钮或者有些重要的按钮Q?/span>
btn1.showsTouchWhenHighlighted = YES;
 
昄控g
[self.view addSubview:btn1]; 
[self.view addSubview:btn2]; 
 
重写l制行ؓ
 
你可以通过子类化按钮来定制属于你自q按钮cR在子类化的时候你可以重蝲下面q些ҎQ这些方法返回CGRectl构Q指明了按钮每一l成部分的边界?/span>
注意Q不要直接调用这些方法, q些Ҏ是你写给pȝ调用的?/span>
 
backgroundRectForBounds   //指定背景边界 
contentRectForBounds         // 指定内容边界 
titleRectForContentRect       // 指定文字标题边界  
imageRectForContentRect   //指定按钮囑փ边界 
 
例:
- (CGRect)imageRectForContentRect:(CGRect)bounds

     return CGRectMake(0.0, 0.0, 44, 44); 

 
[btn1 addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside];//d点击按钮事g
 
-(void)btnPressed:(id)sender
{  
      UIButton* btn = (UIButton*)sender;  
      //开始写你自q动作 
}

forControlEvents参数cd
 typedef NS_OPTIONS(NSUInteger, UIControlEvents) 
{
    UIControlEventTouchDown                 = 1 <<  0,      // 单点触摸按下事gQ用L触屏q,或者又有新手指落下的时候?br />    UIControlEventTouchDownRepeat      = 1 <<  1,      // 多点触摸按下事gQ点触计数大?Q用h下第二、三、或W四Ҏ指的时候?/span>
    UIControlEventTouchDragInside         = 1 <<  2,      // 当一ơ触摸在控gH口内拖动时?/span>
    UIControlEventTouchDragOutside       = 1 <<  3,      // 当一ơ触摸在控gH口之外拖动时?/span>
    UIControlEventTouchDragEnter           = 1 <<  4,      // 当一ơ触总控gH口之外拖动到内部时
    UIControlEventTouchDragExit             = 1 <<  5,      // 当一ơ触总控gH口内部拖动到外部时?/span>
    UIControlEventTouchUpInside            = 1 <<  6,      // 所有在控g之内触摸抬v事g
    UIControlEventTouchUpOutside          = 1 <<  7,      // 所有在控g之外触摸抬v事g(点触必须开始与控g内部才会发送通知)?/span>
    UIControlEventTouchCancel                = 1 <<  8,      //所有触摸取消事Ӟ即一ơ触摸因为放上了太多手指而被取消Q或者被上锁或者电话呼叫打断?/span>

    UIControlEventValueChanged             = 1 << 12,     // 当控件的值发生改变时Q发送通知。用于滑块、分D|件、以及其他取值的控g。你可以配置滑块控g何时发送通知Q在滑块被放下时发送,或者在被拖动时发送?/span>

    UIControlEventEditingDidBegin           = 1 << 16,     // 当文本控件中开始编辑时发送通知
    UIControlEventEditingChanged           = 1 << 17,     // 当文本控件中的文本被改变时发送通知?/span>
    UIControlEventEditingDidEnd              = 1 << 18,     // 当文本控件中~辑l束时发送通知?/span>
    UIControlEventEditingDidEndOnExit    = 1 << 19,     // 当文本控件内通过按下回R键(或等仯为)l束~辑Ӟ发送通知?/span>

    UIControlEventAllTouchEvents             = 0x00000FFF,  // 通知所有触怺件?/span>
    UIControlEventAllEditingEvents           = 0x000F0000,  // 通知所有关于文本编辑的事g?/span>
    UIControlEventApplicationReserved    = 0x0F000000,  // range available for application use
    UIControlEventSystemReserved          = 0xF0000000,  // range reserved for internal framework use
    UIControlEventAllEvents                      = 0xFFFFFFFF   // 通知所有事?/span>
}; 

]]>
iOS UITextFieldW记http://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207649.html王v?/dc:creator>王v?/author>Tue, 15 Jul 2014 03:02:00 GMThttp://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207649.htmlhttp://m.shnenglu.com/wanghaiguang/comments/207649.htmlhttp://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207649.html#Feedback0http://m.shnenglu.com/wanghaiguang/comments/commentRss/207649.htmlhttp://m.shnenglu.com/wanghaiguang/services/trackbacks/207649.html
//手动定义一个UITextField 及其基本的属性:
 UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(202013030)];
 
//讄Ҏ样式Q只有设|了才会昄Ҏ样式 
text.borderStyle = UITextBorderStyleRoundedRect;
typedef 
enum 
{
    UITextBorderStyleNone, 
    UITextBorderStyleLine,
    UITextBorderStyleBezel,
    UITextBorderStyleRoundedRect  
  } UITextBorderStyle;
 
text.backgroundColor 
= [UIColor whiteColor];                             //讄输入框的背景颜色Q此时设|ؓ白色 如果使用了自定义的背景图片边框会被忽略掉 
text.background = [UIImage imageNamed:@"dd.png"];              //讄背景
text.disabledBackground = [UIImage imageNamed:@"cc.png"]; //讄背景
text.placeholder = @"password";                                                //当输入框没有内容Ӟ水印提示 提示内容为password
text.font = [UIFont fontWithName:@"Arial" size:20.0f];              //讄输入框内容的字体样式和大?/span>
text.textColor = [UIColor redColor];                                            //讄字体颜色
text.clearButtonMode = UITextFieldViewModeAlways;                //输入框中是否有个叉号Q在什么时候显C,用于一ơ性删除输入框中的内容

typedef 
enum 
{
    UITextFieldViewModeNever,            
//重不出现
    UITextFieldViewModeWhileEditing,    
//~辑时出?/span>
    UITextFieldViewModeUnlessEditing,  
// 除了~辑外都出现
    UITextFieldViewModeAlways           
//一直出?nbsp;
} UITextFieldViewMode;

text.text = @"一开始就在输入框的文?/span>";   //输入框中一开始就有的文字
text.secureTextEntry = YES;                 //每输入一个字W就变成?nbsp;用语密码输入
text.autocorrectionType = UITextAutocorrectionTypeNo;//是否U错
 
typedef enum 
{

    UITextAutocorrectionTypeDefault,  // 默认
    UITextAutocorrectionTypeNo,       //不自动纠?br />    UITextAutocorrectionTypeYes,      //自动U错
} UITextAutocorrectionType;

text.clearsOnBeginEditing = YES;                            //再次~辑清I?/span>
text.textAlignment = UITextAlignmentLeft;              //内容寚w方式
text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;//内容的垂直对齐方?nbsp; UITextFieldl承自UIControl,此类中有一个属性contentVerticalAlignment
textFied.adjustsFontSizeToFitWidth = YES;             //讄为YES时文本会自动~小以适应文本H口大小.默认是保持原来大?而让长文本滚动 
text.minimumFontSize = 20;                                    //讄自动~小昄的最字体大?/span>
text.keyboardType = UIKeyboardTypeNumberPad; //讄键盘的样?/span>
 
typedef 
enum 
{
    UIKeyboardTypeDefault,                             默认键盘Q支持所有字W?br />    UIKeyboardTypeASCIICapable,                  支持ASCII的默认键?br />    UIKeyboardTypeNumbersAndPunctuation, 标准电话键盘Q支持+Q#字符
    UIKeyboardTypeURL,                                    URL键盘Q支?com按钮 只支持URL字符
UIKeyboardTypeNumberPad,                          数字键盘
UIKeyboardTypePhonePad,                          电话键盘
    UIKeyboardTypeNamePhonePad,               电话键盘Q也支持输入人名
UIKeyboardTypeEmailAddress,                       用于输入电子 邮g地址的键?nbsp;    
UIKeyboardTypeDecimalPad,                          数字键盘 有数字和数?br />    UIKeyboardTypeTwitter,                             优化的键盘,方便输入@?字符
    
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, 
} UIKeyboardType;
 
text.autocapitalizationType 
= UITextAutocapitalizationTypeNone;//首字母是否大?/span>
 
typedef 
enum 
{
    UITextAutocapitalizationTypeNone,              不自动大?br />    UITextAutocapitalizationTypeWords,          单词首字母大?br />    UITextAutocapitalizationTypeSentences,    句子的首字母大写
    UITextAutocapitalizationTypeAllCharacters,  所有字母都大写 
} UITextAutocapitalizationType;

 text.returnKeyType =UIReturnKeyDone;//return键变成什么键
typedef enum 
{
    UIReturnKeyDefault,              默认 灰色按钮Q标有Return
    UIReturnKeyGo,                   标有Go的蓝色按?br />    UIReturnKeyGoogle,              标有Google的蓝色按钮,用语搜烦
    UIReturnKeyJoin,                   标有Join的蓝色按?br />    UIReturnKeyNext,                  标有Next的蓝色按?br />    UIReturnKeyRoute,                标有Route的蓝色按?br />    UIReturnKeySearch,              标有Search的蓝色按?br />    UIReturnKeySend,                 标有Send的蓝色按?br />    UIReturnKeyYahoo,               标有Yahoo的蓝色按?br />    UIReturnKeyYahoo,               标有Yahoo的蓝色按?br />    UIReturnKeyEmergencyCall,  紧急呼叫按?nbsp;
} UIReturnKeyType;

textView.keyboardAppearance=UIKeyboardAppearanceDefaultQ?/span>//键盘外观
typedef enum 
{
UIKeyboardAppearanceDefaultQ?/span>   默认外观Q浅灰色
UIKeyboardAppearanceAlertQ?/span>   q 矛_?/span>
} UIReturnKeyType;

text.delegate = self;//讄代理 用于实现协议
[self.window addSubview:text];//把textfield加到视图?br /> 
//最右侧加图片是以下代码  左侧cM
 UIImageView *image=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right.png"]];
 text.rightView
=image;
 text.rightViewMode 
= UITextFieldViewModeAlways; 
 
typedef 
enum 
{
    UITextFieldViewModeNever,
    UITextFieldViewModeWhileEditing,
    UITextFieldViewModeUnlessEditing,
    UITextFieldViewModeAlways
} UITextFieldViewMode;
 
//按return键键盘往下收  becomeFirstResponder
 
c要采用UITextFieldDelegate协议
text.
delegate = self; 声明text的代理是我,我会d现把键盘往下收的方?nbsp;q个Ҏ在UITextFieldDelegate里所以我们要采用UITextFieldDelegateq个协议
 
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [text resignFirstResponder];    
//主要是[receiver resignFirstResponder]在哪调用p把receiver对应的键盘往下收
    return YES;
}
重写l制行ؓ
除了UITextField对象的风格选项Q你q可以定制化UITextField对象Qؓ他添加许多不同的重写ҎQ来改变文本字段的显C为。这些方法都会返回一个CGRectl构Q制定了文本字段每个部g的边界范围。以下方法都可以重写?br /> 
– textRectForBounds:         
//重写来重|文字区?/span>
– drawTextInRect:              //改变l文字属?重写时调用super可以按默认图形属性绘?若自己完全重写绘制函敎ͼ׃用调用super?
– placeholderRectForBounds:   //重写来重|占位符区域
– drawPlaceholderInRect:    //重写改变l制占位W属?重写时调用super可以按默认图形属性绘?若自己完全重写绘制函敎ͼ׃用调用super?
– borderRectForBounds:      //重写来重|边~区?/span>
– editingRectForBounds:      //重写来重|编辑区?/span>
– clearButtonRectForBounds: //重写来重|clearButton位置,改变size可能Dbutton的图片失?/span>
– leftViewRectForBounds:
– rightViewRectForBounds:
 
委托Ҏ
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{   
      
//q回一个BOOL|指定是否循序文本字段开始编辑  
      return YES; 
} 
 
- (void)textFieldDidBeginEditing:(UITextField *)textField
{ 
       
//开始编辑时触发Q文本字D将成ؓfirst responder 
} 
 
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{ 
      
//q回BOOL|指定是否允许文本字段l束~辑Q当~辑l束Q文本字D会让出first responder 
    
//要想在用L束编辑时L文本字段消失Q可以返回NO 
    
//q对一些文本字D必dl保持活跃状态的E序很有用,比如x消息 
  
    
return NO; 
} 
 
- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{ 
      
//当用户用自动更正功能,把输入的文字修改为推荐的文字Ӟ׃调用q个Ҏ。 
      
//q对于想要加入撤销选项的应用程序特别有用 
      
//可以跟踪字段内所做的最后一ơ修改,也可以对所有编辑做日志记录,用作审计用途。   
      
//要防止文字被改变可以q回NO 
      
//q个Ҏ的参C有一个NSRange对象Q指明了被改变文字的位置Q徏议修改的文本也在其中 
 
    
return YES; 
} 
 
- (BOOL)textFieldShouldClear:(UITextField *)textField
{ 
      
//q回一个BOOL值指明是否允许根据用戯求清除内宏V
      
//可以讄在特定条件下才允许清除内宏V
 
    
return YES; 
} 
 
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{ 
      
//q回一个BOOL|指明是否允许在按下回车键时结束编辑 
       
//如果允许要调用resignFirstResponder ҎQ这回导致结束编辑,而键盘会被收起[textField resignFirstResponder];
      
//查一下resignq个单词的意思就明白q个Ҏ了 
    return YES; 
} 
 
通知
UITextFieldz自UIControlQ所以UIControlcM的通知pȝ在文本字D中也可以用。除了UIControlcȝ标准事gQ你q可以用下列UITextFieldcȝ有的事g
 
UITextFieldTextDidBeginEditingNotification
UITextFieldTextDidChangeNotification
UITextFieldTextDidEndEditingNotification
当文本字D退出编辑模式时触发。通知的object属性存储了最l文本?br /> 
因ؓ文本字段要用键盘输入文字,所以下面这些事件发生时Q也会发送动作通知
UIKeyboardWillShowNotification  
//键盘昄之前发?/span>
UIKeyboardDidShowNotification   //键盘昄之后发?/span>
UIKeyboardWillHideNotification    //键盘隐藏之前发?/span>
UIKeyboardDidHideNotification    //键盘隐藏之后发?/span>
1、Text Q设|文本框的默认文本?/div>
2、Placeholder Q?nbsp;可以在文本框中显C灰色的字,用于提示用户应该在这个文本框输入什么内宏V当q个文本框中输入了数据时Q用于提C的灰色的字会自动消失?/div>
3、Background Q?/div>
4、Disabled Q?nbsp;若选中此项Q用户将不能更改文本框内宏V?/div>
5、接下来是三个按钮,用来讄寚w方式?/div>
6、Border Style Q?nbsp;选择边界风格?/div>
7、Clear Button Q?nbsp;q是一个下拉菜单,你可以选择清除按钮什么时候出玎ͼ所谓清除按钮就是出一个现在文本框双的小 X Q你可以有以下选择Q?/div>
    7.1 Never appears Q?nbsp;从不出现
    7.2 Appears while editing Q?nbsp;~辑时出?/div>
    7.3 Appears unless editing Q?nbsp;
    7.4 Is always visible Q?nbsp;L可见
8、Clear when editing begins Q?nbsp;若选中此项Q则当开始编辑这个文本框Ӟ文本框中之前的内容会被清除掉。比如,你现在这个文本框 A 中输入了 "What" Q之后去~辑文本?nbsp;BQ若再回来编辑文本框 A Q则其中?nbsp;"What" 会被立即清除?/div>
9、Text Color Q?nbsp;讄文本框中文本的颜艌Ӏ?/div>
10、Font Q?nbsp;讄文本的字体与字号?/div>
11、Min Font Size Q?nbsp;讄文本框可以显C的最字体(不过我感觉没什么用Q?/div>
12、Adjust To Fit Q?nbsp;指定当文本框寸减小Ӟ文本框中的文本是否也要羃。选择它,可以使得全部文本都可见,即文本很长。但是这个选项要跟 Min Font Size 配合使用Q文本再~小Q也不会于讑֮?nbsp;Min Font Size ?/div>
接下来的部分用于讄键盘如何昄?/div>
13、Captitalization Q?nbsp;讄大写。下拉菜单中有四个选项Q?/div>
    13.1 None Q?nbsp;不设|大?/div>
    13.2 Words Q?nbsp;每个单词首字母大写,q里的单词指的是以空格分开的字W串
    13.3 Sentances Q?nbsp;每个句子的第一个字母大写,q里的句子是以句号加I格分开的字W串
    13.4 All Characters Q?nbsp;所以字母大?/div>
14、Correction Q?nbsp;查拼写,默认?nbsp;YES ?/div>
15、Keyboard Q?nbsp;选择键盘cdQ比如全数字、字母和数字{?/div>
16、AppearanceQ?/div>
17、Return Key Q?nbsp;选择q回键,可以选择 Search ?nbsp;Return ?nbsp;Done {?/div>
18、Auto-enable Return Key Q?nbsp;如选择此项Q则只有臛_在文本框输入一个字W后键盘的返回键才有效?/div>
19、Secure Q?nbsp;当你的文本框用作密码输入框时Q可以选择q个选项Q此Ӟ字符昄为星受?/div>
 
1.Alignment Horizontal 水^寚w方式
2.Alignment Vertical 垂直寚w方式
3.用于q回一个BOOL倹{输入框是?nbsp;Selected(选中) Enabled(可用) Highlighted(高亮)
 
限制只能输入特定的字W?/div>
(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    NSCharacterSet 
*cs;
    cs 
= [[NSCharacterSet characterSetWithCharactersInString:NUMBERS]invertedSet];
 
    NSString 
*filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""]; //按cs分离出数l?数组按@""分离出字W串
 
    BOOL canChange 
= [string isEqualToString:filtered];
 
    
return canChange;
}
 
上面那个NUMBERS是一个宏Q可以在文g剙定义Q?/div>
#define NUMBERS @”0123456789n” Q这个代表可以输入数字和换行Q请注意q个nQ如果不写这个,Done按键不会触发,如果用在SearchBar中,会不触发Search事gQ因Z自己限制不让输入nQ好惨,我在目中才发现的。)
所以,如果你要限制输入英文和数字的话,可以把q个定义为:
#define kAlphaNum   @”ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789″?/div>
当然Q你q可以在以上Ҏreturn之前Q做一提示的,比如提示用户只能输入数字之类的。如果你觉得有需要的话?/div>
 
限制只能输入一定长度的字符
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{ 
      
//string是此时输入的那个字W?nbsp;textField是此时正在输入的那个输入框 q回YES是可以改变输入框的?nbsp;NO相反
      
if ([string isEqualToString:@"n"]) //按会车可以改?/span>
      { 
           
return YES; 
      } 
      NSString 
* toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string]; //得到输入框的内容
 
      
if (self.myTextField == textField) //判断是否时我们想要限定的那个输入?/span>
      { 
          
if ([toBeString length] > 20
          { 
               
//如果输入框内容大?0则弹?/span>
               textField.text = [toBeString substringToIndex:20]; 
               UIAlertView 
*alert = [[[UIAlertView alloc] initWithTitle:nil message:@"过最大字C能输入了" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil] autorelease]; 
               [alert show]; 
               
return NO; 
          } 
      }
 
    
return YES; 
}

本文转自Q?/span>http://www.3lian.com/edu/2012/11-08/43227.html

]]>iOS日期W记http://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207648.html王v?/dc:creator>王v?/author>Tue, 15 Jul 2014 02:43:00 GMThttp://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207648.htmlhttp://m.shnenglu.com/wanghaiguang/comments/207648.htmlhttp://m.shnenglu.com/wanghaiguang/archive/2014/07/15/207648.html#Feedback0http://m.shnenglu.com/wanghaiguang/comments/commentRss/207648.htmlhttp://m.shnenglu.com/wanghaiguang/services/trackbacks/207648.html1、根据年、月、日获取星期?/strong>
- (int)getWeekdayFromDate:(int)nYead andMonth:(int)nMonth andDay:(int)nDay
{
    NSDateComponents *_comps = [[NSDateComponents alloc] init];
    [_comps setDay:nDay];
    [_comps setMonth:nMonth];
    [_comps setYear:nYead];
    NSCalendar *gregorian = [[NSCalendar alloc]
                             initWithCalendarIdentifier:NSGregorianCalendar];
    NSDate *_date = [gregorian dateFromComponents:_comps];
    NSDateComponents *weekdayComponents =
    [gregorian components:NSWeekdayCalendarUnit fromDate:_date];
    int _weekday = [weekdayComponents weekday];
    
    return _weekday;
}
?/span>
- (NSUInteger)getWeekdayFromDate:(NSDate*)date
{
    NSCalendar* calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease]; 
    NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease]; 
    NSInteger unitFlags = NSYearCalendarUnit | 
                          NSMonthCalendarUnit | 
                          NSDayCalendarUnit | 
                          NSWeekdayCalendarUnit | 
                          NSHourCalendarUnit | 
                          NSMinuteCalendarUnit | 
                          NSSecondCalendarUnit; 

    components = [calendar components:unitFlags fromDate:date];
    NSUInteger weekday = [components weekday]; 
    return weekday;
}

2、根据月和日获取星
-(NSString *)getAstroWithMonth:(int)m day:(int)d
{ 
    NSString *astroString = @"羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎手羯";
    NSString *astroFormat = @"102123444543";
    NSString *result; 
    if (m < 1 || m > 12 || d < 1 || d > 31)
    {
        return @"错误日期格式!";
    }  
    if(m == 2 && d > 29)
    {
        return @"错误日期格式!!";
    }
    else if(m == 4 || m == 6 || m == 9 || m == 11)
    {
        if (d > 30)
        {
            return @"错误日期格式!!!";
        }
    }
    
    result = [NSString stringWithFormat:@"%@",[astroString substringWithRange:NSMakeRange(m*2 - (d < [[astroFormat substringWithRange:NSMakeRange((m - 1), 1)] intValue] - (-19))*2, 2)]];
    
    return result;
}

3、计两个日期之间相差几天几时几分?/strong>
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
   [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
   NSDate *  senddate=[NSDate date];
   //l束旉
   NSDate *endDate = [dateFormatter dateFromString:@"2014-6-24 00:00:00"];
   //当前旉
   NSDate *senderDate = [dateFormatter dateFromString:[dateFormatter stringFromDate:senddate]];
   //得到相差U数
   NSTimeInterval time=[endDate timeIntervalSinceDate:senderDate];
    
   int days = ((int)time)/(3600*24);
   int hours = ((int)time)%(3600*24)/3600;
   int minute = ((int)time)%(3600*24)600/60;
   
   if (days <= 0&&hours; <= 0&&minute; <= 0)
       dateContent=@"0?时0分钟";
   else
       dateContent=[[NSString alloc] initWithFormat:@"%i?i时%i分钟",days,hours,minute];

4、获取当前时?/strong>
NSDate *now = [NSDate date];
NSLog(@”now date is: %@”, now);

NSCalendar *calendar = [NSCalendar currentCalendar];
NSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *dateComponent = [calendar components:unitFlags fromDate:now];
    
int year = [dateComponent year];
int month = [dateComponent month];
int day = [dateComponent day];
int hour = [dateComponent hour];
int minute = [dateComponent minute];
int second = [dateComponent second];

NSLog(@”year is: %d”, year);
NSLog(@”month is: %d”, month);
NSLog(@”day is: %d”, day);
NSLog(@”hour is: %d”, hour);
NSLog(@”minute is: %d”, minute);
NSLog(@”second is: %d”, second);

注:Ҏ互联|资料整?/span>


]]>关闭ios虚拟键盘的几U方法(转蝲Q?/title><link>http://m.shnenglu.com/wanghaiguang/archive/2014/06/23/207382.html</link><dc:creator>王v?/dc:creator><author>王v?/author><pubDate>Mon, 23 Jun 2014 05:54:00 GMT</pubDate><guid>http://m.shnenglu.com/wanghaiguang/archive/2014/06/23/207382.html</guid><wfw:comment>http://m.shnenglu.com/wanghaiguang/comments/207382.html</wfw:comment><comments>http://m.shnenglu.com/wanghaiguang/archive/2014/06/23/207382.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/wanghaiguang/comments/commentRss/207382.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/wanghaiguang/services/trackbacks/207382.html</trackback:ping><description><![CDATA[<div class="eiuoqwm" id="blog_content" class="blog_content" style="line-height: 1.8em;"> <p style="margin: 0px; padding: 0px;">在iOS应用开发中Q有三类视图对象会打开虚拟键盘Q进行输入操作,但如何关闭虚拟键盘,却没有提供自动化的方法。这个需要我们自己去实现。这三类视图对象分别是UITextField,UITextView和UISearchBar?br /> q里介绍一下UITextField中关闭虚拟键盘的几种Ҏ?/p> <p style="margin: 0px; padding: 0px;"> </p> <p style="margin: 0px; padding: 0px;">(原文链接: <a style="color: #006699;">http://mikixiyou.iteye.com/blog/1753330</a> )</p> <p style="margin: 0px; padding: 0px;"><br /><strong> W一U方法,使用它的委托UITextFieldDelegate中的ҎtextFieldShouldReturn:来关闭虚拟键盘?/strong><br /> 在UITextField视图对象如birdNameInput所在的cM实现q个Ҏ?br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->- (BOOL)textFieldShouldReturn:(UITextField *)textField {  <br />    <span style="color: #0000FF; ">if</span> ((textField == self.birdNameInput) || (textField == self.locationInput)) {  <br />        [textField resignFirstResponder];  <br />    }  <br />    <span style="color: #0000FF; ">return</span> YES;  <br />} </div><p> <span style="line-height: 1.8em; font-size: 14px;">q样Q在输入框birdNameInput中打开虚拟键盘后,d键盘的return键就会自动关闭掉虚拟键盘?/span></p><p style="margin: 0px; padding: 0px;"><br /><strong> W二U方法,birdNameInput的属性中Return Key修改为doneQ再定义一个方法和Done键的Did End On Exitq接。通过ddone键触发这个事件来关闭虚拟键盘?/strong><br /> 定义的方法如下:<br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->- (IBAction) textFieldDoneEditing:(id)sender  <br />{  <br />        [sender resignFirstResponder];  <br />} <span style="line-height: 1.8em; font-size: 14px;"> </span></div> <p style="margin: 0px; padding: 0px;">q两个方法都是轻击虚拟键盘上一个键来关闭它。这属于_操作Q而手指不像鼠标,做这U操作不Ҏ。因此就UI层面而言Q这两个Ҏ都不是最好的Ҏ?br /> 在iphone或ipad屏幕上,虚拟键盘占用的面U大是有限的。通过d虚拟键盘之外的区域而关闭虚拟键盘?/p> <p style="margin: 0px; padding: 0px;"> </p> <p style="margin: 0px; padding: 0px;"><strong>W三U方法,通过d键盘之外的空白区域关闭虚拟键盘?/strong><br /> 在birdNameInput所属的视图控制器类的viewDidLoadҎ中定义一个UITapGestureRecognizer的对象,然后它赋gؓ它的视图?br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]   initWithTarget:self action:@selector(dismissKeyboard)];  <br />[self.view addGestureRecognizer:tap];  <br />[tap release]; </div> <p style="margin: 0px; padding: 0px;"><br />再定义一下选择器调用的ҎdismissKeyboard?br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->-(<span style="color: #0000FF; ">void</span>)dismissKeyboard {  <br />       [birdNameInput resignFirstResponder];  <br />} </div><p style="margin: 0px; padding: 0px;"> <br />如果屏幕上有多个textField的话Q一个一个地列出来就有些ȝ。那么将Ҏ修改一下,如下Q?br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->-(<span style="color: #0000FF; ">void</span>)dismissKeyboard {  <br />    NSArray *subviews = [self.view subviews];  <br />    <span style="color: #0000FF; ">for</span> (id objInput <span style="color: #0000FF; ">in</span> subviews) {  <br />        <span style="color: #0000FF; ">if</span> ([objInput isKindOfClass:[UITextField <span style="color: #0000FF; ">class</span>]]) {  <br />            UITextField *theTextField = objInput;  <br />            <span style="color: #0000FF; ">if</span> ([objInput isFirstResponder]) {  <br />                [theTextField resignFirstResponder];  <br />            }  <br />        }  <br />    }  <br />}</div> <p style="margin: 0px; padding: 0px;">如果q个屏幕上的视图对象很复杂的话,另当别论?br /> q个Ҏ是编码新Z个手势对象。也可以直接使用interface builder囑Ş化开发工P在storyboard中拉入一个手势对象到视图控制器类中,再将此手势对象徏立一个IBACTIONQ名U可以是dismissKeyboard?br /> <br /><strong> W四U方法,通过d键盘之外的空白区域关闭虚拟键盘?/strong><br /> 屏q上的view也就是textField的父视图拖一个touch down事g出来Q和一个能关闭虚拟键盘的方法连接。如果视图没有touch down事gQ可view的父cMUIView修改为UIButton?br /> 首先定义q实C个方法backgroundTapQ?/p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"> <span style="font-size: 13px; line-height: 1.8em;">-</span><span style="font-size: 13px; line-height: 1.8em;"> (IBAction) backgroundTap:(id)sender  </span><br />{  <br />        NSArray *subviews = [self.view subviews];  <br />    <span style="color: #0000FF; ">for</span> (id objInput <span style="color: #0000FF; ">in</span> subviews) {  <br />        <span style="color: #0000FF; ">if</span> ([objInput isKindOfClass:[UITextField <span style="color: #0000FF; ">class</span>]]) {  <br />            UITextField *theTextField = objInput;  <br />            <span style="color: #0000FF; ">if</span> ([objInput isFirstResponder]) {  <br />                [theTextField resignFirstResponder];  <br />            }  <br />        }  <br />    }  <br />}</div> <p style="margin: 0px; padding: 0px;">然后选择背景视图的Touch Down事gQ连?backgroundTapQ即可。这样只要轻M下虚拟键盘之外的区域Q就能关闭虚拟键盘。这些方法都是用resignFirstResponderҎ来关闭虚拟键盘,q有其他的方法?/p> <p style="margin: 0px; padding: 0px;"> </p> <p style="margin: 0px; padding: 0px;"><strong>W五U方法,使用endEditingQ方?/strong><br /> 在所在的视图控制器类中,覆盖q个Ҏ?br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->- (<span style="color: #0000FF; ">void</span>)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)<span style="color: #0000FF; ">event</span> {  <br />      [[self view] endEditing:YES];  <br />}</div><p> </p> <p style="margin: 0px; padding: 0px;">This method looks at the current view and its subview hierarchy for the text field that is currently the first responder. If it finds one, it asks that text field to resign as first responder. If the force parameter is set to YES, the text field is never even asked; it is forced to resign.<br /> 但是Q如果这个屏q很复杂Q虚拟键盘之外的区域中有很多按钮。轻击这些区域时可能会轻dq些按钮Q这栯拟键盘就不能关闭?br /> 要是扑ֈ一个没有按钮的I白区域都不Ҏ且还有隐藏的视图对象Ӟ通过d虚拟键盘之外的区域关闭虚拟键盘的Ҏ实现h难了?/p> <p style="margin: 0px; padding: 0px;"> </p> <p style="margin: 0px; padding: 0px;"><strong>W六U方法,覆盖hitTest:withEvent:Ҏ关闭虚拟键盘</strong></p> <p style="margin: 0px; padding: 0px;"> </p> <p style="margin: 0px; padding: 0px;">在stackoverflow.com上,有hq样ȝ。说使用hitTest:withEvent:Ҏ是最好的Q也是最Ҏ的解x法?/p> <p style="margin: 0px; padding: 0px;"> </p> <p style="margin: 0px; padding: 0px;">I think the easiest (and best) way to do this is to subclass your global view and use hitTest:withEvent method to listen to any touch. <br /> Touches on keyboard aren't registered, so hitTest:withEvent is only called when you touch/scroll/swipe/pinch... somewhere else, then call [self endEditing:YES].<br /> This is better than using touchesBegan because touchesBegan are not called if you click on a button on top of the view. <br /> It is better than UITapGestureRecognizer which can't recognize a scrolling gesture for example. It is also better than using a dim screen because in a complexe and dynamic user interface, you can't put dim screen every where. Moreover, it doesn't block other actions, you don't need to tap twice to select a button outside (like in the case of a UIPopover).<br /> Also, it's better than calling [textField resignFirstResponder], because you may have many text fields on screen, so this works for all of them.</p> <p style="margin: 0px; padding: 0px;"> </p> <p style="margin: 0px; padding: 0px;">因此Q我再徏立一个承UIView的视囄。在q个视图cMQ覆盖hitTest:withEvent:ҎQ增加[self endEditing:YES]Ҏ?/p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"> <span style="font-size: 13px; line-height: 1.8em;">-</span><span style="font-size: 13px; line-height: 1.8em;"> (UIView </span><span style="font-size: 13px; line-height: 1.8em;">*</span><span style="font-size: 13px; line-height: 1.8em;">)hitTest:(CGPoint)point withEvent:(UIEvent </span><span style="font-size: 13px; line-height: 1.8em;">*</span><span style="font-size: 13px; line-height: 1.8em;">)</span><span style="font-size: 13px; line-height: 1.8em; color: #0000ff;">event</span><span style="font-size: 13px; line-height: 1.8em;"> {  </span><br />UIView *result = [super hitTest:point withEvent:<span style="color: #0000FF; ">event</span>];  <br />[self endEditing:YES]  <br /><span style="color: #0000FF; ">return</span> result;  <br />} </div><p style="margin: 0px; padding: 0px;"> 我将视图控制器的主视图所属类修改个新囄。这样在屏幕上轻MQ何位|都会关闭虚拟键盘?br /> q个Ҏ是最单,也是最好的关闭虚拟键盘的方法?br /> 使用好hitTest:withEvent:q个ҎQ还可以实现很多很复杂的功能?br /> The implementation of hitTest:withEvent: in UIResponder does the following:</p> <ul style="margin: 0px 0px 1.5em; padding: 0px;"> <li style="margin: 0px 0px 0.25em 30px; padding: 0px;">    It calls pointInside:withEvent: of self</li> <li style="margin: 0px 0px 0.25em 30px; padding: 0px;">    If the return is NO, hitTest:withEvent: returns nil. the end of the story.</li> <li style="margin: 0px 0px 0.25em 30px; padding: 0px;">    If the return is YES, it sends hitTest:withEvent: messages to its subviews. it starts from the top-level subview, and continues to other views until a subview returns a non-nil object, or all subviews receive the message.</li> <li style="margin: 0px 0px 0.25em 30px; padding: 0px;">    If a subview returns a non-nil object in the first time, the first hitTest:withEvent: returns that object. the end of the story.</li> <li style="margin: 0px 0px 0.25em 30px; padding: 0px;">    If no subview returns a non-nil object, the first hitTest:withEvent: returns self</li> </ul> <p style="margin: 0px; padding: 0px;">This process repeats recursively, so normally the leaf view of the view hierarchy is returned eventually.<br /> However, you might override hitTest:withEvent to do something differently. In many cases, overriding pointInside:withEvent: is simpler and still provides enough options to tweak event handling in your application.</p></div><img src ="http://m.shnenglu.com/wanghaiguang/aggbug/207382.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/wanghaiguang/" target="_blank">王v?/a> 2014-06-23 13:54 <a href="http://m.shnenglu.com/wanghaiguang/archive/2014/06/23/207382.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>iOS界面传递之委托http://m.shnenglu.com/wanghaiguang/archive/2014/06/18/207325.html王v?/dc:creator>王v?/author>Wed, 18 Jun 2014 06:50:00 GMThttp://m.shnenglu.com/wanghaiguang/archive/2014/06/18/207325.htmlhttp://m.shnenglu.com/wanghaiguang/comments/207325.htmlhttp://m.shnenglu.com/wanghaiguang/archive/2014/06/18/207325.html#Feedback0http://m.shnenglu.com/wanghaiguang/comments/commentRss/207325.htmlhttp://m.shnenglu.com/wanghaiguang/services/trackbacks/207325.html阅读全文

]]>
iOS中UIImageviewW记http://m.shnenglu.com/wanghaiguang/archive/2014/05/28/207130.html王v?/dc:creator>王v?/author>Wed, 28 May 2014 06:33:00 GMThttp://m.shnenglu.com/wanghaiguang/archive/2014/05/28/207130.htmlhttp://m.shnenglu.com/wanghaiguang/comments/207130.htmlhttp://m.shnenglu.com/wanghaiguang/archive/2014/05/28/207130.html#Feedback0http://m.shnenglu.com/wanghaiguang/comments/commentRss/207130.htmlhttp://m.shnenglu.com/wanghaiguang/services/trackbacks/207130.html
1     UIImageView *imgView =[[UIImageView alloc] initWithFrame:CGRectMake(128, 80,64,64)];
2     imgView.image = [UIImage imageNamed:@"portrait.png"];
3     imgView.userInteractionEnabled=YES;
4     UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClickPortraitImage)];
5     [imgView addGestureRecognizer:singleTap];
6     [self.view addSubview:imgView];

2、响应点M?/div>
1 -(void)onClickPortraitImage{
2     
3     NSLog(@"囄被点?");
4 }

开发工具Xcode5 pȝ版本Q?font face="Heiti SC Light">OS X 10. 9. 3 ( 13D65 )


]]> ޾þһح | þ99Ʒþ99ý| AAAþþþƷ| 99ھƷþþþþþ| ˾Ʒþ޸岻 | þþþ뾫Ʒ| þþƷAV| ھƷþþþþҰ| þþþ㽶Ƶ| AAAþþþƷƬ| þĻƷһ| 97þۺɫdžѿ| ޳ɫwwwþվҹ| һþaþþƷۺ| ۺϾþøϾþúݺݺ97ɫ | 99þùۺϾƷӰԺ | ݺɫۺվþþþþþø| Ʒþۺ| ŷ˾þþƷ| ۺþþ| þۺϳDž | þþƷ˳| ƷۺϾþþþþ97| þˬˬƬAV| þþƷëƬѹۿ| ƷһþþƷɬ| þþƷƷƾ| Ʒ˾Ʒþþ| 91þþƷ91þɫ| Сڵþþþþ| þݺҹҹ96׽| þۺɫHEZYO | þþwww| þAVĻ| þƵ| þ޹Ʒ123| ŷպƷþþþ| ҹƷþþĸ| ഺþ| һһþAþۺϾƷ| ɫþþۺƷ|