Skip to content

Commit

Permalink
第21天- SwipeableCell
Browse files Browse the repository at this point in the history
1.升级api
2.解决控制台警告
  • Loading branch information
qianyb committed Dec 26, 2018
1 parent 2b7468d commit 6facf60
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
TargetAttributes = {
9F9E83541C590718003363C1 = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = F3YT8BWBYJ;
};
9F9E83681C590718003363C1 = {
CreatedOnToolsVersion = 7.2;
Expand Down Expand Up @@ -402,11 +403,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = SwipeableCell/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.appkitchen.SwipeableCell;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -415,10 +418,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = SwipeableCell/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.appkitchen.SwipeableCell;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
23 changes: 12 additions & 11 deletions Project 21 - SwipeableCell/SwipeableCell/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15E33e" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vsV-bj-Y2v">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vsV-bj-Y2v">
<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="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="2pr-Sh-C0n">
<objects>
<navigationController id="vsV-bj-Y2v" sceneMemberID="viewController">
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina47"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="mtp-OD-WiS">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -29,24 +32,23 @@
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="da2-3b-qxf">
<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"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="PatternCell" rowHeight="60" id="aIg-gj-lHT" customClass="PatternCell" customModule="SwipeableCell" customModuleProvider="target">
<rect key="frame" x="0.0" y="92" width="375" height="60"/>
<rect key="frame" x="0.0" y="28" width="375" height="60"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="aIg-gj-lHT" id="DEU-ps-lMU">
<rect key="frame" x="0.0" y="0.0" width="375" height="59.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="FIF-bM-Rpt">
<rect key="frame" x="0.0" y="0.0" width="150" height="60"/>
<rect key="frame" x="0.0" y="0.0" width="150" height="59.5"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="laM-IH-KeJ"/>
<constraint firstAttribute="width" constant="150" id="w2y-gT-tkz"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Neon Autumn" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lxh-7U-ZhQ">
<rect key="frame" x="160" y="17" width="207" height="25"/>
<rect key="frame" x="160" y="17.5" width="207" height="25"/>
<constraints>
<constraint firstAttribute="height" constant="25" id="aBv-Mq-dmy"/>
</constraints>
Expand Down Expand Up @@ -76,7 +78,6 @@
</connections>
</tableView>
<navigationItem key="navigationItem" title="Swipeable Cell" id="rdn-Ak-G7M"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina47"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iIr-fN-iQr" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
Expand Down
2 changes: 1 addition & 1 deletion Project 21 - SwipeableCell/SwipeableCell/PatternCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PatternCell: UITableViewCell {
// Initialization code
}

override func setSelected(selected: Bool, animated: Bool) {
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)

// Configure the view for the selected state
Expand Down
54 changes: 25 additions & 29 deletions Project 21 - SwipeableCell/SwipeableCell/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,72 +23,68 @@ class ViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()

}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
override func numberOfSections(in tableView: UITableView) -> Int {
return 4
}

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 60
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCellWithIdentifier("PatternCell", forIndexPath: indexPath) as! PatternCell


override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "PatternCell", for: indexPath) as! PatternCell
let pattern = data[indexPath.row]

cell.patternImageView.image = UIImage(named: pattern.image)
cell.patternNameLabel.text = pattern.name
return cell

}

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {

let delete = UITableViewRowAction(style: .Normal, title: "🗑\nDelete") { action, index in
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let delete = UITableViewRowAction(style: .normal, title: "🗑\nDelete") { action, index in
print("Delete button tapped")
}
delete.backgroundColor = UIColor.gray

// let bgImage = UIImageView(image: UIImage(named: "love"))
delete.backgroundColor = UIColor.grayColor()
// more.addSubview(bgImage)

let share = UITableViewRowAction(style: .Normal, title: "🤗\nShare") { (action: UITableViewRowAction!, indexPath: NSIndexPath) -> Void in

let share = UITableViewRowAction(style: .normal, title: "🤗\nShare") { (action, indexPath) in
let firstActivityItem = self.data[indexPath.row]

let activityViewController = UIActivityViewController(activityItems: [firstActivityItem.image as NSString], applicationActivities: nil)

self.presentViewController(activityViewController, animated: true, completion: nil)
self.present(activityViewController, animated: true, completion: nil)
}

share.backgroundColor = UIColor.redColor()

let download = UITableViewRowAction(style: .Normal, title: "⬇️\nDownload") { action, index in
share.backgroundColor = UIColor.red

let download = UITableViewRowAction(style: .normal, title: "⬇️\nDownload") { action, index in
print("Download button tapped")
}
download.backgroundColor = UIColor.blueColor()
download.backgroundColor = UIColor.blue

return [download, share, delete]
}

override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}

override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
switch editingStyle {
case .delete:
print("Delete")
case .insert:
print("Insert")
case .none:
print("None")
}
}

}

0 comments on commit 6facf60

Please sign in to comment.