我无法在UIButton中为xcode 7.2中的iPad设置大图像背景图像

时间:2015-12-23 14:11:54

标签: ios objective-c xcode ipad uibutton

我想使用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];
}

谢谢。

0 个答案:

没有答案