簡體   English   中英

為什么XCode存檔的行為與iPhone上的XCode構建/運行不同

[英]Why is XCode archive acting different than XCode build/run on iPhone

我有一個在XCode 4上開發的iPhone應用程序。它在以下環境中正常工作:

  1. iPhone模擬器(iOS版本5)
  2. iOS 5設備(從Archive執行)
  3. iOS 5設備(從XCode構建執行)
  4. iOS 4設備(從XCode構建執行)
  5. iOS 3設備(從XCode構建執行)

但是,當我將iOS 5中運行的存檔放在iOS 3或4設備上時,它很有趣。 從同一設備上的XCode運行時,完全相同的代碼工作正常。

當我說它表現得很有趣時,它會在錯誤的軸上動畫滑動的UIView。 在我為它制作動畫之前,我確實在UIView上執行了旋轉變換。 但同樣,它直接從XCode運行時工作正常,即使在iOS 3和4設備上也是如此。 它僅在存檔中起作用,僅適用於iOS 3和4.該存檔在iOS 5中運行良好。

旋轉是通過輔助類中的靜態調用完成的:

+ (UIImage*)rotateImage:(UIImage *)image {
CGRect             bnds = CGRectZero;
UIImage*           copy = nil;
CGContextRef       ctxt = nil;
CGImageRef         imag = image.CGImage;
CGRect             rect = CGRectZero;
CGAffineTransform  tran = CGAffineTransformIdentity;

rect.size.width  = CGImageGetWidth(imag);
rect.size.height = CGImageGetHeight(imag);

bnds = rect;

bnds = swapWidthAndHeight(bnds);
tran = CGAffineTransformMakeTranslation(rect.size.height, 0.0);
tran = CGAffineTransformRotate(tran, M_PI / 2.0);

UIGraphicsBeginImageContext(bnds.size);
ctxt = UIGraphicsGetCurrentContext();

CGContextScaleCTM(ctxt, -1.0, 1.0);
CGContextTranslateCTM(ctxt, -rect.size.height, 0.0);

CGContextConcatCTM(ctxt, tran);
CGContextDrawImage(UIGraphicsGetCurrentContext(), rect, imag);

copy = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return copy;
}

動畫由:

// The first image should fall from top.
CGRect rect = boardView.frame;
rect.origin = CGPointMake(VIEW_IMAGE_X_POS, 0);
boardView.frame = rect;
[myView addSubview:boardView];

// The starting image comes down.  Then passes control to the next animation routine for the clones.
[UIView beginAnimations:@"addStartingImage" context:boardView];
[UIView setAnimationDuration:1.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startingImageDidStop:finished:context:)];

// Add the new image
rect = boardView.frame;
rect.origin = CGPointMake(VIEW_IMAGE_X_POS, myView.contentSize.height - 108);
boardView.frame = rect;

// End the animation
[UIView commitAnimations];

其他一切都很好。 有什么想法嗎?

嘗試關閉編譯器優化。

在編譯發布版本時,舊iOS 3.x和4.x ARMv6設備上的UI出現問題。 我不明白為什么,但關閉編譯器優化將有所幫助。

關閉Thumb也可以幫助您解決此問題,您可以轉到構建設置並將鼠標懸停在“其他C標志”選項上。 單擊此選項右側顯示的小加號按鈕,為ARMv6體系結構添加條件。 再次執行此操作以為ARMv7體系結構創建一個。 在ARMv6體系結構下,添加-mno-thumb的額外編譯器標志。

Thumb已關閉ARMv6

代碼看起來很好。 我在這里看到的唯一問題是:rect.origin = CGPointMake(VIEW_IMAGE_X_POS,myView.contentSize.height - 108);

嘗試對myView.contentSize.height值進行硬編碼。 視圖/窗口可能不會根據更新的當前設備方向返回contentSize。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM