久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='w78c0'><tr id='w78c0'><dt id='w78c0'><q id='w78c0'><span id='w78c0'><b id='w78c0'><form id='w78c0'><ins id='w78c0'></ins><ul id='w78c0'></ul><sub id='w78c0'></sub></form><legend id='w78c0'></legend><bdo id='w78c0'><pre id='w78c0'><center id='w78c0'></center></pre></bdo></b><th id='w78c0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='w78c0'><tfoot id='w78c0'></tfoot><dl id='w78c0'><fieldset id='w78c0'></fieldset></dl></div>
    • <bdo id='w78c0'></bdo><ul id='w78c0'></ul>

    1. <tfoot id='w78c0'></tfoot>

        <small id='w78c0'></small><noframes id='w78c0'>

        <legend id='w78c0'><style id='w78c0'><dir id='w78c0'><q id='w78c0'></q></dir></style></legend>
      1. 來自 CGImageRef 的 UIImage

        UIImage from CGImageRef(來自 CGImageRef 的 UIImage)
          <bdo id='jbKf3'></bdo><ul id='jbKf3'></ul>
          <i id='jbKf3'><tr id='jbKf3'><dt id='jbKf3'><q id='jbKf3'><span id='jbKf3'><b id='jbKf3'><form id='jbKf3'><ins id='jbKf3'></ins><ul id='jbKf3'></ul><sub id='jbKf3'></sub></form><legend id='jbKf3'></legend><bdo id='jbKf3'><pre id='jbKf3'><center id='jbKf3'></center></pre></bdo></b><th id='jbKf3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jbKf3'><tfoot id='jbKf3'></tfoot><dl id='jbKf3'><fieldset id='jbKf3'></fieldset></dl></div>

              <legend id='jbKf3'><style id='jbKf3'><dir id='jbKf3'><q id='jbKf3'></q></dir></style></legend>

                    <tbody id='jbKf3'></tbody>
                  <tfoot id='jbKf3'></tfoot>

                  <small id='jbKf3'></small><noframes id='jbKf3'>

                  本文介紹了來自 CGImageRef 的 UIImage的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在為一個更復雜的項目嘗試一個簡單的測試,但我很困惑為什么下面的代碼會崩潰并給出 EXC_BAD_ACCESS 錯誤?

                  I am trying a simple test for a much more complex project but I am baffled as to why the code below is crashing and giving an EXC_BAD_ACCESS error?

                  這是從 UIView 調用的.

                  This is called from a UIView.

                   - (void)testing {
                        NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"ball.png" ofType:nil];
                        CGImageRef imageRef = [[[UIImage alloc]initWithContentsOfFile:imagePath]CGImage];
                   //   CGImageRetain(imageRef);
                  
                        UIImage *newImage = [[UIImage alloc]initWithCGImage:imageRef];
                        UIImageView *iv = [[UIImageView alloc]initWithImage:newImage];
                        [self addSubview:iv];
                   }
                  

                  我的猜測是 CGImageRef 沒有被保留,而是添加了 CGImageRetain(imageRef);沒有區別.

                  My guess is that the CGImageRef is not being retained but adding CGImageRetain(imageRef); makes no difference.

                  我還應該注意,這個項目已經開啟了 ARC.

                  I should also note that this project has ARC turned on.

                  編輯

                  EDIT

                  我做了更多的測試,發現這與 ARC 直接相關,因為我創建了 2 個基本項目,其中僅包括上面的代碼.第一個關閉 ARC 并且效果很好.下一個打開 ARC 并且 BAM 崩潰并出現相同的錯誤.有趣的是,我只有在崩潰前第一次運行項目時才收到實際的日志錯誤.

                  I did a little bit more testing and have discovered that this is directly related to ARC as I created 2 basic projects including only the code above. The first with ARC turned off and it worked perfectly. The next with ARC turned on and BAM crash with the same error. The interesting thing is that I got an actual log error ONLY the first time I ran the project before the crash.

                   Error: ImageIO: ImageProviderCopyImageBlockSetCallback 'ImageProviderCopyImageBlockSetCallback' header is not a CFDictionary...
                  

                  推薦答案

                  這行就是問題所在:

                  CGImageRef imageRef = [[[UIImage alloc]initWithContentsOfFile:imagePath]CGImage];
                  

                  創建的 UIImage 將在此完整表達式之后立即釋放(例如,在此行之后).因此,即使嘗試在之后添加 CGImageRetain() 也行不通.

                  The created UIImage will be released immediately following this full-expression (e.g. after this line). So even trying to add a CGImageRetain() afterwards won't work.

                  根本問題是CGImage返回的CGImageRef幾乎肯定是UIImage的一個ivar,當UIImage 被釋放.

                  The fundamental problem is the CGImageRef returned from CGImage is almost certainly an ivar of the UIImage and will be released when the UIImage is deallocted.

                  解決此問題的通用方法是延長 UIImage 的生命周期.您可以通過將 UIImage 放入局部變量并在最后一次引用 CGImage 之后引用它(例如,使用 (void)uiimageVar).或者,您可以將 CGImageRef 保留在同一行,如

                  The generic way to fix this is to extend the lifetime of the UIImage. You can do this by placing the UIImage into a local variable and referencing it after your last reference to the CGImage (e.g. with (void)uiimageVar). Alternatively, you can retain the CGImageRef on that same line, as in

                  CGImageRef imageRef = CGImageRetain([[[UIImage alloc] initWithContentsOfFile:imagePath] CGImage]);
                  

                  但如果你這樣做了,別忘了在完成后釋放 imageRef.

                  But if you do this, don't forget to release the imageRef when you're done.

                  這篇關于來自 CGImageRef 的 UIImage的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報)
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標已經包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))
                • <small id='1iDQZ'></small><noframes id='1iDQZ'>

                        • <bdo id='1iDQZ'></bdo><ul id='1iDQZ'></ul>

                          <i id='1iDQZ'><tr id='1iDQZ'><dt id='1iDQZ'><q id='1iDQZ'><span id='1iDQZ'><b id='1iDQZ'><form id='1iDQZ'><ins id='1iDQZ'></ins><ul id='1iDQZ'></ul><sub id='1iDQZ'></sub></form><legend id='1iDQZ'></legend><bdo id='1iDQZ'><pre id='1iDQZ'><center id='1iDQZ'></center></pre></bdo></b><th id='1iDQZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1iDQZ'><tfoot id='1iDQZ'></tfoot><dl id='1iDQZ'><fieldset id='1iDQZ'></fieldset></dl></div>

                        • <tfoot id='1iDQZ'></tfoot>
                            <tbody id='1iDQZ'></tbody>

                          <legend id='1iDQZ'><style id='1iDQZ'><dir id='1iDQZ'><q id='1iDQZ'></q></dir></style></legend>
                          1. 主站蜘蛛池模板: 午夜精品一区二区三区在线视 | 亚洲国产精品日韩av不卡在线 | 亚洲欧美一区二区三区1000 | 久久国产一区 | 欧美激情在线精品一区二区三区 | 欧美一区二区三区日韩 | 久久天堂网 | 操皮视频| 国产一区二区三区久久久久久久久 | 欧美成人免费在线视频 | 久久99国产精品 | 国产欧美一区二区三区在线看 | 青青草视频网 | 日韩国产欧美 | 中文字幕一区二区三区精彩视频 | 波多野结衣一区二区三区 | 在线午夜| www.一区二区 | av网站在线看 | 亚洲黄色视屏 | 日韩美av| 国产精品久久久久久影视 | 尤物在线精品视频 | 偷拍亚洲色图 | 久久久亚洲精品视频 | 亚洲91| 丁香六月激情 | 99亚洲综合 | 精品国产一区久久 | 久久九九网站 | 午夜丁香视频在线观看 | 国产精品麻 | 亚洲高清一区二区三区 | 国外成人在线视频网站 | 亚洲一区二区三区免费在线观看 | 范冰冰一级做a爰片久久毛片 | a级片在线观看 | 日韩一区二区免费视频 | 欧美黄色精品 | 亚洲一区二区免费视频 | 欧美专区在线观看 |