我有一个有三个视图的基本应用程序,第一个视图,初始视图,有一个带有320 x 460(Ive也尝试过320 x 480)图像的ImageView,用作视图的背景图像。状态栏已启用。当我在手机上测试应用程序时,图像会在应用程序首次加载时调整大小,并最终进行缩放以适应屏幕。我的图像尺寸出了什么问题?由于图像调整大小,应用程序首次加载时,初始视图似乎“跳转”,我不希望用户认为存在问题。
这是我的故事板:
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="vni-Jh-JGC" userLabel="First Responder" sceneMemberID="firstResponder"/>
<viewController id="gWY-GQ-C35" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="e8S-C8-ddz">
<rect key="frame" x="0.0" y="20" width="320" height="460"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView autoresizesSubviews="NO" userInteractionEnabled="NO" contentMode="scaleToFill" image="targetbg.png" id="s7d-M3-VIr">
<rect key="frame" x="-1" y="0.0" width="320" height="460"/>
<autoresizingMask key="autoresizingMask"/>
<rect key="contentStretch" x="0.0" y="0.0" width="0.0" height="0.0"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="uF7-4u-0PX">
<rect key="frame" x="14" y="417" width="300" height="38"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" image="newsubmit.png">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<segue destination="2" kind="modal" id="Qkv-0y-8Sh"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Blake Design Group" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="Am2-mX-6Yv">
<rect key="frame" x="22" y="386" width="280" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="10"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="version 2.0" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="Buw-jD-jIs">
<rect key="frame" x="16" y="374" width="280" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="10"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<nil key="simulatedTopBarMetrics"/>
<simulatedOrientationMetrics key="simulatedOrientationMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics"/>
</viewController>
</objects>
答案 0 :(得分:0)
我会假设您正在尝试创建启动画面 以下是我为iPhone和iPad设置启动画面所做的工作
UIView
(我的启动视图)而不是UIViewController
UIImageView
,imageView尺寸为320 * 460,y设为-10 UIImageView
和容器UIView
将调整大小掩码设置为0(根本没有调整大小)UIImageView
的内容设置为center
willMoveToSuperview
我有以下
- (void)willMoveToSuperview:(UIView *)newSuperview
{
BOOL isiPad = UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM();
if(isiPad)
{
mainImage.image = [UIImage newImageFromResource:@"Default-Portrait~ipad.png"];
}
else {
mainImage.image = [UIImage newImageFromResource:@"Default"];
}
}
现在在didFinishLaunchingWithOptions
我创建此视图并将其添加到self.window.rootViewController
[self.window.rootViewController.view addSubview:splashScreen];
splashScreen.frame = self.window.rootViewController.view.bounds;
splashScreen.autoresizingMask = AUTORESIZE_ALL;
[splashScreen initialize];
这在我的方向和iPad和iPhone中都有用,
注意:我使用相同的default.png图像来创建启动
答案 1 :(得分:0)
我终于明白了,它很简单。我的启动图像是480,而我的bg图像是460.这在加载过程中引起了短暂的重叠,并创建了一个看似调整大小/重新调整大小的内容。今天吸取的教训很好。