ios - 将 UIImage 添加到 UIAlertView 未按预期工作
<p><p>我正在开发一个应用程序。我尝试使用以下代码将 UIIMage 添加到 UIAlertView,</p>
<pre><code>UIAlertView *alert = [ initWithTitle:@"Instruction"
message:@"Please TAP on Screen to Continue."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
UIImageView *imageView = [ initWithFrame:CGRectMake(220, 50, 32, 32)];
UIImage *img = ;
;
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
;
}else{
;
}
;
</code></pre>
<p>我的图像尺寸为 32 × 32 像素。我收到如图所示的警报,</p>
<p> <a href="/image/cvvar.png" rel="noreferrer noopener nofollow"><img src="/image/cvvar.png" alt="Alert"/></a> </p>
<p>我应该为此图像添加约束吗?还是要做什么?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>可以将imageView <code>contentMode</code>设置为<code>UIViewContentModeScaleAspectFit</code>,</p>
<pre><code>UIAlertView *alert = [ initWithTitle:@"Instruction"
message:@"Please TAP on Screen to Continue."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
UIImageView *imageView = [ initWithFrame:CGRectMake(220, 50, 32, 32)];
UIImage *img = ;
imageView.contentMode = UIViewContentModeScaleAspectFit;
;
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
;
}else{
;
}
;
</code></pre>
<p> <a href="/image/IirKk.png" rel="noreferrer noopener nofollow"><img src="/image/IirKk.png" alt="enter image description here"/></a> </p>
<p>可能<strong>Anbu.Karthik</strong>建议的链接评论对您也有帮助。 </p></p>
<p style="font-size: 20px;">关于ios - 将 UIImage 添加到 UIAlertView 未按预期工作,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/42484813/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/42484813/
</a>
</p>
页:
[1]