Giter Site home page Giter Site logo

thermogl / tiswipeabletableview Goto Github PK

View Code? Open in Web Editor NEW
810.0 810.0 74.0 628 KB

Allows you to swipe a UITableViewCell and reveal a back view, functions like cells in the "Twitter" app.

Home Page: http://thermoglobalnuclearwar.com/opensource/

Objective-C 100.00%

tiswipeabletableview's People

Contributors

fcy avatar jivadevoe avatar thermogl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiswipeabletableview's Issues

Swiping animation is working for me

Great project and thanks for sharing. I'm trying to implement this swipe functionality into my own custom UITableView implementation and the swiping action does reveal the back view and hides it on a subsequent swipe back or tapping another cell. What is missing is the bounce animation that I see when using the example project and while I've tried to tweak the duration it doesn't seem to affect the animation either. Please help?

Animations like in Sparrow

Hi there,

have you considered adding animations like they do in Sparrow? There the cell foreground sticks to your finger while swiping, instead of appearing and vanishing instantly.

Also the back view button doesn't appear for me when checking out and building the sample project. Is there anything special to consider?

Thanks!

How to add a TISwipeableTableView to a UIView?

Hi,

1st of all, thanks n congrats for making such a useful extension!

My issue is, I am unable to figure out how to add TISwipeableTableView to a UIView in a UIViewController Class.

Can you please guide on how to achieve this.

Also, please don't mind if this issue sounds very noob, as I am still a newbie!

Thanks!

Please let us know if more details are required.

iOS7.0beta bug .

Please fix it.
Here is exception log:
application launch
2013-06-26 21:51:20.853 SwipeableExample[13383:c07] -[UITableViewCellScrollView drawContentView:]: unrecognized selector sent to instance 0x8e792a0
2013-06-26 21:51:20.854 SwipeableExample[13383:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCellScrollView drawContentView:]: unrecognized selector sent to instance 0x8e792a0'
*** First throw call stack:
(0x217f028 0x1aa9902 0x221bb43 0x216f32b 0x216ef0e 0xa3fa 0x4c080e 0x151c497 0x151c3c8 0x140ebcc 0x151c360 0x155010f 0x151c1cb 0x151c417 0x151bbd4 0x151c3f1 0x1510597 0x1510616 0x147943c 0x147a7cf 0x15359c1 0x456bb7 0x457771 0x46cc6c 0x46d1d9 0x458e55 0x308cce2 0x308c7ed 0x20fa8d5 0x20fa60a 0x2125032 0x212459f 0x21243eb 0x456960 0x458b6b 0x8726 0x8695)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

Use TISwipeableTableView with custom xib uitableviewcell

Hello, i am trying to use your TISwipeableTableView, i have follow the example, and i'm using it with a subclass of UITableViewCell (like you do in the example) plus the xib file, all works, i can see my cell, if i swipe i can see the button tap me, but if i press the button tap don't call the delegate, this is the code:

#import "TISwipeableTableView.h"

@class MasterViewCell;

@protocol MasterViewCellDelegate <NSObject>
- (void)cellBackButtonWasTapped:(MasterViewCell *)cell;
@end

@interface MasterViewCell : TISwipeableTableViewCell {

id <MasterViewCellDelegate> delegate;
NSString * text;
 }

@property (nonatomic, assign) id <MasterViewCellDelegate> delegate;
@property (nonatomic, copy) NSString * text;

 - (void)drawShadowsWithHeight:(CGFloat)shadowHeight opacity:(CGFloat)opacity InRect:(CGRect)rect forContext:(CGContextRef)context;

@end

 #import "MasterViewCell.h"

 @implementation MasterViewCell

 - (void)buttonWasTapped:(UIButton *)button {

if ([delegate respondsToSelector:@selector(cellBackButtonWasTapped:)]){
    [delegate cellBackButtonWasTapped:self];
}
 }

 - (void)backViewWillAppear:(BOOL)animated {

UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonWasTapped:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Tap me" forState:UIControlStateNormal];
[button setFrame:CGRectMake(20, 4, self.backView.frame.size.width - 40, self.backView.frame.size.height - 8)];
[self.backView addSubview:button];
}

