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

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: Update comment 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
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..d88705ca9b307ddea587fc0555c0a012c876f8ba 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;
+@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;
+@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,8 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
- (UILabel*)TOSLabel {
if (!_TOSLabel) {
_TOSLabel = [[UILabel alloc] initWithFrame:CGRectZero];
+ self.TOSObserver = [LabelObserver observerForLabel:_TOSLabel];
+ [self.TOSObserver startObserving];
marq (ping after 24h) 2017/04/19 15:25:19 What do these observers do? This CL doesn't add an
gambard 2017/04/19 15:48:18 The actions are added in CRUILabel+AttributeUtils.
marq (ping after 24h) 2017/04/20 11:52:00 Yeah, that's non-obvious and kind of clunky.
[_TOSLabel setNumberOfLines:0];
[_TOSLabel setTextAlignment:NSTextAlignmentCenter];
}
@@ -232,6 +246,8 @@ NSString* const kCheckBoxCheckedImageName = @"checkbox_checked";
- (UILabel*)optInLabel {
if (!_optInLabel) {
_optInLabel = [[UILabel alloc] initWithFrame:CGRectZero];
+ 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/label_link_controller.h » ('j') | ios/chrome/browser/ui/util/label_observer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698