NewsBlur: fixed #782 (new account recommended sites misaligned; now using autolayout)

This commit is contained in:
David Sinclair 2015-10-26 13:29:07 -07:00
parent f053eafa0f
commit 2e6f948893
3 changed files with 75 additions and 271 deletions

View file

@ -20,7 +20,6 @@
@property (nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (nonatomic) IBOutlet UILabel *instructionLabel;
@property (nonatomic) IBOutlet UITableView *categoriesTable;
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
- (IBAction)tapNextButton;
- (void)tapGoogleReaderButton;

View file

@ -31,7 +31,6 @@
@synthesize activityIndicator;
@synthesize instructionLabel;
@synthesize categoriesTable;
@synthesize scrollView;
@synthesize googleReaderButtonWrapper;
@synthesize importedFeedCount_;
@synthesize currentButton_;
@ -83,16 +82,8 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
CGFloat width = CGRectGetWidth(self.view.frame);
[self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone];
[self.categoriesTable reloadData];
[self.scrollView setContentSize:CGSizeMake(width, self.tableViewHeight + 40)];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self.categoriesTable.frame = CGRectMake((width - 300)/2, 30, self.categoriesTable.frame.size.width, self.tableViewHeight);
} else {
self.categoriesTable.frame = CGRectMake(10, 30, width-10*2, self.tableViewHeight);
}
NSLog(@"%f height", self.tableViewHeight);
}
@ -103,7 +94,6 @@
[self setInstructionLabel:nil];
[self setCategoriesTable:nil];
[self setGoogleReaderButton:nil];
[self setScrollView:nil];
[self setNextButton:nil];
}
@ -305,22 +295,18 @@
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 26;
return 26.0;
}
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == 0) {
return 28.0;
}
return 54.0;
return 30.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CGFloat width = CGRectGetWidth(self.view.frame) - 20;
if (section == 0) {
UIView* categoryTitleView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 20.0, width, 34.0)];
UILabel *categoryTitleLabel = [[UILabel alloc] initWithFrame:categoryTitleView.frame];
UIView* categoryTitleView = [UIView new];
UILabel *categoryTitleLabel = [UILabel new];
categoryTitleLabel.translatesAutoresizingMaskIntoConstraints = NO;
categoryTitleLabel.text = @"You can always add your own individual sites.";
categoryTitleLabel.font = [UIFont fontWithName:@"Helvetica" size:14];
[categoryTitleView addSubview:categoryTitleLabel];
@ -329,21 +315,24 @@
categoryTitleView.backgroundColor = [UIColor clearColor];
categoryTitleLabel.textAlignment = NSTextAlignmentCenter;
[NSLayoutConstraint constraintWithItem:categoryTitleLabel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:categoryTitleView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0].active = YES;
[NSLayoutConstraint constraintWithItem:categoryTitleLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:categoryTitleView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0].active = YES;
return categoryTitleView;
}
// create the parent view that will hold header Label
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, width, 34.0)];
UIView* customView = [UIView new];
customView.tag = section;
UIImage *buttonImage =[[UIImage imageNamed:@"google.png"]
stretchableImageWithLeftCapWidth:5.0 topCapHeight:0.0];
UIButton *headerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
headerBtn.translatesAutoresizingMaskIntoConstraints = NO;
headerBtn.tag = section + 1000;
[headerBtn setBackgroundImage:buttonImage forState:UIControlStateNormal];
headerBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
headerBtn.frame = CGRectMake(0, 20.0, width, 34.0);
headerBtn.titleLabel.shadowColor = UIColorFromRGB(0x1E5BDB);
headerBtn.titleLabel.shadowOffset = CGSizeMake(0, 1);
NSString *categoryTitle;
@ -353,22 +342,31 @@
BOOL inSelect = [self.selectedCategories_
containsObject:[NSString stringWithFormat:@"%@", [category objectForKey:@"title"]]];
NSLog(@"inselected %i", inSelect);
if (inSelect) {
headerBtn.selected = YES;
UIImage *checkmark = [UIImage imageNamed:@"258-checkmark"];
UIImageView *checkmarkView = [[UIImageView alloc] initWithImage:checkmark];
checkmarkView.frame = CGRectMake(headerBtn.frame.origin.x + headerBtn.frame.size.width - 24,
8,
16,
16);
checkmarkView.translatesAutoresizingMaskIntoConstraints = NO;
checkmarkView.tag = 100;
[headerBtn addSubview:checkmarkView];
NSDictionary *views = @{@"checkmark" : checkmarkView};
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[checkmark(16)]-10-|" options:0 metrics:nil views:views]];
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[checkmark(16)]" options:0 metrics:nil views:views]];
[NSLayoutConstraint constraintWithItem:checkmarkView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:headerBtn attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0].active = YES;
}
[headerBtn setTitle:categoryTitle forState:UIControlStateNormal];
[headerBtn addTarget:self action:@selector(addCategory:) forControlEvents:UIControlEventTouchUpInside];
[customView addSubview:headerBtn];
NSDictionary *views = @{@"button" : headerBtn, @"customView" : customView};
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[button]-0-|" options:0 metrics:nil views:views]];
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[button]-0-|" options:0 metrics:nil views:views]];
return customView;
}

