# SWTableViewCell Deployment & Usage Guide
A comprehensive guide for integrating the SWTableViewCell library into iOS projects. This library provides swipeable UITableViewCell functionality with exposed utility buttons, similar to the iOS 7 Mail app.
## Prerequisites
- **macOS** 10.8 or later
- **Xcode** 5.0 or later (supports iOS 6.1 through iOS 7+)
- **iOS SDK** 6.1 or higher
- **CocoaPods** 0.33+ (optional, for CocoaPods installation)
- **Apple Developer Account** (required for testing on physical devices)
## Installation
### Method 1: CocoaPods (Recommended)
Add the dependency to your `Podfile`:
```ruby
platform :ios, '6.1'
pod 'SWTableViewCell', '~> 0.3.7'
Install the pod:
pod install
Open the generated .xcworkspace file:
open YourProject.xcworkspace
Method 2: Manual Integration
- Clone the repository:
git clone https://github.com/CEWendel/SWTableViewCell.git
-
Drag the following source files into your Xcode project:
SWTableViewCell.h/SWTableViewCell.mSWUtilityButtonView.h/SWUtilityButtonView.mSWUtilityButtonTapGestureRecognizer.h/SWUtilityButtonTapGestureRecognizer.mNSMutableArray+SWUtilityButtons.h/NSMutableArray+SWUtilityButtons.m
-
Ensure "Copy items if needed" is checked when adding files.
Configuration
1. Import Headers
In your view controller or custom cell implementation:
#import <SWTableViewCell.h>
#import "NSMutableArray+SWUtilityButtons.h"
2. Configure Utility Buttons
Create utility button arrays using the provided category methods:
- (NSArray *)rightButtons {
NSMutableArray *rightUtilityButtons = [NSMutableArray new];
[rightUtilityButtons sw_addUtilityButtonWithColor:
[UIColor colorWithRed:0.78f green:0.78f blue:0.8f alpha:1.0]
title:@"More"];
[rightUtilityButtons sw_addUtilityButtonWithColor:
[UIColor colorWithRed:1.0f green:0.231f blue:0.188 alpha:1.0f]
title:@"Delete"];
return rightUtilityButtons;
}
- (NSArray *)leftButtons {
NSMutableArray *leftUtilityButtons = [NSMutableArray new];
[leftUtilityButtons sw_addUtilityButtonWithColor:
[UIColor colorWithRed:0.07 green:0.75f blue:0.16f alpha:1.0]
icon:[UIImage imageNamed:@"check.png"]];
[leftUtilityButtons sw_addUtilityButtonWithColor:
[UIColor colorWithRed:1.0f green:1.0f blue:0.35f alpha:1.0]
icon:[UIImage imageNamed:@"clock.png"]];
return leftUtilityButtons;
}
3. Implement Cell Configuration
In your UITableViewDataSource:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Cell";
SWTableViewCell *cell = (SWTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[SWTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:cellIdentifier];
cell.leftUtilityButtons = [self leftButtons];
cell.rightUtilityButtons = [self rightButtons];
cell.delegate = self;
}
// Configure cell content
cell.textLabel.text = @"Your Content";
cell.detailTextLabel.text = @"Detail text";
return cell;
}
4. Implement Delegate Protocol
Adopt SWTableViewCellDelegate in your view controller:
@interface YourViewController () <SWTableViewCellDelegate>
@end
@implementation YourViewController
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index {
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
switch (index) {
case 0:
// Handle first left button
break;
case 1:
// Handle second left button
break;
default:
break;
}
[cell hideUtilityButtonsAnimated:YES];
}
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index {
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
switch (index) {
case 0:
// Handle "More" button
break;
case 1:
// Handle "Delete" button
[self.tableView deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
break;
default:
break;
}
}
- (BOOL)swipeableTableViewCellShouldHideUtilityButtonsOnSwipe:(SWTableViewCell *)cell {
return YES; // Forces cells to close when user swipes another cell
}
@end
5. Custom Interface Builder Cells (Optional)
For custom cells designed in Interface Builder:
- Set the custom class to your subclass of
SWTableViewCellin Identity Inspector - Set the reuse identifier in Attributes Inspector
- Register the nib in
viewDidLoadif using separate nib files:
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView registerNib:[UINib nibWithNibName:@"MyCustomCell" bundle:nil]
forCellReuseIdentifier:@"MyCustomCell"];
}
Build & Run
Development Build
- Select target device (iOS Simulator or connected device)
- Build the project: Cmd+B or:
xcodebuild -workspace YourProject.xcworkspace -scheme YourScheme -sdk iphonesimulator
- Run the application: Cmd+R
Production Build (Archive)
- Select "Generic iOS Device" or connected device as target
- Product → Archive (or Cmd+Shift+)
- Validate and distribute via Organizer window
Deployment
App Store Submission
Since SWTableViewCell is a static library integrated at compile time, no special deployment steps are required beyond standard iOS app submission:
- Ensure
Enable Bitcodeis set appropriately (library supports standard architectures) - Archive the application (Product → Archive)
- Upload to App Store Connect via Xcode Organizer or Application Loader
- Submit for review through App Store Connect
Library Distribution (CocoaPods)
If maintaining a fork or custom version:
- Update the
.podspecfile with version bump - Tag the release in git:
git tag -a 0.3.8 -m "Version 0.3.8"
git push origin 0.3.8
- Push to CocoaPods trunk:
pod trunk push SWTableViewCell.podspec
Troubleshooting
Cell Reuse Issues
Symptom: Utility buttons appear on wrong cells when scrolling
Solution: Ensure leftUtilityButtons and rightUtilityButtons are set inside if (cell == nil) block or reset in prepareForReuse
Delegate Methods Not Called
Symptom: Swipe works but button taps don't trigger delegate methods
Solution: Verify cell.delegate = self is set and the view controller implements SWTableViewCellDelegate
Gesture Conflicts
Symptom: Swipe gestures conflict with other gestures (e.g., navigation drawer)
Solution: Implement swipeableTableViewCellShouldHideUtilityButtonsOnSwipe: to return YES and ensure no other pan gesture recognizers are attached to the table view cells
Buttons Not Visible
Symptom: Swipe action occurs but buttons don't appear
Solution: Check that utility button arrays are populated before cell display. Verify button colors have valid alpha values (not transparent)
Build Errors (Manual Integration)
Symptom: "File not found" errors
Solution: Ensure NSMutableArray+SWUtilityButtons.h is added to the project and imported in files using the category methods
iOS Version Compatibility
Symptom: Crashes on iOS 6.1
Solution: Ensure deployment target is set to iOS 6.1 in Build Settings. The library uses autolayout APIs available in iOS 6.1+.