我承认我是Objective-C的newby,但是我想我已经走得很远了。现在我遇到问题,需要一些帮助。我需要初始化新视图吗?
在我的应用程序中,我在其他信息中以纵向模式显示图像,并希望以横向模式全屏显示它们。我知道你会这样做,定义一个Landscape m,h和nib文件,并在设备移动到横向(与观察者一起工作)时加载该视图,对吗?
在纵向模式下,图像最终取决于用户交互,因此需要告知Landscape类,要显示哪个图像。我在景观类
-(void) putImage:(NSString *)theImage {
pict.image = [UIImage imageNamed: theImage];
NSLog(@"PICT %@",pict.image);
NSLog(@"IMAGE %@",theImage);
}
创建PUTIMAGE方法,并从人像一个调用它,来这里的问题:
NSString *actualImage = [NSString stringWithFormat:@"Picture%i.jpg",selected];
pict.image = [UIImage imageNamed: actualImage];
[landscapeViewController putImage:actualImage];
,每次完美的作品,除了第一个之一。因此,无论我做什么,我都需要先让应用程序以任何方式加载新图像,并改变为横向(不显示图像)。然后,它始终显示正确的图像。
我添加了调试信息,看到正确的图像被分配到景观类中的图片 - 但它似乎需要在它真正设置图像之前显示。
任何帮助你们可以给?
向我们展示了如何初始化您的LandscapeViewController类,它是否与您在问题中提到的Landscape类相同,还是仅仅是一个视图?也需要查看代码。我怀疑你在UIView实例初始化时(如果你实际上有一个)没有为视图设置CGRect。 – Rog 2011-03-14 20:33:00
嗨。这是所有 - 在viewDidLoad的肖像:\t LandscapeViewController * viewController = [[LandscapeViewController alloc] initWithNibName:@“LandscapeView”bundle:nil]; \t自我。landscapeViewController = viewController; \t [viewController release]; 则下一个步骤是显示: 如果 \t { [自我presentModalViewController:self.landscapeViewController动画:是];}(UIDeviceOrientationIsLandscape(deviceOrientation)&& isShowingLandscapeView!) – rummsmummel 2011-03-14 21:05:22
是的,在端部的LndsacpeViewController类只具有ViewWillAppear ViewWillDisappear和putImage方法,并在xib文件中填充整个内容区域的图像。 – rummsmummel 2011-03-14 21:11:42