Skip to content

Commit

Permalink
Fix accounts view bug when rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
poetwang committed Dec 6, 2016
1 parent 3fac634 commit 34a2a1a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
25 changes: 17 additions & 8 deletions seafile/StartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import "ExtentedString.h"
#import "Debug.h"

#define TABLE_HEADER_HEIGHT 100

@interface StartViewController ()<UIDocumentPickerDelegate>
@property (retain) ColorfulButton *footer;
Expand Down Expand Up @@ -64,8 +65,7 @@ - (void)viewDidLoad

NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"SeafStartHeaderView" owner:self options:nil];
UIView *header = [views objectAtIndex:0];
header.frame = CGRectMake(0,0, self.tableView.frame.size.width, 156);
header.autoresizesSubviews = YES;
header.frame = CGRectMake(0,0, self.tableView.frame.size.width, TABLE_HEADER_HEIGHT);
header.backgroundColor = [UIColor clearColor];
UILabel *welcomeLable = (UILabel *)[header viewWithTag:100];
UILabel *msgLabel = (UILabel *)[header viewWithTag:101];
Expand All @@ -83,8 +83,8 @@ - (void)viewDidLoad
bt.layer.cornerRadius = 0;
bt.layer.borderWidth = 1.0f;
bt.layer.masksToBounds = YES;
bt.backgroundColor = [UIColor clearColor];
[bt.layer setBorderColor:[[UIColor grayColor] CGColor]];
bt.layer.borderColor = [[UIColor grayColor] CGColor];
bt.backgroundColor = [UIColor colorWithRed:227.0/255.0 green:227.0/255.0 blue:227.0/255.0 alpha:1.0];
[bt setTitleColor:[UIColor colorWithRed:112/255.0 green:112/255.0 blue:112/255.0 alpha:1.0] forState:UIControlStateNormal];
[bt setTitle:NSLocalizedString(@"Back to Last Account", @"Seafile") forState:UIControlStateNormal];
bt.showsTouchWhenHighlighted = true;
Expand Down Expand Up @@ -169,17 +169,15 @@ - (BOOL)checkLastAccount
- (void)viewWillAppear:(BOOL)animated
{
self.footer.hidden = !([self checkLastAccount]);
self.tableView.tableHeaderView.frame = CGRectMake(0,0, self.tableView.frame.size.width, TABLE_HEADER_HEIGHT);
[self.tableView reloadData];
[super viewWillAppear:animated];
}

- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
ColorfulButton *bt = self.footer;
bt.frame = CGRectMake(self.view.frame.origin.x-1, self.view.frame.size.height-57, self.tableView.frame.size.width+2, 58);
bt.backgroundColor = [UIColor colorWithRed:227.0/255.0 green:227.0/255.0 blue:227.0/255.0 alpha:1.0];
[bt.layer setBorderColor:[[UIColor grayColor] CGColor]];
self.footer.frame = CGRectMake(self.view.frame.origin.x-1, self.view.frame.size.height-57, self.tableView.frame.size.width+2, 58);
}

- (void)viewDidUnload
Expand Down Expand Up @@ -328,6 +326,17 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 20)];
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
self.tableView.tableHeaderView.frame = CGRectMake(0,0, size.width, TABLE_HEADER_HEIGHT);
self.tableView.tableHeaderView = self.tableView.tableHeaderView;
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
}];
}

#pragma mark - Table view delegate
- (void)checkSelectAccount:(SeafConnection *)conn
{
Expand Down
26 changes: 10 additions & 16 deletions seafile/en.lproj/SeafStart.storyboard
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="k7e-C2-Uj2">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="k7e-C2-Uj2">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Seafile-->
<scene sceneID="mDq-71-pQU">
<objects>
<tableViewController id="wus-oO-7xQ" customClass="StartViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="GC2-66-hVf">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="SeafAccountCell" id="jxM-Mp-uGt" customClass="SeafAccountCell">
<rect key="frame" x="0.0" y="86" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="jxM-Mp-uGt" id="l7i-aS-u7s">
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="dataSource" destination="wus-oO-7xQ" id="GhY-LA-Te3"/>
<outlet property="delegate" destination="wus-oO-7xQ" id="T7H-eX-lOH"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Seafile" id="jDa-lQ-Leu"/>
<navigationItem key="navigationItem" title="Seafile" id="lEl-PF-zxr"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xCf-6G-sm8" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
Expand Down
7 changes: 4 additions & 3 deletions seafile/en.lproj/SeafStartHeaderView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleAspectFit" id="1" customClass="SeafStartHeaderView">
<rect key="frame" x="0.0" y="0.0" width="408" height="150"/>
<rect key="frame" x="0.0" y="0.0" width="408" height="100"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="100" contentMode="scaleAspectFill" text="" textAlignment="center" lineBreakMode="tailTruncation" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="3">
Expand All @@ -25,7 +25,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="101" contentMode="left" text="Choose an account to start" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="6">
<rect key="frame" x="0.0" y="130" width="408" height="20"/>
<rect key="frame" x="0.0" y="80" width="408" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="3R9-4B-4Rd"/>
</constraints>
Expand All @@ -38,13 +38,14 @@
<constraint firstItem="6" firstAttribute="width" secondItem="3" secondAttribute="width" id="B76-Fn-AWn"/>
<constraint firstItem="6" firstAttribute="centerX" secondItem="3" secondAttribute="centerX" id="QW3-ta-H9s"/>
<constraint firstItem="3" firstAttribute="width" secondItem="1" secondAttribute="width" id="WbL-O2-aKA"/>
<constraint firstItem="6" firstAttribute="top" secondItem="3" secondAttribute="bottom" constant="10" id="eTA-ym-xcx"/>
<constraint firstAttribute="bottom" secondItem="6" secondAttribute="bottom" id="h7j-aX-kTg"/>
<constraint firstItem="3" firstAttribute="top" secondItem="1" secondAttribute="top" constant="20" id="hIO-C3-yfs"/>
<constraint firstItem="3" firstAttribute="centerX" secondItem="1" secondAttribute="centerX" id="myA-iY-Hq2"/>
</constraints>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics" statusBarStyle="blackOpaque"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="268" y="91"/>
<point key="canvasLocation" x="293" y="100"/>
</view>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
Expand Down

0 comments on commit 34a2a1a

Please sign in to comment.