﻿<?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++博客-ifeng-随笔分类-IOS开发</title><link>http://www.cppblog.com/ifeng/category/17051.html</link><description /><language>zh-cn</language><lastBuildDate>Sat, 26 Jan 2013 00:37:42 GMT</lastBuildDate><pubDate>Sat, 26 Jan 2013 00:37:42 GMT</pubDate><ttl>60</ttl><item><title>IOS后台在线</title><link>http://www.cppblog.com/ifeng/archive/2013/01/24/197526.html</link><dc:creator>冷锋</dc:creator><author>冷锋</author><pubDate>Thu, 24 Jan 2013 02:40:00 GMT</pubDate><guid>http://www.cppblog.com/ifeng/archive/2013/01/24/197526.html</guid><wfw:comment>http://www.cppblog.com/ifeng/comments/197526.html</wfw:comment><comments>http://www.cppblog.com/ifeng/archive/2013/01/24/197526.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ifeng/comments/commentRss/197526.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ifeng/services/trackbacks/197526.html</trackback:ping><description><![CDATA[1.IOS进入后台最多可以申请10分钟的运行时间。<br />2.音乐、位置、VOIP可以后台运行。<br />3.以VOIP为例，需要在后台保持一条长连接，先将此socket打标记注册，进入后台时此socket会由系统托管，APP进入休眠。为了维持长连接，<br />系统会在最短600秒的间隔内唤醒一次，有新数据到来时也会唤醒，但是必须在10秒内处理完毕，此时，可以通过本地通知给用户。<br />详细文档参见官方文档。本文仅作笔记。<img src ="http://www.cppblog.com/ifeng/aggbug/197526.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ifeng/" target="_blank">冷锋</a> 2013-01-24 10:40 <a href="http://www.cppblog.com/ifeng/archive/2013/01/24/197526.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UIView的旋转</title><link>http://www.cppblog.com/ifeng/archive/2011/12/21/162548.html</link><dc:creator>冷锋</dc:creator><author>冷锋</author><pubDate>Wed, 21 Dec 2011 11:30:00 GMT</pubDate><guid>http://www.cppblog.com/ifeng/archive/2011/12/21/162548.html</guid><wfw:comment>http://www.cppblog.com/ifeng/comments/162548.html</wfw:comment><comments>http://www.cppblog.com/ifeng/archive/2011/12/21/162548.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ifeng/comments/commentRss/162548.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ifeng/services/trackbacks/162548.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;做过几次有关UIView坐标变换的，但是经常不能得到自己想要的效果，今天就把它仔细研究了下。记下来等以后忘记的时候再复习<br /><div><ul style="margin-left: 0.0208in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; ">  <p style="margin:0in;font-size:10.0pt"><span style="font-family:SimSun">重写</span><span style="font-family:Calibri">shouldAutorateToInterfaceOrientation:</span><span style="font-family:SimSun">，限制某个方向</span><span style="font-family: SimSun; font-size: 10pt; ">会改变原点的位置，原点会一直保持在左上角，但已经不是原来的左上角了</span></p>  <p style="margin:0in;font-family:SimSun;font-size:10.0pt">&nbsp;</p>  <p style="margin:0in;font-size:10.0pt"><span style="font-family:Calibri">setStatusBarOrientation.</span><span style="font-family:SimSun">改变状态栏的方向。它不会改变原点的位置，但会改变键盘的方向</span></p>  <p style="margin:0in;font-size:10.0pt"><span style="font-family:SimSun">旋转前</span><span style="font-family:Calibri">self.myview</span><span style="font-family:SimSun">的</span><span style="font-family:Calibri">frame ={0,0,320,50}</span></p>  <p style="margin:0in;font-family:SimSun;font-size:10.0pt">CGAffineTransform at  =CGAffineTransformMakeRotation(M_PI/2);</p>  <p style="margin:0in;font-size:10.0pt"><span style="font-family:SimSun">[self.</span><span style="font-family:Calibri">myview </span><span style="font-family:SimSun">setTransform:at];</span></p>  <p style="margin:0in;font-size:10.0pt"><span style="font-family:SimSun">旋转后</span><span style="font-family:Calibri">frame={135,-135,50,320},</span><span style="font-family:SimSun">视图的所有像素旋转</span><span style="font-family:  Calibri">90</span><span style="font-family:SimSun">度</span></p>  <p style="margin:0in;font-family:宋体;font-size:10.0pt">坐标是相对于父视图的</p>  <p style="margin:0in;font-family:宋体;font-size:10.0pt">&nbsp;</p>  <p style="margin:0in;font-size:10.0pt"><span style="font-family:宋体">假如</span><span style="font-family:Calibri">view</span><span style="font-family:宋体">已经转成竖的，这时通过设置</span><span style="font-family:  Calibri">frame</span><span style="font-family:宋体">而不是通过</span><span style="font-family:Calibri">setTransform</span><span style="font-family:宋体">强制成横的话，会截掉部分图像</span></p>  <p style="margin:0in;font-family:宋体;font-size:10.0pt">&nbsp;</p>  <p style="margin:0in;font-size:10.0pt"><span style="font-family:宋体">坐标多次变换的合成，要以被变换的</span><span style="font-family:Calibri">view</span><span style="font-family:宋体">的局部坐标系为参照，比如</span></p>  <p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">&nbsp;</p><div style="font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; border-image: initial; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; background-color: #eeeeee; "><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->testView&nbsp;=&nbsp;[[UIView&nbsp;alloc]&nbsp;initWithFrame:CGRectMake(0,&nbsp;0,&nbsp;320,&nbsp;50)];<br />UILabel*label&nbsp;=&nbsp;[[UILabel&nbsp;alloc]initWithFrame:CGRectMake(0,&nbsp;0,&nbsp;100,&nbsp;20)];<br />label.text&nbsp;=@"Test";<br />label.tag=100;<br />[testView&nbsp;addSubview:label];<br />此时的&nbsp;frame&nbsp;={0,0,320,50}</div><p>&nbsp;</p><div><img src="http://www.cppblog.com/images/cppblog_com/ifeng/未命名图片1.png" width="321" height="460" alt="" />&nbsp;<br /><br /><div title="Print Page Break" style="font-size: 1px; page-break-before: always; vertical-align: middle; height: 1px; background-color: #c0c0c0">&nbsp;<br />&nbsp;</div><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 />-->CGAffineTransform&nbsp;at&nbsp;=CGAffineTransformMakeRotation(M_PI/2);先顺时钟旋转90<br />at&nbsp;=CGAffineTransformTranslate(at,200,0);,<br />[self.testView&nbsp;setTransform:at];&nbsp;</div></div></ul>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.cppblog.com/images/cppblog_com/ifeng/未命名图片2.png" width="323" height="460" alt="" /><br /><div><p style="margin:0in;font-size:10.0pt"><span style="font-family:SimSun">此时的</span><span style="font-family:Calibri"> frame ={135,65,50,320},</span><span style="font-family:SimSun">可以看到宽高已经反过来了，</span><span style="font-family:Calibri">view</span><span style="font-family: SimSun">中的像素方向也改变了，而如果只是用</span><span style="font-family:Calibri">setFrame</span><span style="font-family:SimSun">来改变宽高的话是不会改变像素方向的</span></p></div><span style="background-color: #eeeeee; font-size: 13px; ">&nbsp;</span><span style="background-color: #eeeeee; font-size: 13px; ">&nbsp;</span><span style="background-color: #eeeeee; font-size: 13px; ">&nbsp;</span><span style="background-color: #eeeeee; font-size: 13px; ">&nbsp;</span><span style="background-color: #eeeeee; font-size: 13px; ">&nbsp;</span><span style="background-color: #eeeeee; font-size: 13px; ">&nbsp;</span><span style="background-color: #eeeeee; font-size: 13px; ">&nbsp;</span><span style="background-color: #eeeeee; font-size: 13px; ">&nbsp;</span></div><img src ="http://www.cppblog.com/ifeng/aggbug/162548.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ifeng/" target="_blank">冷锋</a> 2011-12-21 19:30 <a href="http://www.cppblog.com/ifeng/archive/2011/12/21/162548.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UIWebView加上safari风格前进后退按钮</title><link>http://www.cppblog.com/ifeng/archive/2011/06/02/147984.html</link><dc:creator>冷锋</dc:creator><author>冷锋</author><pubDate>Thu, 02 Jun 2011 14:46:00 GMT</pubDate><guid>http://www.cppblog.com/ifeng/archive/2011/06/02/147984.html</guid><wfw:comment>http://www.cppblog.com/ifeng/comments/147984.html</wfw:comment><comments>http://www.cppblog.com/ifeng/archive/2011/06/02/147984.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ifeng/comments/commentRss/147984.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ifeng/services/trackbacks/147984.html</trackback:ping><description><![CDATA[今天在写程序内打开网页的功能，写工具条的时候发现系统图标里面竟然没有后退按钮，，由于我这个是静态库工程，不可能自己弄张图上去，不然使用本库的时候还得附上图片，经过一下午的搜索，终于找到个比较靠谱的，这哥们硬是用代码给画出来个箭头了(话说如果是其他不规则的图形要咋办呢？)，还是google管用啊，baidu非常非常非常。。。垃圾。 
<div>
<h2><a title="Permanent Link: Code Example: Drawing the iPhone Back Button" href="http://outerlevel.com/blog/2008/12/26/code-example-drawing-the-iphone-back-button/" rel="bookmark">Code Example: Drawing the iPhone Back Button（转载）</a></h2>
<div>
<div><img alt="" src="http://outerlevel.com/blog/images/iPhoneBackButton.png" /></div>
<p>Recently, I had need to provide a back button similar to the one used in Mobile Safari for a consulting project.</p>
<p>Many of the buttons used in the built-in iPhone applications are made available via the SDK with built in button types and graphics. Unfortunately, the back button is not one of these.</p>
<p>Because I needed to display the toolbar button from inside a static library which can not include images, I had to render the back arrow directly in code.</p>
<p>Since this was a bit time consuming, I thought I would share in hopes that it saves someone else a little bit of time.</p>
<div><pre line="1">- (CGContextRef)createContext
{
// create the bitmap context
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(nil,27,27,8,0,
colorSpace,kCGImageAlphaPremultipliedLast);
CFRelease(colorSpace);
return context;
}
- (CGImageRef)createBackArrowImageRef
{
CGContextRef context = [self createContext];
// set the fill color
CGColorRef fillColor = [[UIColor blackColor] CGColor];
CGContextSetFillColor(context, CGColorGetComponents(fillColor));
CGContextBeginPath(context);
CGContextMoveToPoint(context, 8.0f, 13.0f);
CGContextAddLineToPoint(context, 24.0f, 4.0f);
CGContextAddLineToPoint(context, 24.0f, 22.0f);
CGContextClosePath(context);
CGContextFillPath(context);
// convert the context into a CGImageRef
CGImageRef image = CGBitmapContextCreateImage(context);
CGContextRelease(context);
return image;
}
- (UIBarButtonItem *)backButton
{
CGImageRef theCGImage = [self createBackArrowImageRef];
UIImage *backImage = [[UIImage alloc] initWithCGImage:theCGImage];
CGImageRelease(theCGImage);
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:backImage
style:UIBarButtonItemStylePlain
target:self.webView
action:@selector(goBack)];
[backImage release], backImage = nil;
return [backButton autorelease];
}</pre></div></div></div> <img src ="http://www.cppblog.com/ifeng/aggbug/147984.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ifeng/" target="_blank">冷锋</a> 2011-06-02 22:46 <a href="http://www.cppblog.com/ifeng/archive/2011/06/02/147984.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用静态库时函数调用指向错误。</title><link>http://www.cppblog.com/ifeng/archive/2011/05/27/147334.html</link><dc:creator>冷锋</dc:creator><author>冷锋</author><pubDate>Fri, 27 May 2011 01:23:00 GMT</pubDate><guid>http://www.cppblog.com/ifeng/archive/2011/05/27/147334.html</guid><wfw:comment>http://www.cppblog.com/ifeng/comments/147334.html</wfw:comment><comments>http://www.cppblog.com/ifeng/archive/2011/05/27/147334.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ifeng/comments/commentRss/147334.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ifeng/services/trackbacks/147334.html</trackback:ping><description><![CDATA[最近调试iphone项目时，发现使用静态库时调用函数A会直接跳到B函数去了，后来才发现原来使用静态库函数时是根据头文件的函数声明顺序去定位函数的，由于我的静态库的头文件的函数声明顺序跟使用库时添加的头文件里的函数声明顺序不一致，导致了杯具，网上搜索了下有些人说是按头文件来搜索函数的，有些人又说不是，莫非各个平台都不一样？求解答，有木有... <img src ="http://www.cppblog.com/ifeng/aggbug/147334.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ifeng/" target="_blank">冷锋</a> 2011-05-27 09:23 <a href="http://www.cppblog.com/ifeng/archive/2011/05/27/147334.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>