├── Snapshots
└── JZTableViewRowActionOverview.gif
├── JZTableViewRowActionDemo
├── JZTableViewRowActionDemo
│ ├── Assets.xcassets
│ │ ├── Contents.json
│ │ ├── tip.imageset
│ │ │ ├── tip@2x.png
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── main.m
│ ├── JZTableViewRowAction
│ │ ├── UITableViewRowAction+JZExtension.h
│ │ ├── UITableViewRowAction+JZExtension.m
│ │ ├── UITableViewRowAction.m
│ │ └── UITableViewCell+JZExtension.m
│ ├── Info.plist
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── AppDelegate.m
│ └── ViewController.m
├── JZTableViewRowActionDemo.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── project.pbxproj
├── JZTableViewRowActionDemoTests
│ ├── Info.plist
│ └── JZTableViewRowActionDemoTests.m
└── JZTableViewRowActionDemoUITests
│ ├── Info.plist
│ └── JZTableViewRowActionDemoUITests.m
├── .gitignore
├── LICENSE
├── README.md
└── JZTableViewRowAction
├── UITableViewRowAction+JZExtension.h
├── UITableViewRowAction+JZExtension.m
├── UITableViewRowAction.m
└── UITableViewCell+JZExtension.m
/Snapshots/JZTableViewRowActionOverview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JazysYu/JZTableViewRowAction/HEAD/Snapshots/JZTableViewRowActionOverview.gif
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/Assets.xcassets/tip.imageset/tip@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JazysYu/JZTableViewRowAction/HEAD/JZTableViewRowActionDemo/JZTableViewRowActionDemo/Assets.xcassets/tip.imageset/tip@2x.png
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // JZTableViewRowActionDemo
4 | //
5 | // Created by Jazys on 11/12/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UITableViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // JZTableViewRowActionDemo
4 | //
5 | // Created by Jazys on 11/12/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // JZTableViewRowActionDemo
4 | //
5 | // Created by Jazys on 11/12/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/Assets.xcassets/tip.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "tip@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | #Pods/
27 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/JZTableViewRowAction/UITableViewRowAction+JZExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // UITableViewRowAction+JZExtension.h
3 | // MIX
4 | //
5 | // Created by Jazys on 10/23/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UITableViewRowAction (JZExtension)
12 |
13 | @property (nonatomic, strong, nullable) UIImage *image;
14 |
15 | @property (nonatomic, assign) BOOL enabled;
16 |
17 | + (nonnull instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style image:(nullable UIImage *)image handler:(nullable void (^)(UITableViewRowAction * _Nullable action, NSIndexPath * _Nullable indexPath))handler;
18 |
19 | @end
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemoTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemoUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Jazys
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JZTableViewRowAction
2 | Using UITableViewRowAction on iOS >= 5.0, you can set an image or enable status for UITableViewRowAction.
3 |
4 | # Overview
5 |
6 | 
7 |
8 | # Usage
9 |
10 | * Implement API in UITableViewDelegate:
11 |
12 | ```objc
13 | - (nullable NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
14 | ```
15 |
16 | * Create UITableViewRowAction with an image:
17 |
18 | ```objc
19 | UITableViewRowAction *action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault image:"your image" handler:rowActionHandler];
20 | ```
21 |
22 | * Set enable status:
23 |
24 | ```objc
25 | action.enabled = false;
26 | ```
27 |
28 | # Installation
29 | Drag all source files under floder JZTableViewRowAction to your project.
30 |
31 | ``` objc
32 | UITableViewRowAction+JZExtension.h UITableViewRowAction+JZExtension.m
33 | UITableViewCell+JZExtension.m UITableViewRowAction.m
34 | ```
35 | ***
36 | 欢迎微博[@J_雨](http://weibo.com/JazysYu/)与我交流
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemoTests/JZTableViewRowActionDemoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // JZTableViewRowActionDemoTests.m
3 | // JZTableViewRowActionDemoTests
4 | //
5 | // Created by Jazys on 11/12/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface JZTableViewRowActionDemoTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation JZTableViewRowActionDemoTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/JZTableViewRowAction/UITableViewRowAction+JZExtension.m:
--------------------------------------------------------------------------------
1 | //
2 | // UITableViewRowAction+JZExtension.m
3 | // SwipeToDeleteDemo
4 | //
5 | // Created by Jazys on 11/11/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import "UITableViewRowAction+JZExtension.h"
10 | #import
11 |
12 | @implementation UITableViewRowAction (JZExtension)
13 |
14 | + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style image:(UIImage *)image handler:(void (^)(UITableViewRowAction * _Nullable, NSIndexPath * _Nullable))handler {
15 | UITableViewRowAction *rowAction = [self rowActionWithStyle:style title:@"holder" handler:handler];
16 | rowAction.image = image;
17 | return rowAction;
18 | }
19 |
20 | - (void)setImage:(UIImage *)image {
21 | objc_setAssociatedObject(self, @selector(image), image, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
22 | }
23 |
24 | - (void)setEnabled:(BOOL)enabled {
25 | objc_setAssociatedObject(self, @selector(enabled), @(enabled), OBJC_ASSOCIATION_ASSIGN);
26 | }
27 |
28 | - (UIImage *)image {
29 | return objc_getAssociatedObject(self, _cmd);
30 | }
31 |
32 | - (BOOL)enabled {
33 | id enabled = objc_getAssociatedObject(self, _cmd);
34 | return enabled ? [enabled boolValue] : true;
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemoUITests/JZTableViewRowActionDemoUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // JZTableViewRowActionDemoUITests.m
3 | // JZTableViewRowActionDemoUITests
4 | //
5 | // Created by Jazys on 11/12/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface JZTableViewRowActionDemoUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation JZTableViewRowActionDemoUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/JZTableViewRowAction/UITableViewRowAction+JZExtension.h:
--------------------------------------------------------------------------------
1 | //The MIT License (MIT)
2 | //
3 | //Copyright (c) 2015 Jazys
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy
6 | //of this software and associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | //copies of the Software, and to permit persons to whom the Software is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice and this permission notice shall be included in all
13 | //copies or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | #import
24 |
25 | @interface UITableViewRowAction (JZExtension)
26 |
27 | @property (nonatomic, strong, nullable) UIImage *image;
28 |
29 | @property (nonatomic, assign) BOOL enabled;
30 |
31 | + (nonnull instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style image:(nullable UIImage *)image handler:(nullable void (^)(UITableViewRowAction * _Nullable action, NSIndexPath * _Nullable indexPath))handler;
32 |
33 | @end
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UIStatusBarHidden
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 | UIViewControllerBasedStatusBarAppearance
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // JZTableViewRowActionDemo
4 | //
5 | // Created by Jazys on 11/12/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/JZTableViewRowAction/UITableViewRowAction+JZExtension.m:
--------------------------------------------------------------------------------
1 | //The MIT License (MIT)
2 | //
3 | //Copyright (c) 2015 Jazys
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy
6 | //of this software and associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | //copies of the Software, and to permit persons to whom the Software is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice and this permission notice shall be included in all
13 | //copies or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | #import "UITableViewRowAction+JZExtension.h"
24 | #import
25 |
26 | @implementation UITableViewRowAction (JZExtension)
27 |
28 | + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style image:(UIImage *)image handler:(void (^)(UITableViewRowAction * _Nullable, NSIndexPath * _Nullable))handler {
29 | UITableViewRowAction *rowAction = [self rowActionWithStyle:style title:@"holder" handler:handler];
30 | rowAction.image = image;
31 | return rowAction;
32 | }
33 |
34 | - (void)setImage:(UIImage *)image {
35 | objc_setAssociatedObject(self, @selector(image), image, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
36 | }
37 |
38 | - (void)setEnabled:(BOOL)enabled {
39 | objc_setAssociatedObject(self, @selector(enabled), @(enabled), OBJC_ASSOCIATION_ASSIGN);
40 | }
41 |
42 | - (UIImage *)image {
43 | return objc_getAssociatedObject(self, _cmd);
44 | }
45 |
46 | - (BOOL)enabled {
47 | id enabled = objc_getAssociatedObject(self, _cmd);
48 | return enabled ? [enabled boolValue] : true;
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // JZTableViewRowActionDemo
4 | //
5 | // Created by Jazys on 11/10/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "UITableViewRowAction+JZExtension.h"
11 |
12 | @interface ViewController ()
13 | @property (nonatomic, strong) NSArray *models;
14 | @property (nonatomic, copy) NSString *tableViewReuseIdentifier;
15 | @end
16 |
17 | @implementation ViewController
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 | self.tableViewReuseIdentifier = NSStringFromClass([UITableViewCell class]);
21 | }
22 |
23 | - (void)didReceiveMemoryWarning {
24 | [super didReceiveMemoryWarning];
25 | // Dispose of any resources that can be recreated.
26 | }
27 |
28 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
29 | return self.models.count;
30 | }
31 |
32 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
33 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.tableViewReuseIdentifier forIndexPath:indexPath];
34 | cell.backgroundColor = self.models[indexPath.row];
35 | return cell;
36 | }
37 |
38 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
39 | [self setEditing:false animated:true];
40 | }
41 |
42 | - (nullable NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
43 |
44 | void(^rowActionHandler)(UITableViewRowAction *, NSIndexPath *) = ^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
45 | NSLog(@"%@", action);
46 | [self setEditing:false animated:true];
47 | };
48 |
49 | UIButton *buttonForImage = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
50 | UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault image:[buttonForImage imageForState:UIControlStateNormal] handler:rowActionHandler];
51 |
52 | UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"disenable" handler:rowActionHandler];
53 | action2.enabled = false;
54 |
55 | UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"emjoy👍" handler:rowActionHandler];
56 |
57 | return @[action1,action2,action3];
58 | }
59 |
60 | #pragma mark - getters
61 |
62 | - (NSArray *)models {
63 | if (!_models) {
64 | NSMutableArray *__models = [NSMutableArray array];
65 | for (int index = 0; index < 20; index++) {
66 | [__models addObject:[UIColor colorWithHue:arc4random() % 256 / 256.0 saturation:arc4random() % 128 / 256.0 brightness:arc4random() % 128 / 256.0 alpha:1]];
67 | }
68 | _models = __models;
69 | }
70 | return _models;
71 | }
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/JZTableViewRowAction/UITableViewRowAction.m:
--------------------------------------------------------------------------------
1 | //
2 | // UITableViewRowAction.m
3 | // tableView
4 | //
5 | // Created by Jazys on 10/23/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | @interface JZTableViewRowAction : NSObject
14 | {
15 | UITableViewRowActionStyle _style;
16 | }
17 | @property (nonatomic, readonly) UITableViewRowActionStyle style;
18 | @property (nonatomic, copy, nullable) NSString *title;
19 | @property (nonatomic, copy, nullable) UIColor *backgroundColor; // default background color is dependent on style
20 | @property (nonatomic, copy, nullable) UIVisualEffect* backgroundEffect;
21 | @property (nonatomic, copy, nullable) void (^handler)(UITableViewRowAction *, NSIndexPath *);
22 | @property (nonatomic, strong, nullable) UIImage *image;
23 | @property (nonatomic, strong, nonnull) NSIndexPath *indexPath;
24 | @property (nonatomic, assign) BOOL enabled;
25 | + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style title:(nullable NSString *)title handler:(void (^)(UITableViewRowAction *action, NSIndexPath *indexPath))handler;
26 | + (nonnull instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style image:(nullable UIImage *)image handler:(nullable void (^)(UITableViewRowAction * _Nullable action, NSIndexPath * _Nullable indexPath))handler;
27 | @end
28 |
29 | @implementation JZTableViewRowAction
30 |
31 | + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style title:(NSString *)title handler:(void (^)(UITableViewRowAction *, NSIndexPath *))handler {
32 | JZTableViewRowAction *rowAction = [[JZTableViewRowAction alloc] init];
33 | rowAction.title = title;
34 | rowAction.handler = handler;
35 | rowAction->_style = style;
36 | rowAction.enabled = true;
37 | return rowAction;
38 | }
39 |
40 | + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style image:(UIImage *)image handler:(void (^)(UITableViewRowAction * _Nullable, NSIndexPath * _Nullable))handler {
41 | JZTableViewRowAction *rowAction = [self rowActionWithStyle:style title:@"holder" handler:handler];
42 | rowAction.image = image;
43 | return rowAction;
44 | }
45 |
46 | - (id)copyWithZone:(NSZone *)zone {
47 | return [self copy];
48 | }
49 |
50 | - (void)actionTriggered:(id)sender {
51 | !self.handler ?: self.handler((__kindof UITableViewRowAction *)self, self.indexPath);
52 | }
53 |
54 | @end
55 |
56 |
57 | __asm(
58 | ".section __DATA,__objc_classrefs,regular,no_dead_strip\n"
59 | #if TARGET_RT_64_BIT
60 | ".align 3\n"
61 | "L_OBJC_CLASS_UITableViewRowAction:\n"
62 | ".quad _OBJC_CLASS_$_UITableViewRowAction\n"
63 | #else
64 | ".align 2\n"
65 | "_OBJC_CLASS_UITableViewRowAction:\n"
66 | ".long _OBJC_CLASS_$_UITableViewRowAction\n"
67 | #endif
68 | ".weak_reference _OBJC_CLASS_$_UITableViewRowAction\n"
69 | );
70 |
71 | __attribute__((constructor)) static void JZTableViewRowActionPatchEntry(void) {
72 | static dispatch_once_t onceToken;
73 | dispatch_once(&onceToken, ^{
74 | @autoreleasepool {
75 |
76 | if (objc_getClass("UITableViewRowAction")) {
77 | return;
78 | }
79 |
80 | Class *tableViewRowActionClassLocation = NULL;
81 |
82 | #if TARGET_CPU_ARM
83 | __asm("movw %0, :lower16:(_OBJC_CLASS_UITableViewRowAction-(LPC0+4))\n"
84 | "movt %0, :upper16:(_OBJC_CLASS_UITableViewRowAction-(LPC0+4))\n"
85 | "LPC0: add %0, pc" : "=r"(tableViewRowActionClassLocation));
86 | #elif TARGET_CPU_ARM64
87 | __asm("adrp %0, L_OBJC_CLASS_UITableViewRowAction@PAGE\n"
88 | "add %0, %0, L_OBJC_CLASS_UITableViewRowAction@PAGEOFF" : "=r"(tableViewRowActionClassLocation));
89 | #elif TARGET_CPU_X86_64
90 | __asm("leaq L_OBJC_CLASS_UITableViewRowAction(%%rip), %0" : "=r"(tableViewRowActionClassLocation));
91 | #elif TARGET_CPU_X86
92 | void *pc = NULL;
93 | __asm("calll L0\n"
94 | "L0: popl %0\n"
95 | "leal _OBJC_CLASS_UITableViewRowAction-L0(%0), %1" : "=r"(pc), "=r"(tableViewRowActionClassLocation));
96 | #else
97 | #error Unsupported CPU
98 | #endif
99 |
100 | if (tableViewRowActionClassLocation && !*tableViewRowActionClassLocation) {
101 | Class class = objc_allocateClassPair(JZTableViewRowAction.class, "UITableViewRowAction", 0);
102 | if (class) {
103 | objc_registerClassPair(class);
104 | *tableViewRowActionClassLocation = class;
105 | }
106 | }
107 | }
108 | });
109 | }
110 |
--------------------------------------------------------------------------------
/JZTableViewRowAction/UITableViewRowAction.m:
--------------------------------------------------------------------------------
1 | //The MIT License (MIT)
2 | //
3 | //Copyright (c) 2015 Jazys
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy
6 | //of this software and associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | //copies of the Software, and to permit persons to whom the Software is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice and this permission notice shall be included in all
13 | //copies or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 |
24 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0
25 | #error "JZTableViewRowAction must be compiled under iOS8 SDK at least"
26 | #endif
27 |
28 | #import
29 | #import
30 | #import
31 |
32 | @interface JZTableViewRowAction : NSObject
33 | {
34 | UITableViewRowActionStyle _style;
35 | }
36 | @property (nonatomic, readonly) UITableViewRowActionStyle style;
37 | @property (nonatomic, copy, nullable) NSString *title;
38 | @property (nonatomic, copy, nullable) UIColor *backgroundColor; // default background color is dependent on style
39 | @property (nonatomic, copy, nullable) UIVisualEffect* backgroundEffect;
40 | @property (nonatomic, copy, nullable) void (^handler)(UITableViewRowAction *, NSIndexPath *);
41 | @property (nonatomic, strong, nullable) UIImage *image;
42 | @property (nonatomic, strong, nonnull) NSIndexPath *indexPath;
43 | @property (nonatomic, assign) BOOL enabled;
44 | + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style title:(nullable NSString *)title handler:(void (^)(UITableViewRowAction *action, NSIndexPath *indexPath))handler;
45 | + (nonnull instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style image:(nullable UIImage *)image handler:(nullable void (^)(UITableViewRowAction * _Nullable action, NSIndexPath * _Nullable indexPath))handler;
46 | @end
47 |
48 | @implementation JZTableViewRowAction
49 |
50 | + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style title:(NSString *)title handler:(void (^)(UITableViewRowAction *, NSIndexPath *))handler {
51 | JZTableViewRowAction *rowAction = [[JZTableViewRowAction alloc] init];
52 | rowAction.title = title;
53 | rowAction.handler = handler;
54 | rowAction->_style = style;
55 | rowAction.enabled = true;
56 | return rowAction;
57 | }
58 |
59 | + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style image:(UIImage *)image handler:(void (^)(UITableViewRowAction * _Nullable, NSIndexPath * _Nullable))handler {
60 | JZTableViewRowAction *rowAction = [self rowActionWithStyle:style title:@"holder" handler:handler];
61 | rowAction.image = image;
62 | return rowAction;
63 | }
64 |
65 | - (id)copyWithZone:(NSZone *)zone {
66 | return [self copy];
67 | }
68 |
69 | - (void)actionTriggered:(id)sender {
70 | !self.handler ?: self.handler((__kindof UITableViewRowAction *)self, self.indexPath);
71 | }
72 |
73 | @end
74 |
75 | // ----------------------------------------------------
76 | // Runtime injection start.
77 | // Assemble codes below are based on:
78 | // https://github.com/forkingdog/FDStackView
79 | // ----------------------------------------------------
80 |
81 | __asm(
82 | ".section __DATA,__objc_classrefs,regular,no_dead_strip\n"
83 | #if TARGET_RT_64_BIT
84 | ".align 3\n"
85 | "L_OBJC_CLASS_UITableViewRowAction:\n"
86 | ".quad _OBJC_CLASS_$_UITableViewRowAction\n"
87 | #else
88 | ".align 2\n"
89 | "_OBJC_CLASS_UITableViewRowAction:\n"
90 | ".long _OBJC_CLASS_$_UITableViewRowAction\n"
91 | #endif
92 | ".weak_reference _OBJC_CLASS_$_UITableViewRowAction\n"
93 | );
94 |
95 | __attribute__((constructor)) static void JZTableViewRowActionPatchEntry(void) {
96 | static dispatch_once_t onceToken;
97 | dispatch_once(&onceToken, ^{
98 | @autoreleasepool {
99 |
100 | if (objc_getClass("UITableViewRowAction")) {
101 | return;
102 | }
103 |
104 | Class *tableViewRowActionClassLocation = NULL;
105 |
106 | #if TARGET_CPU_ARM
107 | __asm("movw %0, :lower16:(_OBJC_CLASS_UITableViewRowAction-(LPC0+4))\n"
108 | "movt %0, :upper16:(_OBJC_CLASS_UITableViewRowAction-(LPC0+4))\n"
109 | "LPC0: add %0, pc" : "=r"(tableViewRowActionClassLocation));
110 | #elif TARGET_CPU_ARM64
111 | __asm("adrp %0, L_OBJC_CLASS_UITableViewRowAction@PAGE\n"
112 | "add %0, %0, L_OBJC_CLASS_UITableViewRowAction@PAGEOFF" : "=r"(tableViewRowActionClassLocation));
113 | #elif TARGET_CPU_X86_64
114 | __asm("leaq L_OBJC_CLASS_UITableViewRowAction(%%rip), %0" : "=r"(tableViewRowActionClassLocation));
115 | #elif TARGET_CPU_X86
116 | void *pc = NULL;
117 | __asm("calll L0\n"
118 | "L0: popl %0\n"
119 | "leal _OBJC_CLASS_UITableViewRowAction-L0(%0), %1" : "=r"(pc), "=r"(tableViewRowActionClassLocation));
120 | #else
121 | #error Unsupported CPU
122 | #endif
123 |
124 | if (tableViewRowActionClassLocation && !*tableViewRowActionClassLocation) {
125 | Class class = objc_allocateClassPair(JZTableViewRowAction.class, "UITableViewRowAction", 0);
126 | if (class) {
127 | objc_registerClassPair(class);
128 | *tableViewRowActionClassLocation = class;
129 | }
130 | }
131 | }
132 | });
133 | }
134 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo/JZTableViewRowAction/UITableViewCell+JZExtension.m:
--------------------------------------------------------------------------------
1 | //
2 | // UITableViewCell+JZTableViewRowAction.m
3 | // tableView
4 | //
5 | // Created by Jazys on 10/23/15.
6 | // Copyright © 2015 Jazys. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "UITableViewRowAction+JZExtension.h"
12 |
13 | @implementation UITableViewCell (JZExtension)
14 |
15 | + (void)load {
16 | [super load];
17 | static dispatch_once_t onceToken;
18 | dispatch_once(&onceToken, ^{
19 | Method willTransitionToState = class_getInstanceMethod(self, @selector(willTransitionToState:));
20 | Method __willTransitionToState = class_getInstanceMethod(self, @selector(__willTransitionToState:));
21 | method_exchangeImplementations(willTransitionToState, __willTransitionToState);
22 |
23 | Method titleForDeleteConfirmationButton = class_getInstanceMethod([UITableView class], NSSelectorFromString(@"_titleForDeleteConfirmationButtonForRowAtIndexPath:"));
24 | Method _titleForDeleteConfirmationButton = class_getInstanceMethod([UITableView class], NSSelectorFromString(@"titleForDeleteConfirmationButtonForRowAtIndexPath:"));
25 | method_exchangeImplementations(titleForDeleteConfirmationButton, _titleForDeleteConfirmationButton);
26 | });
27 | }
28 |
29 | - (void)__willTransitionToState:(UITableViewCellStateMask)state {
30 |
31 | [self __willTransitionToState:state];
32 |
33 | if (state == UITableViewCellStateShowingDeleteConfirmationMask) {
34 |
35 | UITableView *tableView = [self valueForKey:@"_tableView"];
36 | if (![tableView.delegate respondsToSelector:@selector(tableView:editActionsForRowAtIndexPath:)]) {
37 | return;
38 | }
39 |
40 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
41 |
42 | UIView *swipeToDeleteConfirmationView = [self valueForKey:@"_swipeToDeleteConfirmationView"];
43 | if ([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] != NSOrderedAscending) {
44 | for (UIButton *deleteButton in swipeToDeleteConfirmationView.subviews) {
45 |
46 | UITableViewRowAction *rowAction = [deleteButton valueForKey:@"_action"];
47 | if (rowAction.backgroundColor) {
48 | deleteButton.backgroundColor = rowAction.backgroundColor;
49 | }
50 |
51 | deleteButton.enabled = rowAction.enabled;
52 |
53 | if (rowAction.image) {
54 | NSTextAttachment *imageAtt = [[NSTextAttachment alloc] init];
55 | imageAtt.image = rowAction.image;
56 | [deleteButton setAttributedTitle:[NSAttributedString attributedStringWithAttachment:imageAtt] forState:UIControlStateNormal];
57 | }
58 | }
59 | return;
60 | }
61 |
62 | NSIndexPath *indexPath = [tableView indexPathForCell:self];
63 |
64 | NSArray *rowActions = [tableView.delegate tableView:tableView editActionsForRowAtIndexPath:indexPath];
65 | self.rowActions = rowActions;
66 |
67 | UIButton *deleteConfirmButton = swipeToDeleteConfirmationView.subviews.firstObject;
68 | deleteConfirmButton.titleLabel.textColor = deleteConfirmButton.backgroundColor;
69 | CGFloat buttonWidth = deleteConfirmButton.bounds.size.width / rowActions.count;
70 | CGFloat buttonHeight = deleteConfirmButton.bounds.size.height;
71 | for (NSInteger index = 0; index < rowActions.count; index++) {
72 |
73 | UITableViewRowAction *rowAction = rowActions[index];
74 |
75 | [rowAction setValue:indexPath forKey:@"indexPath"];
76 |
77 | UIButton *rowActionButton = [UIButton buttonWithType:UIButtonTypeCustom];
78 |
79 | if (rowAction.backgroundColor) {
80 | rowActionButton.backgroundColor = rowAction.backgroundColor;
81 | } else {
82 | rowActionButton.backgroundColor = rowAction.style == UITableViewRowActionStyleDestructive ? deleteConfirmButton.backgroundColor : [UIColor colorWithRed:187.0/255.0 green:187.0/255.0 blue:193.0/255.0 alpha:1.0];
83 | }
84 |
85 | if (rowAction.enabled) {
86 | [rowActionButton addTarget:rowAction action:NSSelectorFromString(@"actionTriggered:") forControlEvents:UIControlEventTouchUpInside];
87 | }
88 |
89 | rowActionButton.frame = CGRectMake((rowActions.count - 1 - index) * buttonWidth, 0, buttonWidth, buttonHeight);
90 |
91 | rowAction.image ? [rowActionButton setImage:rowAction.image forState:UIControlStateNormal]
92 | : [rowActionButton setTitle:rowAction.title forState:UIControlStateNormal];
93 |
94 | [deleteConfirmButton addSubview:rowActionButton];
95 | }
96 | });
97 | }
98 | }
99 |
100 | - (void)setRowActions:(NSArray *)rowActions {
101 | objc_setAssociatedObject(self, @selector(rowActions), rowActions, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
102 | }
103 |
104 | - (NSArray *)rowActions {
105 | return objc_getAssociatedObject(self, _cmd);
106 | }
107 |
108 | @end
109 |
110 | @implementation UITableView (JZExtension)
111 |
112 | - (id)titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
113 | if (![self.delegate respondsToSelector:@selector(tableView:editActionsForRowAtIndexPath:)]) {
114 | return [self titleForDeleteConfirmationButtonForRowAtIndexPath:indexPath];
115 | }
116 | // System version above iOS7 will not go on.
117 | NSArray *rowActions = [self.delegate tableView:self editActionsForRowAtIndexPath:indexPath];
118 | NSMutableString *placeholder = [NSMutableString string];
119 | NSString *longestString = @" "; //A placeholder string for the default width.
120 | {
121 | CGFloat fontSize = 12;
122 | for (UITableViewRowAction *action in rowActions) {
123 | CGFloat actionTitleWidth = [action.title sizeWithFont:[UIFont systemFontOfSize:fontSize]].width;
124 | CGFloat currentLongestStringWidth = [longestString sizeWithFont:[UIFont systemFontOfSize:fontSize]].width;
125 | if (actionTitleWidth > currentLongestStringWidth) {
126 | longestString = action.title;
127 | }
128 | }
129 | }
130 | for (int index = 0; index < rowActions.count; index++) {
131 | [placeholder appendString:longestString];
132 | }
133 | return placeholder;
134 | }
135 |
136 | @end
137 |
--------------------------------------------------------------------------------
/JZTableViewRowAction/UITableViewCell+JZExtension.m:
--------------------------------------------------------------------------------
1 | //The MIT License (MIT)
2 | //
3 | //Copyright (c) 2015 Jazys
4 | //
5 | //Permission is hereby granted, free of charge, to any person obtaining a copy
6 | //of this software and associated documentation files (the "Software"), to deal
7 | //in the Software without restriction, including without limitation the rights
8 | //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | //copies of the Software, and to permit persons to whom the Software is
10 | //furnished to do so, subject to the following conditions:
11 | //
12 | //The above copyright notice and this permission notice shall be included in all
13 | //copies or substantial portions of the Software.
14 | //
15 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | //SOFTWARE.
22 |
23 | #import
24 | #import
25 | #import "UITableViewRowAction+JZExtension.h"
26 |
27 | @implementation UITableViewCell (JZExtension)
28 |
29 | + (void)load {
30 | [super load];
31 | static dispatch_once_t onceToken;
32 | dispatch_once(&onceToken, ^{
33 | Method willTransitionToState = class_getInstanceMethod(self, @selector(willTransitionToState:));
34 | Method __willTransitionToState = class_getInstanceMethod(self, @selector(__willTransitionToState:));
35 | method_exchangeImplementations(willTransitionToState, __willTransitionToState);
36 |
37 | Method titleForDeleteConfirmationButton = class_getInstanceMethod([UITableView class], NSSelectorFromString(@"_titleForDeleteConfirmationButtonForRowAtIndexPath:"));
38 | Method _titleForDeleteConfirmationButton = class_getInstanceMethod([UITableView class], NSSelectorFromString(@"titleForDeleteConfirmationButtonForRowAtIndexPath:"));
39 | method_exchangeImplementations(titleForDeleteConfirmationButton, _titleForDeleteConfirmationButton);
40 | });
41 | }
42 |
43 | - (void)__willTransitionToState:(UITableViewCellStateMask)state {
44 |
45 | [self __willTransitionToState:state];
46 |
47 | if (state == UITableViewCellStateShowingDeleteConfirmationMask) {
48 |
49 | UITableView *tableView = [self valueForKey:@"_tableView"];
50 | if (![tableView.delegate respondsToSelector:@selector(tableView:editActionsForRowAtIndexPath:)]) {
51 | return;
52 | }
53 |
54 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
55 |
56 | UIView *swipeToDeleteConfirmationView = [self valueForKey:@"_swipeToDeleteConfirmationView"];
57 | if ([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] != NSOrderedAscending) {
58 | for (UIButton *deleteButton in swipeToDeleteConfirmationView.subviews) {
59 |
60 | UITableViewRowAction *rowAction = [deleteButton valueForKey:@"_action"];
61 | if (rowAction.backgroundColor) {
62 | deleteButton.backgroundColor = rowAction.backgroundColor;
63 | }
64 |
65 | deleteButton.enabled = rowAction.enabled;
66 |
67 | if (rowAction.image) {
68 | NSTextAttachment *imageAtt = [[NSTextAttachment alloc] init];
69 | imageAtt.image = rowAction.image;
70 | [deleteButton setAttributedTitle:[NSAttributedString attributedStringWithAttachment:imageAtt] forState:UIControlStateNormal];
71 | }
72 | }
73 | return;
74 | }
75 |
76 | NSIndexPath *indexPath = [tableView indexPathForCell:self];
77 |
78 | NSArray *rowActions = [tableView.delegate tableView:tableView editActionsForRowAtIndexPath:indexPath];
79 | self.rowActions = rowActions;
80 |
81 | UIButton *deleteConfirmButton = swipeToDeleteConfirmationView.subviews.firstObject;
82 | deleteConfirmButton.titleLabel.textColor = deleteConfirmButton.backgroundColor;
83 | CGFloat buttonWidth = deleteConfirmButton.bounds.size.width / rowActions.count;
84 | CGFloat buttonHeight = deleteConfirmButton.bounds.size.height;
85 | for (NSInteger index = 0; index < rowActions.count; index++) {
86 |
87 | UITableViewRowAction *rowAction = rowActions[index];
88 |
89 | [rowAction setValue:indexPath forKey:@"indexPath"];
90 |
91 | UIButton *rowActionButton = [UIButton buttonWithType:UIButtonTypeCustom];
92 |
93 | if (rowAction.backgroundColor) {
94 | rowActionButton.backgroundColor = rowAction.backgroundColor;
95 | } else {
96 | rowActionButton.backgroundColor = rowAction.style == UITableViewRowActionStyleDestructive ? deleteConfirmButton.backgroundColor : [UIColor colorWithRed:187.0/255.0 green:187.0/255.0 blue:193.0/255.0 alpha:1.0];
97 | }
98 |
99 | if (rowAction.enabled) {
100 | [rowActionButton addTarget:rowAction action:NSSelectorFromString(@"actionTriggered:") forControlEvents:UIControlEventTouchUpInside];
101 | }
102 |
103 | rowActionButton.frame = CGRectMake((rowActions.count - 1 - index) * buttonWidth, 0, buttonWidth, buttonHeight);
104 |
105 | rowAction.image ? [rowActionButton setImage:rowAction.image forState:UIControlStateNormal]
106 | : [rowActionButton setTitle:rowAction.title forState:UIControlStateNormal];
107 |
108 | [deleteConfirmButton addSubview:rowActionButton];
109 | }
110 | });
111 | }
112 | }
113 |
114 | - (void)setRowActions:(NSArray *)rowActions {
115 | objc_setAssociatedObject(self, @selector(rowActions), rowActions, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
116 | }
117 |
118 | - (NSArray *)rowActions {
119 | return objc_getAssociatedObject(self, _cmd);
120 | }
121 |
122 | @end
123 |
124 | @implementation UITableView (JZExtension)
125 |
126 | - (id)titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
127 | if (![self.delegate respondsToSelector:@selector(tableView:editActionsForRowAtIndexPath:)]) {
128 | return [self titleForDeleteConfirmationButtonForRowAtIndexPath:indexPath];
129 | }
130 | // System version above iOS7 will not go on.
131 | NSArray *rowActions = [self.delegate tableView:self editActionsForRowAtIndexPath:indexPath];
132 | NSMutableString *placeholder = [NSMutableString string];
133 | NSString *longestString = @" "; //A placeholder string for the default width.
134 | {
135 | CGFloat fontSize = 12;
136 | for (UITableViewRowAction *action in rowActions) {
137 | CGFloat actionTitleWidth = [action.title sizeWithFont:[UIFont systemFontOfSize:fontSize]].width;
138 | CGFloat currentLongestStringWidth = [longestString sizeWithFont:[UIFont systemFontOfSize:fontSize]].width;
139 | if (actionTitleWidth > currentLongestStringWidth) {
140 | longestString = action.title;
141 | }
142 | }
143 | }
144 | for (int index = 0; index < rowActions.count; index++) {
145 | [placeholder appendString:longestString];
146 | }
147 | return placeholder;
148 | }
149 |
150 | @end
151 |
--------------------------------------------------------------------------------
/JZTableViewRowActionDemo/JZTableViewRowActionDemo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 401D568F1BF44F8B007A1C36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 401D568E1BF44F8B007A1C36 /* main.m */; };
11 | 401D56921BF44F8B007A1C36 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 401D56911BF44F8B007A1C36 /* AppDelegate.m */; };
12 | 401D56951BF44F8B007A1C36 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 401D56941BF44F8B007A1C36 /* ViewController.m */; };
13 | 401D56981BF44F8B007A1C36 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 401D56961BF44F8B007A1C36 /* Main.storyboard */; };
14 | 401D569A1BF44F8B007A1C36 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 401D56991BF44F8B007A1C36 /* Assets.xcassets */; };
15 | 401D569D1BF44F8B007A1C36 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 401D569B1BF44F8B007A1C36 /* LaunchScreen.storyboard */; };
16 | 401D56A81BF44F8C007A1C36 /* JZTableViewRowActionDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 401D56A71BF44F8C007A1C36 /* JZTableViewRowActionDemoTests.m */; };
17 | 401D56B31BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 401D56B21BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests.m */; };
18 | 401D56C51BF4522F007A1C36 /* UITableViewCell+JZExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 401D56C11BF4522F007A1C36 /* UITableViewCell+JZExtension.m */; };
19 | 401D56C61BF4522F007A1C36 /* UITableViewRowAction+JZExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 401D56C31BF4522F007A1C36 /* UITableViewRowAction+JZExtension.m */; };
20 | 401D56C71BF4522F007A1C36 /* UITableViewRowAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 401D56C41BF4522F007A1C36 /* UITableViewRowAction.m */; };
21 | /* End PBXBuildFile section */
22 |
23 | /* Begin PBXContainerItemProxy section */
24 | 401D56A41BF44F8C007A1C36 /* PBXContainerItemProxy */ = {
25 | isa = PBXContainerItemProxy;
26 | containerPortal = 401D56821BF44F8B007A1C36 /* Project object */;
27 | proxyType = 1;
28 | remoteGlobalIDString = 401D56891BF44F8B007A1C36;
29 | remoteInfo = JZTableViewRowActionDemo;
30 | };
31 | 401D56AF1BF44F8C007A1C36 /* PBXContainerItemProxy */ = {
32 | isa = PBXContainerItemProxy;
33 | containerPortal = 401D56821BF44F8B007A1C36 /* Project object */;
34 | proxyType = 1;
35 | remoteGlobalIDString = 401D56891BF44F8B007A1C36;
36 | remoteInfo = JZTableViewRowActionDemo;
37 | };
38 | /* End PBXContainerItemProxy section */
39 |
40 | /* Begin PBXFileReference section */
41 | 401D568A1BF44F8B007A1C36 /* JZTableViewRowActionDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JZTableViewRowActionDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
42 | 401D568E1BF44F8B007A1C36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
43 | 401D56901BF44F8B007A1C36 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
44 | 401D56911BF44F8B007A1C36 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
45 | 401D56931BF44F8B007A1C36 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
46 | 401D56941BF44F8B007A1C36 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
47 | 401D56971BF44F8B007A1C36 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
48 | 401D56991BF44F8B007A1C36 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
49 | 401D569C1BF44F8B007A1C36 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
50 | 401D569E1BF44F8B007A1C36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
51 | 401D56A31BF44F8C007A1C36 /* JZTableViewRowActionDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JZTableViewRowActionDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
52 | 401D56A71BF44F8C007A1C36 /* JZTableViewRowActionDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JZTableViewRowActionDemoTests.m; sourceTree = ""; };
53 | 401D56A91BF44F8C007A1C36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
54 | 401D56AE1BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JZTableViewRowActionDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
55 | 401D56B21BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JZTableViewRowActionDemoUITests.m; sourceTree = ""; };
56 | 401D56B41BF44F8C007A1C36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
57 | 401D56C11BF4522F007A1C36 /* UITableViewCell+JZExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITableViewCell+JZExtension.m"; sourceTree = ""; };
58 | 401D56C21BF4522F007A1C36 /* UITableViewRowAction+JZExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITableViewRowAction+JZExtension.h"; sourceTree = ""; };
59 | 401D56C31BF4522F007A1C36 /* UITableViewRowAction+JZExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITableViewRowAction+JZExtension.m"; sourceTree = ""; };
60 | 401D56C41BF4522F007A1C36 /* UITableViewRowAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UITableViewRowAction.m; sourceTree = ""; };
61 | /* End PBXFileReference section */
62 |
63 | /* Begin PBXFrameworksBuildPhase section */
64 | 401D56871BF44F8B007A1C36 /* Frameworks */ = {
65 | isa = PBXFrameworksBuildPhase;
66 | buildActionMask = 2147483647;
67 | files = (
68 | );
69 | runOnlyForDeploymentPostprocessing = 0;
70 | };
71 | 401D56A01BF44F8C007A1C36 /* Frameworks */ = {
72 | isa = PBXFrameworksBuildPhase;
73 | buildActionMask = 2147483647;
74 | files = (
75 | );
76 | runOnlyForDeploymentPostprocessing = 0;
77 | };
78 | 401D56AB1BF44F8C007A1C36 /* Frameworks */ = {
79 | isa = PBXFrameworksBuildPhase;
80 | buildActionMask = 2147483647;
81 | files = (
82 | );
83 | runOnlyForDeploymentPostprocessing = 0;
84 | };
85 | /* End PBXFrameworksBuildPhase section */
86 |
87 | /* Begin PBXGroup section */
88 | 401D56811BF44F8B007A1C36 = {
89 | isa = PBXGroup;
90 | children = (
91 | 401D568C1BF44F8B007A1C36 /* JZTableViewRowActionDemo */,
92 | 401D56A61BF44F8C007A1C36 /* JZTableViewRowActionDemoTests */,
93 | 401D56B11BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests */,
94 | 401D568B1BF44F8B007A1C36 /* Products */,
95 | );
96 | sourceTree = "";
97 | };
98 | 401D568B1BF44F8B007A1C36 /* Products */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 401D568A1BF44F8B007A1C36 /* JZTableViewRowActionDemo.app */,
102 | 401D56A31BF44F8C007A1C36 /* JZTableViewRowActionDemoTests.xctest */,
103 | 401D56AE1BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests.xctest */,
104 | );
105 | name = Products;
106 | sourceTree = "";
107 | };
108 | 401D568C1BF44F8B007A1C36 /* JZTableViewRowActionDemo */ = {
109 | isa = PBXGroup;
110 | children = (
111 | 401D56C01BF4522F007A1C36 /* JZTableViewRowAction */,
112 | 401D56901BF44F8B007A1C36 /* AppDelegate.h */,
113 | 401D56911BF44F8B007A1C36 /* AppDelegate.m */,
114 | 401D56931BF44F8B007A1C36 /* ViewController.h */,
115 | 401D56941BF44F8B007A1C36 /* ViewController.m */,
116 | 401D56961BF44F8B007A1C36 /* Main.storyboard */,
117 | 401D56991BF44F8B007A1C36 /* Assets.xcassets */,
118 | 401D569B1BF44F8B007A1C36 /* LaunchScreen.storyboard */,
119 | 401D569E1BF44F8B007A1C36 /* Info.plist */,
120 | 401D568D1BF44F8B007A1C36 /* Supporting Files */,
121 | );
122 | path = JZTableViewRowActionDemo;
123 | sourceTree = "";
124 | };
125 | 401D568D1BF44F8B007A1C36 /* Supporting Files */ = {
126 | isa = PBXGroup;
127 | children = (
128 | 401D568E1BF44F8B007A1C36 /* main.m */,
129 | );
130 | name = "Supporting Files";
131 | sourceTree = "";
132 | };
133 | 401D56A61BF44F8C007A1C36 /* JZTableViewRowActionDemoTests */ = {
134 | isa = PBXGroup;
135 | children = (
136 | 401D56A71BF44F8C007A1C36 /* JZTableViewRowActionDemoTests.m */,
137 | 401D56A91BF44F8C007A1C36 /* Info.plist */,
138 | );
139 | path = JZTableViewRowActionDemoTests;
140 | sourceTree = "";
141 | };
142 | 401D56B11BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests */ = {
143 | isa = PBXGroup;
144 | children = (
145 | 401D56B21BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests.m */,
146 | 401D56B41BF44F8C007A1C36 /* Info.plist */,
147 | );
148 | path = JZTableViewRowActionDemoUITests;
149 | sourceTree = "";
150 | };
151 | 401D56C01BF4522F007A1C36 /* JZTableViewRowAction */ = {
152 | isa = PBXGroup;
153 | children = (
154 | 401D56C11BF4522F007A1C36 /* UITableViewCell+JZExtension.m */,
155 | 401D56C21BF4522F007A1C36 /* UITableViewRowAction+JZExtension.h */,
156 | 401D56C31BF4522F007A1C36 /* UITableViewRowAction+JZExtension.m */,
157 | 401D56C41BF4522F007A1C36 /* UITableViewRowAction.m */,
158 | );
159 | path = JZTableViewRowAction;
160 | sourceTree = "";
161 | };
162 | /* End PBXGroup section */
163 |
164 | /* Begin PBXNativeTarget section */
165 | 401D56891BF44F8B007A1C36 /* JZTableViewRowActionDemo */ = {
166 | isa = PBXNativeTarget;
167 | buildConfigurationList = 401D56B71BF44F8C007A1C36 /* Build configuration list for PBXNativeTarget "JZTableViewRowActionDemo" */;
168 | buildPhases = (
169 | 401D56861BF44F8B007A1C36 /* Sources */,
170 | 401D56871BF44F8B007A1C36 /* Frameworks */,
171 | 401D56881BF44F8B007A1C36 /* Resources */,
172 | );
173 | buildRules = (
174 | );
175 | dependencies = (
176 | );
177 | name = JZTableViewRowActionDemo;
178 | productName = JZTableViewRowActionDemo;
179 | productReference = 401D568A1BF44F8B007A1C36 /* JZTableViewRowActionDemo.app */;
180 | productType = "com.apple.product-type.application";
181 | };
182 | 401D56A21BF44F8C007A1C36 /* JZTableViewRowActionDemoTests */ = {
183 | isa = PBXNativeTarget;
184 | buildConfigurationList = 401D56BA1BF44F8C007A1C36 /* Build configuration list for PBXNativeTarget "JZTableViewRowActionDemoTests" */;
185 | buildPhases = (
186 | 401D569F1BF44F8C007A1C36 /* Sources */,
187 | 401D56A01BF44F8C007A1C36 /* Frameworks */,
188 | 401D56A11BF44F8C007A1C36 /* Resources */,
189 | );
190 | buildRules = (
191 | );
192 | dependencies = (
193 | 401D56A51BF44F8C007A1C36 /* PBXTargetDependency */,
194 | );
195 | name = JZTableViewRowActionDemoTests;
196 | productName = JZTableViewRowActionDemoTests;
197 | productReference = 401D56A31BF44F8C007A1C36 /* JZTableViewRowActionDemoTests.xctest */;
198 | productType = "com.apple.product-type.bundle.unit-test";
199 | };
200 | 401D56AD1BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests */ = {
201 | isa = PBXNativeTarget;
202 | buildConfigurationList = 401D56BD1BF44F8C007A1C36 /* Build configuration list for PBXNativeTarget "JZTableViewRowActionDemoUITests" */;
203 | buildPhases = (
204 | 401D56AA1BF44F8C007A1C36 /* Sources */,
205 | 401D56AB1BF44F8C007A1C36 /* Frameworks */,
206 | 401D56AC1BF44F8C007A1C36 /* Resources */,
207 | );
208 | buildRules = (
209 | );
210 | dependencies = (
211 | 401D56B01BF44F8C007A1C36 /* PBXTargetDependency */,
212 | );
213 | name = JZTableViewRowActionDemoUITests;
214 | productName = JZTableViewRowActionDemoUITests;
215 | productReference = 401D56AE1BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests.xctest */;
216 | productType = "com.apple.product-type.bundle.ui-testing";
217 | };
218 | /* End PBXNativeTarget section */
219 |
220 | /* Begin PBXProject section */
221 | 401D56821BF44F8B007A1C36 /* Project object */ = {
222 | isa = PBXProject;
223 | attributes = {
224 | LastUpgradeCheck = 0710;
225 | ORGANIZATIONNAME = Jazys;
226 | TargetAttributes = {
227 | 401D56891BF44F8B007A1C36 = {
228 | CreatedOnToolsVersion = 7.1;
229 | };
230 | 401D56A21BF44F8C007A1C36 = {
231 | CreatedOnToolsVersion = 7.1;
232 | TestTargetID = 401D56891BF44F8B007A1C36;
233 | };
234 | 401D56AD1BF44F8C007A1C36 = {
235 | CreatedOnToolsVersion = 7.1;
236 | TestTargetID = 401D56891BF44F8B007A1C36;
237 | };
238 | };
239 | };
240 | buildConfigurationList = 401D56851BF44F8B007A1C36 /* Build configuration list for PBXProject "JZTableViewRowActionDemo" */;
241 | compatibilityVersion = "Xcode 3.2";
242 | developmentRegion = English;
243 | hasScannedForEncodings = 0;
244 | knownRegions = (
245 | en,
246 | Base,
247 | );
248 | mainGroup = 401D56811BF44F8B007A1C36;
249 | productRefGroup = 401D568B1BF44F8B007A1C36 /* Products */;
250 | projectDirPath = "";
251 | projectRoot = "";
252 | targets = (
253 | 401D56891BF44F8B007A1C36 /* JZTableViewRowActionDemo */,
254 | 401D56A21BF44F8C007A1C36 /* JZTableViewRowActionDemoTests */,
255 | 401D56AD1BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests */,
256 | );
257 | };
258 | /* End PBXProject section */
259 |
260 | /* Begin PBXResourcesBuildPhase section */
261 | 401D56881BF44F8B007A1C36 /* Resources */ = {
262 | isa = PBXResourcesBuildPhase;
263 | buildActionMask = 2147483647;
264 | files = (
265 | 401D569D1BF44F8B007A1C36 /* LaunchScreen.storyboard in Resources */,
266 | 401D569A1BF44F8B007A1C36 /* Assets.xcassets in Resources */,
267 | 401D56981BF44F8B007A1C36 /* Main.storyboard in Resources */,
268 | );
269 | runOnlyForDeploymentPostprocessing = 0;
270 | };
271 | 401D56A11BF44F8C007A1C36 /* Resources */ = {
272 | isa = PBXResourcesBuildPhase;
273 | buildActionMask = 2147483647;
274 | files = (
275 | );
276 | runOnlyForDeploymentPostprocessing = 0;
277 | };
278 | 401D56AC1BF44F8C007A1C36 /* Resources */ = {
279 | isa = PBXResourcesBuildPhase;
280 | buildActionMask = 2147483647;
281 | files = (
282 | );
283 | runOnlyForDeploymentPostprocessing = 0;
284 | };
285 | /* End PBXResourcesBuildPhase section */
286 |
287 | /* Begin PBXSourcesBuildPhase section */
288 | 401D56861BF44F8B007A1C36 /* Sources */ = {
289 | isa = PBXSourcesBuildPhase;
290 | buildActionMask = 2147483647;
291 | files = (
292 | 401D56C71BF4522F007A1C36 /* UITableViewRowAction.m in Sources */,
293 | 401D56951BF44F8B007A1C36 /* ViewController.m in Sources */,
294 | 401D56C51BF4522F007A1C36 /* UITableViewCell+JZExtension.m in Sources */,
295 | 401D56921BF44F8B007A1C36 /* AppDelegate.m in Sources */,
296 | 401D568F1BF44F8B007A1C36 /* main.m in Sources */,
297 | 401D56C61BF4522F007A1C36 /* UITableViewRowAction+JZExtension.m in Sources */,
298 | );
299 | runOnlyForDeploymentPostprocessing = 0;
300 | };
301 | 401D569F1BF44F8C007A1C36 /* Sources */ = {
302 | isa = PBXSourcesBuildPhase;
303 | buildActionMask = 2147483647;
304 | files = (
305 | 401D56A81BF44F8C007A1C36 /* JZTableViewRowActionDemoTests.m in Sources */,
306 | );
307 | runOnlyForDeploymentPostprocessing = 0;
308 | };
309 | 401D56AA1BF44F8C007A1C36 /* Sources */ = {
310 | isa = PBXSourcesBuildPhase;
311 | buildActionMask = 2147483647;
312 | files = (
313 | 401D56B31BF44F8C007A1C36 /* JZTableViewRowActionDemoUITests.m in Sources */,
314 | );
315 | runOnlyForDeploymentPostprocessing = 0;
316 | };
317 | /* End PBXSourcesBuildPhase section */
318 |
319 | /* Begin PBXTargetDependency section */
320 | 401D56A51BF44F8C007A1C36 /* PBXTargetDependency */ = {
321 | isa = PBXTargetDependency;
322 | target = 401D56891BF44F8B007A1C36 /* JZTableViewRowActionDemo */;
323 | targetProxy = 401D56A41BF44F8C007A1C36 /* PBXContainerItemProxy */;
324 | };
325 | 401D56B01BF44F8C007A1C36 /* PBXTargetDependency */ = {
326 | isa = PBXTargetDependency;
327 | target = 401D56891BF44F8B007A1C36 /* JZTableViewRowActionDemo */;
328 | targetProxy = 401D56AF1BF44F8C007A1C36 /* PBXContainerItemProxy */;
329 | };
330 | /* End PBXTargetDependency section */
331 |
332 | /* Begin PBXVariantGroup section */
333 | 401D56961BF44F8B007A1C36 /* Main.storyboard */ = {
334 | isa = PBXVariantGroup;
335 | children = (
336 | 401D56971BF44F8B007A1C36 /* Base */,
337 | );
338 | name = Main.storyboard;
339 | sourceTree = "";
340 | };
341 | 401D569B1BF44F8B007A1C36 /* LaunchScreen.storyboard */ = {
342 | isa = PBXVariantGroup;
343 | children = (
344 | 401D569C1BF44F8B007A1C36 /* Base */,
345 | );
346 | name = LaunchScreen.storyboard;
347 | sourceTree = "";
348 | };
349 | /* End PBXVariantGroup section */
350 |
351 | /* Begin XCBuildConfiguration section */
352 | 401D56B51BF44F8C007A1C36 /* Debug */ = {
353 | isa = XCBuildConfiguration;
354 | buildSettings = {
355 | ALWAYS_SEARCH_USER_PATHS = NO;
356 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
357 | CLANG_CXX_LIBRARY = "libc++";
358 | CLANG_ENABLE_MODULES = YES;
359 | CLANG_ENABLE_OBJC_ARC = YES;
360 | CLANG_WARN_BOOL_CONVERSION = YES;
361 | CLANG_WARN_CONSTANT_CONVERSION = YES;
362 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
363 | CLANG_WARN_EMPTY_BODY = YES;
364 | CLANG_WARN_ENUM_CONVERSION = YES;
365 | CLANG_WARN_INT_CONVERSION = YES;
366 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
367 | CLANG_WARN_UNREACHABLE_CODE = YES;
368 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
369 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
370 | COPY_PHASE_STRIP = NO;
371 | DEBUG_INFORMATION_FORMAT = dwarf;
372 | ENABLE_STRICT_OBJC_MSGSEND = YES;
373 | ENABLE_TESTABILITY = YES;
374 | GCC_C_LANGUAGE_STANDARD = gnu99;
375 | GCC_DYNAMIC_NO_PIC = NO;
376 | GCC_NO_COMMON_BLOCKS = YES;
377 | GCC_OPTIMIZATION_LEVEL = 0;
378 | GCC_PREPROCESSOR_DEFINITIONS = (
379 | "DEBUG=1",
380 | "$(inherited)",
381 | );
382 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
383 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
384 | GCC_WARN_UNDECLARED_SELECTOR = YES;
385 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
386 | GCC_WARN_UNUSED_FUNCTION = YES;
387 | GCC_WARN_UNUSED_VARIABLE = YES;
388 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
389 | MTL_ENABLE_DEBUG_INFO = YES;
390 | ONLY_ACTIVE_ARCH = YES;
391 | SDKROOT = iphoneos;
392 | TARGETED_DEVICE_FAMILY = "1,2";
393 | };
394 | name = Debug;
395 | };
396 | 401D56B61BF44F8C007A1C36 /* Release */ = {
397 | isa = XCBuildConfiguration;
398 | buildSettings = {
399 | ALWAYS_SEARCH_USER_PATHS = NO;
400 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
401 | CLANG_CXX_LIBRARY = "libc++";
402 | CLANG_ENABLE_MODULES = YES;
403 | CLANG_ENABLE_OBJC_ARC = YES;
404 | CLANG_WARN_BOOL_CONVERSION = YES;
405 | CLANG_WARN_CONSTANT_CONVERSION = YES;
406 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
407 | CLANG_WARN_EMPTY_BODY = YES;
408 | CLANG_WARN_ENUM_CONVERSION = YES;
409 | CLANG_WARN_INT_CONVERSION = YES;
410 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
411 | CLANG_WARN_UNREACHABLE_CODE = YES;
412 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
413 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
414 | COPY_PHASE_STRIP = NO;
415 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
416 | ENABLE_NS_ASSERTIONS = NO;
417 | ENABLE_STRICT_OBJC_MSGSEND = YES;
418 | GCC_C_LANGUAGE_STANDARD = gnu99;
419 | GCC_NO_COMMON_BLOCKS = YES;
420 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
421 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
422 | GCC_WARN_UNDECLARED_SELECTOR = YES;
423 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
424 | GCC_WARN_UNUSED_FUNCTION = YES;
425 | GCC_WARN_UNUSED_VARIABLE = YES;
426 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
427 | MTL_ENABLE_DEBUG_INFO = NO;
428 | SDKROOT = iphoneos;
429 | TARGETED_DEVICE_FAMILY = "1,2";
430 | VALIDATE_PRODUCT = YES;
431 | };
432 | name = Release;
433 | };
434 | 401D56B81BF44F8C007A1C36 /* Debug */ = {
435 | isa = XCBuildConfiguration;
436 | buildSettings = {
437 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
438 | INFOPLIST_FILE = JZTableViewRowActionDemo/Info.plist;
439 | IPHONEOS_DEPLOYMENT_TARGET = 6.0;
440 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
441 | PRODUCT_BUNDLE_IDENTIFIER = com.jazys.JZTableViewRowActionDemo;
442 | PRODUCT_NAME = "$(TARGET_NAME)";
443 | };
444 | name = Debug;
445 | };
446 | 401D56B91BF44F8C007A1C36 /* Release */ = {
447 | isa = XCBuildConfiguration;
448 | buildSettings = {
449 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
450 | INFOPLIST_FILE = JZTableViewRowActionDemo/Info.plist;
451 | IPHONEOS_DEPLOYMENT_TARGET = 6.0;
452 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
453 | PRODUCT_BUNDLE_IDENTIFIER = com.jazys.JZTableViewRowActionDemo;
454 | PRODUCT_NAME = "$(TARGET_NAME)";
455 | };
456 | name = Release;
457 | };
458 | 401D56BB1BF44F8C007A1C36 /* Debug */ = {
459 | isa = XCBuildConfiguration;
460 | buildSettings = {
461 | BUNDLE_LOADER = "$(TEST_HOST)";
462 | INFOPLIST_FILE = JZTableViewRowActionDemoTests/Info.plist;
463 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
464 | PRODUCT_BUNDLE_IDENTIFIER = com.jazys.JZTableViewRowActionDemoTests;
465 | PRODUCT_NAME = "$(TARGET_NAME)";
466 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JZTableViewRowActionDemo.app/JZTableViewRowActionDemo";
467 | };
468 | name = Debug;
469 | };
470 | 401D56BC1BF44F8C007A1C36 /* Release */ = {
471 | isa = XCBuildConfiguration;
472 | buildSettings = {
473 | BUNDLE_LOADER = "$(TEST_HOST)";
474 | INFOPLIST_FILE = JZTableViewRowActionDemoTests/Info.plist;
475 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
476 | PRODUCT_BUNDLE_IDENTIFIER = com.jazys.JZTableViewRowActionDemoTests;
477 | PRODUCT_NAME = "$(TARGET_NAME)";
478 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JZTableViewRowActionDemo.app/JZTableViewRowActionDemo";
479 | };
480 | name = Release;
481 | };
482 | 401D56BE1BF44F8C007A1C36 /* Debug */ = {
483 | isa = XCBuildConfiguration;
484 | buildSettings = {
485 | INFOPLIST_FILE = JZTableViewRowActionDemoUITests/Info.plist;
486 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
487 | PRODUCT_BUNDLE_IDENTIFIER = com.jazys.JZTableViewRowActionDemoUITests;
488 | PRODUCT_NAME = "$(TARGET_NAME)";
489 | TEST_TARGET_NAME = JZTableViewRowActionDemo;
490 | USES_XCTRUNNER = YES;
491 | };
492 | name = Debug;
493 | };
494 | 401D56BF1BF44F8C007A1C36 /* Release */ = {
495 | isa = XCBuildConfiguration;
496 | buildSettings = {
497 | INFOPLIST_FILE = JZTableViewRowActionDemoUITests/Info.plist;
498 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
499 | PRODUCT_BUNDLE_IDENTIFIER = com.jazys.JZTableViewRowActionDemoUITests;
500 | PRODUCT_NAME = "$(TARGET_NAME)";
501 | TEST_TARGET_NAME = JZTableViewRowActionDemo;
502 | USES_XCTRUNNER = YES;
503 | };
504 | name = Release;
505 | };
506 | /* End XCBuildConfiguration section */
507 |
508 | /* Begin XCConfigurationList section */
509 | 401D56851BF44F8B007A1C36 /* Build configuration list for PBXProject "JZTableViewRowActionDemo" */ = {
510 | isa = XCConfigurationList;
511 | buildConfigurations = (
512 | 401D56B51BF44F8C007A1C36 /* Debug */,
513 | 401D56B61BF44F8C007A1C36 /* Release */,
514 | );
515 | defaultConfigurationIsVisible = 0;
516 | defaultConfigurationName = Release;
517 | };
518 | 401D56B71BF44F8C007A1C36 /* Build configuration list for PBXNativeTarget "JZTableViewRowActionDemo" */ = {
519 | isa = XCConfigurationList;
520 | buildConfigurations = (
521 | 401D56B81BF44F8C007A1C36 /* Debug */,
522 | 401D56B91BF44F8C007A1C36 /* Release */,
523 | );
524 | defaultConfigurationIsVisible = 0;
525 | defaultConfigurationName = Release;
526 | };
527 | 401D56BA1BF44F8C007A1C36 /* Build configuration list for PBXNativeTarget "JZTableViewRowActionDemoTests" */ = {
528 | isa = XCConfigurationList;
529 | buildConfigurations = (
530 | 401D56BB1BF44F8C007A1C36 /* Debug */,
531 | 401D56BC1BF44F8C007A1C36 /* Release */,
532 | );
533 | defaultConfigurationIsVisible = 0;
534 | defaultConfigurationName = Release;
535 | };
536 | 401D56BD1BF44F8C007A1C36 /* Build configuration list for PBXNativeTarget "JZTableViewRowActionDemoUITests" */ = {
537 | isa = XCConfigurationList;
538 | buildConfigurations = (
539 | 401D56BE1BF44F8C007A1C36 /* Debug */,
540 | 401D56BF1BF44F8C007A1C36 /* Release */,
541 | );
542 | defaultConfigurationIsVisible = 0;
543 | defaultConfigurationName = Release;
544 | };
545 | /* End XCConfigurationList section */
546 | };
547 | rootObject = 401D56821BF44F8B007A1C36 /* Project object */;
548 | }
549 |
--------------------------------------------------------------------------------