Skip to content

Commit

Permalink
Adding button to go to bottom of the view. Adding autolayout to views.
Browse files Browse the repository at this point in the history
  • Loading branch information
agustinslions committed Oct 17, 2017
1 parent 3f1c724 commit 229c040
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 22 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
22 changes: 12 additions & 10 deletions SLConsoleLog/ConsoleLogs/SLConsoleTypesViewController.xib
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="YOU_ConsoleTypesViewController">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SLConsoleTypesViewController">
<connections>
<outlet property="tableView" destination="mcc-op-EHs" id="1kA-ra-UDH"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
Expand All @@ -20,9 +21,8 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="mcc-op-EHs">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="mcc-op-EHs">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="dataSource" destination="-1" id="NIq-kH-ca1"/>
Expand All @@ -31,12 +31,14 @@
</tableView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="mcc-op-EHs" firstAttribute="bottom" secondItem="OX7-Gl-CZ2" secondAttribute="bottom" id="3Vu-Yw-JsR"/>
<constraint firstItem="mcc-op-EHs" firstAttribute="trailing" secondItem="OX7-Gl-CZ2" secondAttribute="trailing" id="418-RI-WLW"/>
<constraint firstItem="mcc-op-EHs" firstAttribute="leading" secondItem="OX7-Gl-CZ2" secondAttribute="leading" id="RQI-P9-t4G"/>
<constraint firstItem="mcc-op-EHs" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="xJN-4I-GZR"/>
</constraints>
<viewLayoutGuide key="safeArea" id="OX7-Gl-CZ2"/>
<point key="canvasLocation" x="519" y="361"/>
</view>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</document>
35 changes: 33 additions & 2 deletions SLConsoleLog/ConsoleLogs/SLLogsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

@interface SLLogsViewController () <MFMailComposeViewControllerDelegate>
@interface SLLogsViewController () <MFMailComposeViewControllerDelegate, UIScrollViewDelegate>

@property (nonatomic, weak) IBOutlet UITextView *textView;
@property (nonatomic, weak) IBOutlet UIButton *button;

@end

Expand All @@ -24,7 +25,7 @@ - (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.textView.text = [SLConsoleLogManager getLogsForType:self.filePathLogs];

[self checkIfBottomScroll];
UIBarButtonItem *barbutton = [[UIBarButtonItem alloc] initWithTitle:@"Send Logs" style:UIBarButtonItemStyleDone target:self action:@selector(sendLogsAction)];
self.navigationItem.rightBarButtonItem = barbutton;
}
Expand Down Expand Up @@ -55,4 +56,34 @@ - (void)didReceiveMemoryWarning
// Dispose of any resources that can be recreated.
}

- (IBAction)goToBottom:(id)sender
{
CGPoint bottomOffset = CGPointMake(0, self.textView.contentSize.height - self.textView.bounds.size.height);
[self.textView setContentOffset:bottomOffset animated:YES];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self checkIfBottomScroll];
}

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
[self checkIfBottomScroll];
}

- (void)checkIfBottomScroll {
CGPoint offset = self.textView.contentOffset;
CGRect bounds = self.textView.bounds;
CGSize size = self.textView.contentSize;
UIEdgeInsets inset = self.textView.contentInset;
float y = offset.y + bounds.size.height - inset.bottom;
float h = size.height;

if (y >= h) {
self.button.hidden = YES;
} else {
self.button.hidden = NO;
}
}


@end
43 changes: 33 additions & 10 deletions SLConsoleLog/ConsoleLogs/SLLogsViewController.xib
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="YOU_LogsViewController">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SLLogsViewController">
<connections>
<outlet property="button" destination="uMv-mC-3Oc" id="DPS-ec-cDW"/>
<outlet property="textView" destination="WHp-gk-PD3" id="2Qv-e3-fSp"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
Expand All @@ -20,22 +22,43 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" id="WHp-gk-PD3">
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WHp-gk-PD3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<connections>
<outlet property="delegate" destination="-1" id="u7r-Pu-deJ"/>
</connections>
</textView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uMv-mC-3Oc">
<rect key="frame" x="0.0" y="627" width="375" height="40"/>
<color key="backgroundColor" red="0.6570132058" green="0.0" blue="0.65905448720000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="gSr-LE-HVD"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Go to bottom">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="goToBottom:" destination="-1" eventType="touchUpInside" id="Blk-8c-vlF"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="8qz-u1-wED" firstAttribute="trailing" secondItem="uMv-mC-3Oc" secondAttribute="trailing" id="0Hq-hE-bnW"/>
<constraint firstItem="WHp-gk-PD3" firstAttribute="leading" secondItem="8qz-u1-wED" secondAttribute="leading" id="36G-qb-GL8"/>
<constraint firstItem="WHp-gk-PD3" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="5Au-ZV-uKV"/>
<constraint firstItem="uMv-mC-3Oc" firstAttribute="bottom" secondItem="8qz-u1-wED" secondAttribute="bottom" id="VbU-Vf-Fo8"/>
<constraint firstItem="WHp-gk-PD3" firstAttribute="trailing" secondItem="8qz-u1-wED" secondAttribute="trailing" id="YTL-9c-tDu"/>
<constraint firstItem="uMv-mC-3Oc" firstAttribute="leading" secondItem="8qz-u1-wED" secondAttribute="leading" id="rvl-Ea-0lh"/>
<constraint firstItem="WHp-gk-PD3" firstAttribute="bottom" secondItem="8qz-u1-wED" secondAttribute="bottom" id="v2Z-gv-7s7"/>
</constraints>
<viewLayoutGuide key="safeArea" id="8qz-u1-wED"/>
<point key="canvasLocation" x="519" y="361"/>
</view>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</document>

0 comments on commit 229c040

Please sign in to comment.