gpt4 book ai didi

iphone - iOS iphone uialertview 在横向添加了另一个 TextView

转载 作者:行者123 更新时间:2023-11-29 04:35:43 24 4
gpt4 key购买 nike

我目前正在使用一个警报 View ,其中有一个 TextView ,但是当我将 iPhone 旋转到横向时,会发生一些奇怪的事情,另一个 TextView 似乎出现在警报 View 上。 iPad 上不会出现此问题。有谁知道这可能是什么原因造成的?任何建议或帮助将不胜感激。

我的代码放置在应用程序委托(delegate)中,并在下面列出,

- (IBAction) loadAboutUs 
{
UIAlertView *showSelection;
showSelection.delegate = self;
NSString *key = [NSString stringWithFormat: @"Drug Tariff\n"
@"Version: %@\n"
@"text\n\n"
@"text\n"
@"text\n"
@"text", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
showSelection = [[UIAlertView alloc]
initWithTitle: @""
message: @"\n\n\n\n\n\n\n\n\n\n"//The new lines are used to increase the size of the pop-up
delegate: nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil];

//The text view inserted into the alertview
UITextView *myTextView = [[UITextView alloc] initWithFrame:CGRectMake(12.0, 15.0, 260.0, 210.0)];
myTextView.text = key;
myTextView.dataDetectorTypes = UIDataDetectorTypeAll;//set the textview to pick up all link types
[myTextView setFont:[UIFont fontWithName:@"ArialMT" size:16]];
myTextView.textAlignment = UITextAlignmentCenter;
myTextView.editable = false;//the textview needs to be uneditable for the dataDectector to work
myTextView.scrollEnabled = true;
[myTextView setBackgroundColor:[UIColor whiteColor]];
[showSelection addSubview:myTextView];

[showSelection show];
}

我已附上该问题的图片,

Alertview issue

更新:

运行下面的代码时得到的输出,

NSArray *subviews = [showSelection subviews];
for (UIView *view in subviews)
{
NSLog(@"class %@, tag: %i", [view class], view.tag);
}

Landscape
2012-06-18 17:56:43.906 TS Data[6513:b903] class UIImageView, tag: 0
2012-06-18 17:56:43.907 TS Data[6513:b903] class UILabel, tag: 0
2012-06-18 17:56:43.908 TS Data[6513:b903] class UILabel, tag: 0
2012-06-18 17:56:43.908 TS Data[6513:b903] class UIThreePartButton, tag: 1
2012-06-18 17:56:43.909 TS Data[6513:b903] class UITextView, tag: 1000
2012-06-18 17:56:43.910 TS Data[6513:b903] class UIAlertTextView, tag: 12345
2012-06-18 17:56:43.910 TS Data[6513:b903] class UIImageView, tag: 3334

Portrait
2012-06-18 17:56:38.035 TS Data[6513:b903] class UIImageView, tag: 0
2012-06-18 17:56:38.053 TS Data[6513:b903] class UILabel, tag: 0
2012-06-18 17:56:38.054 TS Data[6513:b903] class UILabel, tag: 0
2012-06-18 17:56:38.055 TS Data[6513:b903] class UIThreePartButton, tag: 1
2012-06-18 17:56:38.055 TS Data[6513:b903] class UITextView, tag: 1000

最佳答案

您只需在初始化 UIAlertView 时更改“message”属性:

showSelection = [[UIAlertView alloc] 
initWithTitle: @""
message: @""
delegate: nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil];

请注意,如果您想调整 UIAlertView 的大小,您可以在 View Controller 中使用以下代码:

- (void) willPresentAlertView:(UIAlertView *)alertView
{
alertView.frame = CGRectMake(0, 0, 150, 250);
}

关于iphone - iOS iphone uialertview 在横向添加了另一个 TextView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11084919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com