2012-02-20 78 views
0

任何人都可以告訴我如何設置UIImage的方向。這是如果我的UIImage方向是UIImageOrientationDown然後我想要將其更改爲UIImageOrientationUp在iPhone/iPad中更改UIImage的方向

任何人都可以請告訴我如何實現這一點。

我已經搜索了很多,但直到現在我只找到關於如何獲得圖像的方向。

回答

0

嘗試: -

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
           duration:(NSTimeInterval)duration { 

    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {   
     yourImage.transform = CGAffineTransformMakeRotation(M_PI/2); 
    } 
    else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){ 
     yourImage.transform = CGAffineTransformMakeRotation(-M_PI/2); 
    } 
    else { 
     yourImage.transform = CGAffineTransformMakeRotation(0.0); 
    } 
} 
+0

這是UIImage的代表? – Shah 2012-02-20 05:05:19

+0

@sHaH .. Nup .... UIViewController的...它會檢測到方向改變事件 – Maulik 2012-02-20 05:22:54

+0

啊...不幫忙的兄弟。 ( – Shah 2012-02-20 05:24:04