Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm

Issue 2828743002: LabelObserver is no longer retained by the label (Closed)
Patch Set: Address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/ui/util/CRUILabel+AttributeUtils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm
diff --git a/ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm b/ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm
index e57276250466c666058b8103361a34fe9bc2966e..b010c60b5a178015fa58ab8665ed856daccaa6f6 100644
--- a/ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm
+++ b/ios/chrome/browser/ui/first_run/welcome_to_chrome_view.mm
@@ -14,6 +14,7 @@
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/chrome/browser/ui/util/CRUILabel+AttributeUtils.h"
#import "ios/chrome/browser/ui/util/label_link_controller.h"
+#import "ios/chrome/browser/ui/util/label_observer.h"
#include "ios/chrome/common/string_util.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h"
@@ -92,8 +93,12 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
@property(strong, nonatomic, readonly) UIImageView* imageView;
// The "Terms of Service" label.
@property(strong, nonatomic, readonly) UILabel* TOSLabel;
+// Observer for setting the size of the TOSLabel with cr_lineHeight.
+@property(strong, nonatomic) LabelObserver* TOSObserver;
// The stats reporting opt-in label.
@property(strong, nonatomic, readonly) UILabel* optInLabel;
+// Observer for setting the size of the optInLabel with cr_lineHeight.
+@property(strong, nonatomic) LabelObserver* optInObserver;
// The stats reporting opt-in checkbox button.
@property(strong, nonatomic, readonly) UIButton* checkBoxButton;
// The "Accept & Continue" button.
@@ -135,6 +140,8 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
@implementation WelcomeToChromeView
@synthesize delegate = _delegate;
+@synthesize TOSObserver = _TOSObserver;
+@synthesize optInObserver = _optInObserver;
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
@@ -179,6 +186,11 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
completion:nil];
}
+- (void)dealloc {
+ [self.TOSObserver stopObserving];
+ [self.optInObserver stopObserving];
+}
+
#pragma mark - Accessors
- (BOOL)isCheckBoxSelected {
@@ -223,6 +235,10 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
- (UILabel*)TOSLabel {
if (!_TOSLabel) {
_TOSLabel = [[UILabel alloc] initWithFrame:CGRectZero];
+ // Add an observer to the label to be able to keep the cr_lineHeight.
+ self.TOSObserver = [LabelObserver observerForLabel:_TOSLabel];
+ [self.TOSObserver startObserving];
+
[_TOSLabel setNumberOfLines:0];
[_TOSLabel setTextAlignment:NSTextAlignmentCenter];
}
@@ -232,6 +248,10 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
- (UILabel*)optInLabel {
if (!_optInLabel) {
_optInLabel = [[UILabel alloc] initWithFrame:CGRectZero];
+ // Add an observer to the label to be able to keep the cr_lineHeight.
+ self.optInObserver = [LabelObserver observerForLabel:_optInLabel];
+ [self.optInObserver startObserving];
+
[_optInLabel setNumberOfLines:0];
[_optInLabel
setText:l10n_util::GetNSString(IDS_IOS_FIRSTRUN_NEW_OPT_IN_LABEL)];
« no previous file with comments | « no previous file | ios/chrome/browser/ui/util/CRUILabel+AttributeUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698