Below is my attempt. I added a rightBarButtonItem to the navigation bar. Then connected it with the method below. What am I doing wrong? When I click the button, the method is called, because I see the log. Nothing visible happens when it is called. If I click the button repeatedly, the image flickers however.
- (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];
}
is it possible that the
-(MWPhoto *) photoWithImage
method doesn't read the orientation property of the UIImage? i would try rotating the image by drawing it into a rotated image context and then extracting the rotated image from the context. check out this thread: Creating a UIImage from a rotated UIImageView