• Stars
    star
    171
  • Rank 222,266 (Top 5 %)
  • Language
    Objective-C
  • Created over 12 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Custom UITableViewCell for iOS that supports multiple row selection

CRMultiRowSelect

CRMultiRowSelect is a custom UITableViewCell for iOS that supports multiple row selection in a UITableViewController.

Customize the color you want in just one line of code.

Everything is drawn with CoreGraphics NO IMAGES, so it supports Retina Display and looks beauty.

Demo screenshot

Customizable mark colors:

Marks screenshot

How To Use

  • Add CRTableViewCell.m and CRTableViewCell.h files to your XCode Project
  • In your UITableViewController.h add your 'selected marks' NSMutableArray:
@interface YourTableViewController : UITableViewController
{
    NSArray *dataSource;
    NSMutableArray *selectedMarks; // You need probably to save the selected cells for use in the future.
}
  • Customize your cellForRowAtIndexPath method implementation:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CRTableViewCellIdentifier = @"cellIdentifier";
    
    // init the CRTableViewCell
    CRTableViewCell *cell = (CRTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CRTableViewCellIdentifier];
    
    if (cell == nil) {
        cell = [[CRTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CRTableViewCellIdentifier];
    }
    
    // Check if the cell is currently selected (marked)
    NSString *text = [dataSource objectAtIndex:[indexPath row]];
    cell.isSelected = [selectedMarks containsObject:text] ? YES : NO;
    cell.textLabel.text = text;
    
    return cell;
}
  • Customize your didSelectRowAtIndexPath method implementation:
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *text = [dataSource objectAtIndex:[indexPath row]];
    
    if ([selectedMarks containsObject:text])// Is selected?
        [selectedMarks removeObject:text];
    else
        [selectedMarks addObject:text];
    
    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
  • You can customize the mark color using a HEX color, just change this line in the CRTableViewCell.m file
#define kMarkColor                  kBlueColor // or your HEX color, example: 0xfff000
  • Optionally you can get the selected cells using your previous declared NSMutableArray (example):
- (void)done:(id)sender
{
    NSLog(@"%@", selectedMarks);
}
  • Also, you can refer to the Demo Example in the CRTableViewController.m file

Requirements

  • Xcode 4.3 or higher
  • LLVM compiler
  • iOS 4.3 or higher
  • CoreGraphics Framework
  • ARC

License

Copyright 2012 Christian H. Roman Mendoza / Daniel Rueda Jimenez

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contact me

Christian Roman

Website: http://chroman.me

Contact: [email protected]

Twitter: http://twitter.com/chroman

Thanks for the support: Daniel Rueda Xtr3m0

More Repositories

1

CRGradientNavigationBar

Custom UINavigationBar subclass which allows gradient coloured navigation bar on iOS 7.
Objective-C
914
star
2

CRMotionView

A custom photo viewer that implements device motion scrolling, inspired by Facebook Paper.
Objective-C
758
star
3

Doppio

An open source iOS app to find the nearest Starbucks store using NSURLSession, AFNetworking 2.0, Mantle and Starbucks private API.
Objective-C
553
star
4

CRPixellatedView

Custom UIView subclass with a pixellated animation inspired by Facebook's Slingshot app.
Objective-C
375
star
5

ANPR

License plate recognition for iOS using OpenCV & Tesseract OCR Engine
C++
252
star
6

HeartBeats

Source code for iOS app to draw heart beats by reading color changes using the device flash led and CoreGraphics.
Objective-C
168
star
7

CRMediaPickerController

An easy-to-use UIImagePickerController replacement for picking Images and Videos.
Objective-C
165
star
8

CRGradientLabel

Custom UILabel subclass with gradient coloured background, written in Swift.
Swift
50
star
9

repuve-api

Python
13
star
10

df-gtfs

Script para importar dataset de "df_gtfs" a PostgreSQL
13
star
11

Ecobici

Ecobici+ iOS app. Disponibilidad inteligente de Ecobici, ciclovias y rutas seguras. #hackdf
Objective-C
10
star
12

API-SCT

API para consumir datos de rutas a traves de SCT
Ruby
9
star
13

XReset

Xcode Plugin to Reset iOS Simulators Content and Settings.
Objective-C
7
star
14

congreso

iOS app for #app115 challenge which Mexican House of Representatives announced that they were planning to pay $9.3 million to have an app developed. This an open source version and was presented at Mexican Congress.
Objective-C
7
star
15

FaceMemesCV

Live face detection & memes with OpenCV
C++
5
star
16

Toggle

Google Chrome extension to toggle between .h and .m source files on GitHub.
JavaScript
4
star
17

memeAR

iPhone app that detects real time faces and add memes
Objective-C
4
star
18

meds

Meds application for Android
Java
3
star
19

TextureViewDemo

Android TextureView Demo like the new Youtube app.
Java
3
star
20

chroMVC

PHP MVC framework based on Sinatra
JavaScript
2
star
21

cpmx4-chat

CPMX4 Node.js Chat
CSS
1
star
22

Programming-challenges

Programming challenges that solve in my free time from the book: The programming contest training manual
Java
1
star