0
我試圖檢查圖像的當前方向並將其翻轉到與當前的相反。iOS:如何根據當前方向翻轉圖像?
如果我的屏幕上只有一個元素,此代碼有效,但只要我增加了陣列的50/50獲取方向權限的機會。
-(IBAction)flipBtn:(id)sender
{
UIImage* flippedImage;
if(flipBtn.tag==FLIP_BUTTON_TAG)
{
UIImage* sourceImage1 = self.outletImageView.image;
flippedImage = [UIImage imageWithCGImage:sourceImage1.CGImage scale:1.0 orientation: UIImageOrientationUpMirrored];
flipBtn.tag = FLIP_VUTTON_TAG2;
}else{
UIImage* sourceImage1 = self.outletImageView.image;
flippedImage = [UIImage imageWithCGImage:sourceImage1.CGImage scale:1.0 orientation: UIImageOrientationUp];
flipBtn.tag = FLIP_BUTTON_TAG;
}
NSInteger index1 = [imgViewArray indexOfObject:self.outletImageView];
[imgViewArray removeObject:self.outletImageView];
self.outletImageView.image = flippedImage;
[imgViewArray insertObject:self.outletImageView atIndex:index1];
}
這並沒有解決問題,它仍然沒有檢測到當前的方向,然後鏡像它。這是以與以前完全相同的方式工作 –
請參閱更新的答案。 – Winston