我有一個模板測驗應用程序,它已經在應用商店中以各種形式出現了一段時間,總的來說它收到了很好的評價並且沒有錯誤報告。僅iOS 8.1間歇性地顯示UITextView
最近我有兩個錯誤報告,人們使用iOS 8.1.2或8.1.3的iPad,並說現在和我用來顯示問題的UITextView是空白的。
我一直無法複製這個錯誤,但如果有人能夠闡明這個錯誤,我將不勝感激。
對象questions
和userAnswer
不是零,所以它肯定是一個UITextView問題。
該控制器是在這裏:
@interface ReviewController() @property (strong, nonatomic) IBOutlet UITextView *output; @end @implementation ReviewController - (void)viewDidLoad { [super viewDidLoad]; [self setReviewText]; // Do any additional setup after loading the view. } -(void)setReviewText{ NSArray* questions = [[NSArray alloc] init]; questions = [_manager getAllQuestions]; NSMutableArray* userAnswer = [[NSMutableArray alloc] init]; userAnswer = [self answersAttributed]; if(questions == nil) _output.text = @"Questions Error"; if (userAnswer == nil) { _output.text = @"Error"; } NSMutableAttributedString *mutableAttString = [[NSMutableAttributedString alloc] init]; int i = 0; NSAttributedString *linebreak =[[NSAttributedString alloc] initWithString:@"\n"]; for (Question* q in questions) { if (i == [userAnswer count]) break; NSAttributedString *qtext =[[NSAttributedString alloc] initWithString:q.questionText]; NSAttributedString *ctext =[[NSAttributedString alloc] initWithString:@"Correct Answer:\n"]; NSAttributedString *atext =[[NSAttributedString alloc] initWithString:q.answerText]; NSAttributedString *ytext =[[NSAttributedString alloc] initWithString:@"Your Answer:\n"]; NSAttributedString *utext =[[NSAttributedString alloc] initWithAttributedString:userAnswer[i]]; [mutableAttString appendAttributedString:qtext]; [mutableAttString appendAttributedString:linebreak]; [mutableAttString appendAttributedString:ctext]; [mutableAttString appendAttributedString:atext]; [mutableAttString appendAttributedString:linebreak]; [mutableAttString appendAttributedString:ytext]; [mutableAttString appendAttributedString:utext]; [mutableAttString appendAttributedString:linebreak]; [mutableAttString appendAttributedString:linebreak]; i++; } NSAttributedString* outText = [[NSAttributedString alloc] init]; outText = [mutableAttString mutableCopy]; _output.attributedText = outText; [_output setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]]; } -(NSMutableArray*)answersAttributed { NSMutableArray* ansAtt = [[NSMutableArray alloc] init]; NSArray* questions = [[NSArray alloc] init]; questions = [_manager getAllQuestions]; NSArray* userAnswers = [[NSArray alloc] init]; userAnswers = [_manager getAllUserAnswers]; if ([questions count] != [userAnswers count]) { return ansAtt; } int i = 0; for (NSString* userAnswer in userAnswers) { if([[questions[i] answerText] isEqualToString:userAnswer]) { NSDictionary *attributes = @{NSBackgroundColorAttributeName:[UIColor greenColor]}; NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:userAnswer attributes:attributes]; [ansAtt addObject:attrString]; } else { NSDictionary *attributes = @{NSBackgroundColorAttributeName:[UIColor redColor]}; NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:userAnswer attributes:attributes]; [ansAtt addObject:attrString]; } i++; } return ansAtt; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Make sure your segue name in storyboard is the same as this line if ([[segue identifier] isEqualToString:@"review2results"]) { // Get reference to the destination view controller ReviewController *vc = [segue destinationViewController]; // Pass any objects to the view controller here, like... [vc setManager:_manager]; } }
是否使用自動版式?它可能與旋轉有關 - 比如說如果在問題加載時旋轉設備? – brandonscript 2015-02-09 21:54:18
我正在使用AutoLayout,但我已將應用程序配置爲只能在縱向模式下工作。有人說,大約50%的時間'UITextView'沒有出現,似乎他們每次都在旋轉,但我會問。感謝您的建議。 – James 2015-02-09 21:56:34
是的,這聽起來不太可能! – brandonscript 2015-02-09 21:57:11