我目前正在使用一个带有 textview 的警报视图,但是当我将 iPhone 旋转到横向时发生了一些奇怪的事情,另一个 textview 似乎出现在警报视图上。这个问题在 iPad 上不会发生。有谁知道这可能是什么原因造成的?任何建议或帮助将不胜感激。
我的代码放置在应用程序委托中,并在下面列出,
- (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];
}
我附上了这个问题的图片,
更新:
当我运行下面的代码时得到的输出,
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