Ios 以编程方式设置图像视图而用户看不到它的更改?
我一直在尝试设置一个imageView,当用户从横向模式旋转到纵向模式时,不会看到它的变化 在Ios 以编程方式设置图像视图而用户看不到它的更改?,ios,uiimage,tablefooterview,Ios,Uiimage,Tablefooterview,我一直在尝试设置一个imageView,当用户从横向模式旋转到纵向模式时,不会看到它的变化 在willanimaterotationInterfaceoOrientation方法中,我将图像重新设置为适当的图像(取决于它是处于横向模式还是纵向模式: if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { NSLog(@"Going to Portrait Mode."); UIImage *footerI
willanimaterotationInterfaceoOrientation
方法中,我将图像重新设置为适当的图像(取决于它是处于横向模式还是纵向模式:
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
NSLog(@"Going to Portrait Mode.");
UIImage *footerImage = [UIImage imageNamed:@"SchoolImageLandscape.png"];
UIImageView *fView = [[UIImageView alloc] initWithImage:footerImage];
[self.tableView setTableFooterView:fView];
} else if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
NSLog(@"Portrait Mode");
UIImage *footerImage = [UIImage imageNamed:@"SchoolImage.png"];
UIImageView *fView = [[UIImageView alloc] initWithImage:footerImage];
[self.tableView setTableFooterView:fView];
}
但是,我在确定如何在用户看不到更改的地方进行更改时遇到了一些问题。这意味着当它旋转时,您会看到较大的图像变为较小的图像。我不希望出现这种情况
有人知道如何使转换更加用户友好吗?我也尝试过设置imageView
didRotateFromInterfaceOrientation
方法,但没有更好的效果。好的,我不知道是否有更好的方法
我所做的:
在WillAnimateRotationInterfaceOrientation方法中,我通过执行以下操作隐藏了TableFooter视图:
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
// hide the footer image so that the user doesn't see
// the image go from large image (landscape) to a smaller image
self.tableView.tableFooterView.hidden = YES;
}
然后在,didRotateFromInterfaceOrientation
方法中,我决定
if (UIInterfaceOrientationIsLandscape(fromInterfaceOrientation)) {
NSLog(@"Going to Portrait Mode.");
UIImage *footerImage = [UIImage imageNamed:@"SchoolImage.png"];
UIImageView *fView = [[UIImageView alloc] initWithImage:footerImage];
[self.tableView setTableFooterView:fView];
// unhide the footer
self.tableView.tableFooterView.hidden = NO;
// set the alpha to 0 so you can't see it immediately
fView.alpha = 0.0f;
// Fade in the image
[UIView transitionWithView:fView
duration:1.0f
options:0
animations:^{
fView.alpha = 1.0f;
} completion:nil];
}
这使得转换看起来好多了
希望这对某人有所帮助。如果有人有更好的想法,请随时回答问题
谢谢!!!=)