我想使用xcode 7.2在目标C中设置UIButton内的背景图像。 它在iPhone和iPod上工作得非常好,但在iPad上它不能满足我的要求。 我认为原因是iPad中的图像太大了。 这是我的代码。
-(void) showImagePickerController {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:imagePicker animated:YES completion:nil];
}
- (void)imagePickerController:(UIImagePickerController )picker didFinishPickingImage:(UIImage )image editingInfo:(NSDictionary<NSString ,id> )editingInfo {
tempImage = image;
[self showResult];
[picker dismissViewControllerAnimated:YES completion:nil];
}
- (void) showResult {
[button setBackgroundImage:tempImage forState:UIControlStateNormal];
}
谢谢。