forked from shu223/iOS8-Sampler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a sample for UITableViewRowAction.
- Loading branch information
Showing
6 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// RowActionViewController.h | ||
// iOS8Sampler | ||
// | ||
// Created by Shuichi Tsutsumi on 2014/11/25. | ||
// Copyright (c) 2014年 Shuichi Tsutsumi. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface RowActionViewController : UIViewController | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// | ||
// RowActionViewController.m | ||
// iOS8Sampler | ||
// | ||
// Created by Shuichi Tsutsumi on 2014/11/25. | ||
// Copyright (c) 2014年 Shuichi Tsutsumi. All rights reserved. | ||
// | ||
|
||
#import "RowActionViewController.h" | ||
#import "SVProgressHUD.h" | ||
|
||
|
||
@interface RowActionViewController () | ||
<UITableViewDataSource, UITableViewDelegate> | ||
@property (nonatomic, weak) IBOutlet UITableView *tableView; | ||
@property (nonatomic, strong) NSArray *items; | ||
@end | ||
|
||
|
||
@implementation RowActionViewController | ||
|
||
- (void)viewDidLoad { | ||
|
||
[super viewDidLoad]; | ||
|
||
self.items = @[ | ||
@"Swipe this cell", | ||
]; | ||
} | ||
|
||
- (void)didReceiveMemoryWarning { | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
/* | ||
#pragma mark - Navigation | ||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | ||
// Get the new view controller using [segue destinationViewController]. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
|
||
|
||
|
||
// ============================================================================= | ||
#pragma mark - TableViewDataSource | ||
|
||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | ||
|
||
return 1; | ||
} | ||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | ||
|
||
return [self.items count]; | ||
} | ||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
static NSString *CellIdentifier = @"Cell"; | ||
|
||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; | ||
if (!cell) { | ||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault | ||
reuseIdentifier:CellIdentifier]; | ||
cell.accessoryType = UITableViewCellAccessoryNone; | ||
cell.selectionStyle = UITableViewCellSelectionStyleNone; | ||
} | ||
|
||
cell.textLabel.text = self.items[indexPath.row]; | ||
|
||
return cell; | ||
} | ||
|
||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { | ||
|
||
} | ||
|
||
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
|
||
UITableViewRowAction *destructiveAction; | ||
UITableViewRowAction *normalAction; | ||
|
||
destructiveAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive | ||
title:@"destructive" | ||
handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { | ||
[SVProgressHUD showSuccessWithStatus:@"Destructive action has been executed!"]; | ||
}]; | ||
|
||
normalAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal | ||
title:@"normal" | ||
handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { | ||
[SVProgressHUD showSuccessWithStatus:@"Normal action has been executed!"]; | ||
}]; | ||
|
||
return @[destructiveAction, normalAction]; | ||
} | ||
|
||
|
||
// ============================================================================= | ||
#pragma mark - UITableViewDelegate | ||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6246"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowActionViewController"> | ||
<connections> | ||
<outlet property="tableView" destination="Csj-wf-3lP" id="yJU-er-VMQ"/> | ||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> | ||
</connections> | ||
</placeholder> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> | ||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
<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" translatesAutoresizingMaskIntoConstraints="NO" id="Csj-wf-3lP"> | ||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | ||
<connections> | ||
<outlet property="dataSource" destination="-1" id="ZBy-CZ-lBm"/> | ||
<outlet property="delegate" destination="-1" id="MIi-04-Clk"/> | ||
</connections> | ||
</tableView> | ||
</subviews> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
<constraints> | ||
<constraint firstItem="Csj-wf-3lP" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="14s-bA-eMd"/> | ||
<constraint firstItem="Csj-wf-3lP" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="9rw-AM-of3"/> | ||
<constraint firstAttribute="bottom" secondItem="Csj-wf-3lP" secondAttribute="bottom" id="Dny-Lh-OM5"/> | ||
<constraint firstAttribute="trailing" secondItem="Csj-wf-3lP" secondAttribute="trailing" id="iM0-nH-4AC"/> | ||
</constraints> | ||
</view> | ||
</objects> | ||
</document> |