2011-12-05 51 views

回答

0

,當你選擇從選擇器中的圖像,它應該returt UIImage類型。只是將它設置爲圖像的任何UIView的sublass(按鈕是UIView的子類也是如此):

[yourUIImageView setImage:UIImageFronUIPicker]; 
[yourUIButton setBackgroundImage:UIImageFronUIPicker]; 

等等...

0

你看看UIImageViewcontentMode財產。

typedef enum { 
    UIViewContentModeScaleToFill, 
    UIViewContentModeScaleAspectFit, 
    UIViewContentModeScaleAspectFill, 
    UIViewContentModeRedraw, 
    UIViewContentModeCenter, 
    UIViewContentModeTop, 
    UIViewContentModeBottom, 
    UIViewContentModeLeft, 
    UIViewContentModeRight, 
    UIViewContentModeTopLeft, 
    UIViewContentModeTopRight, 
    UIViewContentModeBottomLeft, 
    UIViewContentModeBottomRight, 
} UIViewContentMode; 
0

實現您的視圖控制器UIImagePickerControllerDelegate並實施以下

委託方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { 

    [selectedImageBtn setImage:image forState:UIControlStateNormal]; 
    [[imagePicker parentViewController] dismissModalViewControllerAnimated:YES]; 

} 
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { 
    [[imagePicker parentViewController] dismissModalViewControllerAnimated:YES]; 
}