2010-11-22 304 views
3

如何讓objecive-C圖像尺寸,圖像尺寸,

我使用imagePicker加載一個形象,我想知道,圖像的尺寸。 (w * h)

是否可能。 ?

感謝&問候...

回答

8

您實現UIImagePickerControllerDelegate Protocol,特別是imagePickerController:didFinishPickingMediaWithInfo:方法。該方法的最後一個參數是一個包含UIImagePickerControllerOriginalImage鍵的UImage引用的字典。獲取此UIImage *並獲取它的size屬性。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 

    UIImage *image = (UIImage*) [info objectForKey:UIImagePickerControllerOriginalImage]; 
    //access width and height like this 
    image.size.width; 
    image.size.height; 
}