下面是我的尝试。我在导航栏中添加了一个 rightBarButtonItem。然后用下面的方法连接起来。我究竟做错了什么?当我单击按钮时,该方法被调用,因为我看到了日志。调用它时没有任何可见的事情发生。但是,如果我反复单击该按钮,图像会闪烁。
- (void)rotatedImage
{
NSLog(@"rotatedImage");
id <MWPhoto> assetPhoto = [self photoAtIndex:_currentPageIndex];
UIImageOrientation imageOrientation = assetPhoto.underlyingImage.imageOrientation;
UIImageOrientation orientationToBe;
if (imageOrientation == UIImageOrientationLeft) orientationToBe = UIImageOrientationDown;
else if (imageOrientation == UIImageOrientationDown) orientationToBe = UIImageOrientationRight;
else if (imageOrientation == UIImageOrientationRight) orientationToBe = UIImageOrientationUp;
else orientationToBe = UIImageOrientationLeft;
UIImage *rotatedImage = [UIImage imageWithCGImage:[assetPhoto.underlyingImage CGImage] scale: 1 orientation:orientationToBe];
MWPhoto *r = [MWPhoto photoWithImage:rotatedImage];
[_photos replaceObjectAtIndex:_currentPageIndex withObject:r];
[self reloadData];
}