0

In an iPhone/iPad App that am developing, am rotating an imageview with this code:

   if (myOrientation == UIInterfaceOrientationPortrait) {

        NSLog(@"portrait");

        self.imageViewPic.transform = CGAffineTransformMakeRotation(degreesToRadians(0));
        self.imageViewPic.bounds = CGRectMake(0.0f, 0.0f, [[UIScreen mainScreen] bounds].size.width,  [[UIScreen mainScreen] bounds].size.height);
        self.imageViewPic.center = CGPointMake(([[UIScreen mainScreen] bounds].size.height)/2, ([[UIScreen mainScreen] bounds].size.width)/2);
        [self.imageViewPic setFrame:CGRectMake(0.0,0.0,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height)];
        self.imageViewPic.image = self.picture;

        self.imageViewBarTop.transform = CGAffineTransformMakeRotation(degreesToRadians(0));
        self.buttonHome.transform = CGAffineTransformMakeRotation(degreesToRadians(0));
       ....
    }

The imageViewPic (which is full-screen sized) does rotate, but then it occurs almost a minute 'after' I actually rotate the device (iPhone/iPad), whereas, in contrast, the other components in the screen (for example, imageViewBarTop -> which is a bar on the top of the screen, buttonHome -> which is a 'home' button) rotate instantly on rotation of the device. Why is the rotation of the imageViewPic taking so long (even though its code is actually before the code that rotates other components)? Is it because the imageViewPic occupies the entire screen? Any help is gretly appreciated.

Jean
  • 2,611
  • 8
  • 35
  • 60

1 Answers1

0

Is there a reason you're wanting to manually transform the image? If you're rotating everything in the view, you might want to just rotate the view itself and save your processor a lot of work! Just use the willAnimateRotationToInterfaceOreintation method.

Scott Hillson
  • 900
  • 1
  • 12
  • 30
  • Hi Hillsons, Thanks for your reply. The problem with the bar & Home-button is that their position changes when the view is rotated. So, I need to reposition them. So, I decided to do it myself instead of letting it to the mercy of iOS. – Jean Oct 16 '12 at 06:05
  • Another more important issue (I just recollected) was that this view is on top of certain other views. Now, shouldAutorotateToInterfaceOrientation is called only on the lowermost view (assume the views to be arranged/stacked like a pack of cards), even if I rotate the top view ; but i want the top view to rotate, but I don't support rotation in any other view (including the lowermost one). So, I had to do this explicit rotation to address this (i.e. not rotate any views beneath, but rotate just this topmost one). – Jean Oct 16 '12 at 06:10
  • I think the reason your app is running so slow is because you're trying to stack views on top of each other, the more views you display simultaneously, the slower things will become. – Scott Hillson Oct 16 '12 at 22:00
  • is it so? But then the other views aren't being 'displayed' (i.e. they are only beneath it), so they don't require any processing, right ? – Jean Oct 17 '12 at 03:42
  • but what you say seems to make some sense to me, because I when I transition between the views, I see that (during the momentary transition/swipe), the views beneath it also get displayed. – Jean Oct 17 '12 at 03:43
  • Even if other views are being 'displayed' you must design your app so that other views are unloaded, or they continue to use up processing power. Visit this thread http://stackoverflow.com/questions/1158788/when-should-i-release-objects-in-voidviewdidunload-rather-than-in-dealloc – Scott Hillson Oct 17 '12 at 04:02