- (void)backViewDidDisappear:(BOOL)animated {
// Remove any subviews from the backView.
[self.backView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
 }

 - (void)drawBackView:(CGRect)rect {

[[UIImage imageNamed:@"meshpattern.png"] drawAsPatternInRect:rect];
[self drawShadowsWithHeight:10 opacity:0.3 InRect:rect forContext:UIGraphicsGetCurrentContext()];
 }

 - (void)drawShadowsWithHeight:(CGFloat)shadowHeight opacity:(CGFloat)opacity InRect:(CGRect)rect forContext:(CGContextRef)context {

CGColorSpaceRef space = CGBitmapContextGetColorSpace(context);

CGFloat topComponents[8] = {0, 0, 0, opacity, 0, 0, 0, 0};
CGGradientRef topGradient = CGGradientCreateWithColorComponents(space, topComponents, nil, 2);
CGPoint finishTop = CGPointMake(rect.origin.x, rect.origin.y + shadowHeight);
CGContextDrawLinearGradient(context, topGradient, rect.origin, finishTop, kCGGradientDrawsAfterEndLocation);

CGFloat bottomComponents[8] = {0, 0, 0, 0, 0, 0, 0, opacity};
CGGradientRef bottomGradient = CGGradientCreateWithColorComponents(space, bottomComponents, nil, 2);
CGPoint startBottom = CGPointMake(rect.origin.x, rect.size.height - shadowHeight);
CGPoint finishBottom = CGPointMake(rect.origin.x, rect.size.height);
CGContextDrawLinearGradient(context, bottomGradient, startBottom, finishBottom, kCGGradientDrawsAfterEndLocation);

CGGradientRelease(topGradient);
CGGradientRelease(bottomGradient);
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/

@end

Masterview.h
#import "MasterViewCell.h"

@interface MasterViewController : TISwipeableTableViewController <MasterViewCellDelegate> 

Masterview.m

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {

static NSString *CellIdentifier = @"MasterView";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MasterViewCustomCellImage" owner:self options:nil];
    cell = (MasterViewCell *)[nib objectAtIndex:0];
    //NSLog(@"Nuova Cella");
}

[self configureCell:cell atIndexPath:indexPath];
((MasterViewCell *) cell).delegate = self;


return cell;
 }

- (void)cellBackButtonWasTapped:(MasterViewCell *)cell {

UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"BackView Button"
                                                     message:@"WHOA! YOU TAPPED A BACKVIEW BUTTON!"
                                                    delegate:nil cancelButtonTitle:@"Sorry"
                                           otherButtonTitles:nil];
[alertView show];

[self hideVisibleBackView:YES];
}

how i can do?

Using this with interface built in Interface Builder

Hi,
Have some problems getting this to work with my custom cells made with Interface Builder. Have just started playing with iPhone development, so probably just some simple things I can't figure it out.

Is there anything you can tell me so I can make it work? :P Or do you know about any examples where I can see this used this way?

Thanks, Terw

Add Gesture on UIImageView in customCell

Hello, i don't know if you remember me :), i'm using your amazing TISwipe in my project, i have a xib file, and i have sublclassed my CustomCell with your TISwipe in this way:

@interface MasterViewCell : TISwipeableTableViewCell

all work fine, and i can swipe on the cell, but i'm trying to add a simple gesture like this:

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(mothe)];
[longPress setMinimumPressDuration:1.0];
[self.posterImage setUserInteractionEnabled:YES];
[self.posterImage addGestureRecognizer:longPress];

in a uiimageview on the custom cell, but i can't detect that gesture, i think because there is a problem with the TISwipeableTableViewCell...

Doesn't work with UISearchDisplayControllers

Accidently deleted the last post.

Title says it all, the solution is to do the swipe detection in the cell and use a subclassed UITableViewController to hide other cells' backviews.

Kinda working on it, but I've no need to use a UISearchDisplayController so it's not a priority.

Initialising the TISwipeableTableView in initWithStyle.

Something I've found happening if you init the table in the initWithStyle method in the UITableViewController, is that when the application receives a memory warning and is forced to unload something, the table is the first to go.

When the system gets the memory back, viewDidLoad is called, but obviously not initWithStyle. This presents a problem if the table is init'ed in initWithStyle. After the memory warning, the swipeable table view is no longer in use and is replaced with the standard UITableView, this results in the cells no longer being able to be swiped and can result in crashes.

I've updated the sample project to show the table being init'ed in viewDidLoad to overcome this issue.

Problem when adding accessory to cell

I'm attempting to implement a subclass of TISwipeableTableViewCell in iOS 4.2 with a UITableViewCellAccessoryDisclosureIndicator as the cell's accessory. I am setting the accessory type using "setAccessoryType:" in the table view controller's "cellForRowAtIndexPath:"

This seems to break both the swipe functionality and the cell highlighting. It works great without the accessory view. It can be reproduced in the sample project. Am I going about this incorrectly?

Your help is appreciated, and thanks for putting this project out. It is saving me a great deal of time.

Doesn't Work With UISearchDisplayControllers

Due to the fact we can't supply our own UITableViews to a UISearchDisplayController, when you do use one, the cell swiping doesn't work. Infact, most interactions perform pretty dreadfully.

I'm thinking a workaround to this is to do the swipe detection in the cell itself, but that leaves the problems of letting the other cells know they need to return to normal, and letting the table know a cell has been swiped.

A custom UITableViewController jumps to mind for this solution, but again, the UISearchDisplayController is a kind of controller in its own right and wouldn't get any custom delegate methods we passed along. Though, now I've mentioned it, a few things have jumped to mind on how to do this.

The NSNotificationCenter is another solution, but it seems a little too hacky. I avoid the NSNotificationCenter wherever possible.

Going to look into swipe detection in the cell, actually think I'm on to something now haha.

Adding a textlabel breaks the swipe effect

Hi!
I've just noticed that adding a textlabel like so: cell.textLabel.text = @"swipe" instead of using the deprecated UITableViewCell's method setText breaks the swipe effect . I dont have any accessory types associated to the cell. is this supposed to happen? Anyway, thank you very much for all the work you've put into this small, but valuable, project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.