View file

@ -1,244 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">2048</int>
<string key="IBDocument.SystemVersion">13F34</string>
<string key="IBDocument.InterfaceBuilderVersion">6245</string>
<string key="IBDocument.AppKitVersion">1265.21</string>
<string key="IBDocument.HIToolboxVersion">698.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">6238</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUILabel</string>
<string>IBUIScrollView</string>
<string>IBUITableView</string>
<string>IBUIView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="IBProxyObject" id="841351856">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBProxyObject" id="606714003">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBUIView" id="874391841">
<nil key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUIScrollView" id="75178207">
<reference key="NSNextResponder" ref="874391841"/>
<int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUITableView" id="1020189204">
<reference key="NSNextResponder" ref="75178207"/>
<int key="NSvFlags">272</int>
<string key="NSFrame">{{32, 50}, {477, 490}}</string>
<reference key="NSSuperview" ref="75178207"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MCAwAA</bytes>
</object>
<bool key="IBUIClipsSubviews">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBUIAlwaysBounceVertical">YES</bool>
<bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
<bool key="IBUIShowsVerticalScrollIndicator">NO</bool>
<int key="IBUIStyle">1</int>
<int key="IBUISeparatorStyle">2</int>
<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">44</float>
<float key="IBUISectionHeaderHeight">10</float>
<float key="IBUISectionFooterHeight">10</float>
</object>
<object class="IBUILabel" id="482977125">
<reference key="NSNextResponder" ref="75178207"/>
<int key="NSvFlags">303</int>
<string key="NSFrame">{{0, 12}, {540, 42}}</string>
<reference key="NSSuperview" ref="75178207"/>
<reference key="NSNextKeyView" ref="1020189204"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<string key="IBUIText">Subscribe to recommended sites:</string>
<object class="NSColor" key="IBUITextColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAAA</bytes>
<string key="IBUIColorCocoaTouchKeyPath">darkTextColor</string>
</object>
<nil key="IBUIHighlightedColor"/>
<object class="NSColor" key="IBUIShadowColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<string key="IBUIShadowOffset">{0, 1}</string>
<int key="IBUIBaselineAdjustment">0</int>
<float key="IBUIMinimumFontSize">10</float>
<int key="IBUINumberOfLines">2</int>
<int key="IBUITextAlignment">1</int>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">1</int>
<double key="pointSize">22</double>
</object>
<object class="NSFont" key="IBUIFont">
<string key="NSName">HelveticaNeue</string>
<double key="NSSize">22</double>
<int key="NSfFlags">16</int>
</object>
<double key="preferredMaxLayoutWidth">540</double>
</object>
</array>
<string key="NSFrameSize">{540, 540}</string>
<reference key="NSSuperview" ref="874391841"/>
<reference key="NSNextKeyView" ref="482977125"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
</array>
<string key="NSFrame">{{0, 44}, {540, 540}}</string>
<reference key="NSNextKeyView" ref="75178207"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">2</int>
<bytes key="NSRGB">MC45MDk4MDM5ODY1IDAuOTE3NjQ3MTIzMyAwLjg5NDExNzcxMwA</bytes>
</object>
<object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
<bool key="IBUIPrompted">NO</bool>
</object>
<object class="IBUISimulatedSizeMetrics" key="IBUISimulatedDestinationMetrics">
<string key="IBUISimulatedSizeMetricsClass">IBUISimulatedFreeformSizeMetricsSentinel</string>
<string key="IBUIDisplayName">Freeform</string>
</object>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="874391841"/>
</object>
<int key="connectionID">130</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">categoriesTable</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="1020189204"/>
</object>
<int key="connectionID">161</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">scrollView</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="75178207"/>
</object>
<int key="connectionID">169</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">instructionLabel</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="482977125"/>
</object>
<int key="connectionID">171</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="841351856"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="606714003"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">129</int>
<reference key="object" ref="874391841"/>
<array class="NSMutableArray" key="children">
<reference ref="75178207"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">168</int>
<reference key="object" ref="75178207"/>
<array class="NSMutableArray" key="children">
<reference ref="482977125"/>
<reference ref="1020189204"/>
</array>
<reference key="parent" ref="874391841"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">170</int>
<reference key="object" ref="482977125"/>
<reference key="parent" ref="75178207"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">160</int>
<reference key="object" ref="1020189204"/>
<reference key="parent" ref="75178207"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">FirstTimeUserAddSitesViewController</string>
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="129.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="160.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<reference key="168.IBNSViewMetadataGestureRecognizers" ref="0"/>
<string key="168.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="170.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">171</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBIPadFramework</string>
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">NO</bool>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="4600" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="FirstTimeUserAddSitesViewController">
<connections>
<outlet property="categoriesTable" destination="160" id="161"/>
<outlet property="instructionLabel" destination="170" id="171"/>
<outlet property="view" destination="129" id="130"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="129">
<rect key="frame" x="0.0" y="0.0" width="540" height="540"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Subscribe to recommended sites:" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" minimumFontSize="10" preferredMaxLayoutWidth="540" translatesAutoresizingMaskIntoConstraints="NO" id="170">
<rect key="frame" x="0.0" y="12" width="540" height="28"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<color key="shadowColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="shadowOffset" width="0.0" height="1"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" translatesAutoresizingMaskIntoConstraints="NO" id="160">
<rect key="frame" x="30" y="40" width="480" height="475"/>
<animations/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tableView>
</subviews>
<animations/>
<color key="backgroundColor" red="0.90980398650000005" green="0.91764712329999998" blue="0.89411771299999998" alpha="1" colorSpace="deviceRGB"/>
<constraints>
<constraint firstItem="170" firstAttribute="leading" secondItem="129" secondAttribute="leading" id="0Gh-7n-ZO5"/>
<constraint firstAttribute="trailing" secondItem="170" secondAttribute="trailing" id="0uM-Nx-AOO"/>
<constraint firstAttribute="trailing" secondItem="160" secondAttribute="trailing" constant="30" id="FPV-8k-kdF"/>
<constraint firstItem="170" firstAttribute="top" secondItem="129" secondAttribute="top" constant="12" id="H9Y-qc-VLb"/>
<constraint firstAttribute="bottom" secondItem="160" secondAttribute="bottom" constant="25" id="NyO-u2-i76"/>
<constraint firstItem="160" firstAttribute="leading" secondItem="129" secondAttribute="leading" constant="30" id="RXu-fj-og3"/>
<constraint firstItem="160" firstAttribute="top" secondItem="170" secondAttribute="bottom" id="TzS-W7-IfU"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<nil key="simulatedTopBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
</document>