Git Product home page Git Product logo

Comments (19)

Errortype520 avatar Errortype520 commented on July 25, 2024 1

Still an issue using Swift 2, and Xcode 7. Cells do not swipe. Loading cell from XIB.

from mgswipetablecell.

MortimerGoro avatar MortimerGoro commented on July 25, 2024

Hi Philip,

Changing the superclass to MGSwipeTableCell and adding the left buttons should be enough.

I have a test using storyboards in the demo project but I can't reproduce the issue. Please, send me a testcase that reproduces the problem and I will debug it ;)

from mgswipetablecell.

brightsider avatar brightsider commented on July 25, 2024

+1
I'm create custom cell with subclass and this don't work (@interface CheckInCell : MGSwipeTableCell).
Work only with original cell.

from mgswipetablecell.

brightsider avatar brightsider commented on July 25, 2024

I'm fixing it - in subclassed cell added this:

  • (void)awakeFromNib
    {
    [super awakeFromNib];
    }

from mgswipetablecell.

MortimerGoro avatar MortimerGoro commented on July 25, 2024

Yeah, you should always call super methods because MGSwipeTableCell or the original UITableViewCell might have some work to do ;)

Philip, does the super method call fix your problem?

from mgswipetablecell.

hemangshah avatar hemangshah commented on July 25, 2024

Subclass MGSwipeTableCell instead of UITableViewCell
I've resolved the issue by implementing

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self) {
        //add your cell objects here
    }
    return self;
}

I commented,
//- (void)awakeFromNib {
// [super awakeFromNib];
//}

It works fine now,

In table view datasource implementation, its same like we are doing.

  static NSString *cellIdentifier = @"cellIdentifier";
  Custom *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  if(cell == nil) {
      cell = [[Custom alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  }

from mgswipetablecell.

mbellmbell avatar mbellmbell commented on July 25, 2024

Also having difficulty with subclassing MGSwipeCell. I don't get any swipe behavior when first displaying cells, but if I scroll cells out of view and then back into view the swipe behavior works for those cells.

The MGSwipeCell subclass loads its view from a nib.

from mgswipetablecell.

ellern avatar ellern commented on July 25, 2024

Me too, can't get it to work. I'm loading my tableview from a nib file.

In my viewDidLoad:
[self.tableView registerNib:[UINib nibWithNibName:@"CustomTableViewCell" bundle:nil] forCellReuseIdentifier:@"CustomReuseIdentifier"];

Then in tableView cellForRowAtIndexPath:
MGSwipeTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomReuseIdentifier" forIndexPath:indexPath];

The cells render fine, but I'm not able to swipe.

from mgswipetablecell.

waltermvp avatar waltermvp commented on July 25, 2024

I had the same issue. And also registered cells like so:

    [self.tableView registerNib:[UINib nibWithNibName:userCellIdentifier bundle:nil]
         forCellReuseIdentifier:userCellIdentifier];

Calling

    [super awakeFromNib];

fixed the issue

from mgswipetablecell.

ellern avatar ellern commented on July 25, 2024

Not working for me, any chance you can share your code?

from mgswipetablecell.

mbellmbell avatar mbellmbell commented on July 25, 2024

Yup.
-(void)awakeFromNib { [super awakeFromNib]; } in the MGSwipeTableCell subclass works for me.

from mgswipetablecell.

MortimerGoro avatar MortimerGoro commented on July 25, 2024

Fixed. I have implemented - (id)initWithCoder:(NSCoder*)aDecoder to avoid relying only on awakeFromNib to do some internal initializations. Now it works even if you don't call [super awakeFromNib].

from mgswipetablecell.

scorpionking2k5 avatar scorpionking2k5 commented on July 25, 2024

Using a subclass with a nib.
Tried using with and without delegate.
Delegate methods get called but nothing happening still. Failing to get any swipe action at all.

Tried all the solutions mentioned above. Nothing still working.

iOS 8 + iPad 2 simulator + XCode 6.1.1

from mgswipetablecell.

jaisongreen avatar jaisongreen commented on July 25, 2024

I am having the same issue as scorpionking2k5.

Subclassing with a XIB, delegate methods get called but swipe buttons dont show up at all.

from mgswipetablecell.

 avatar commented on July 25, 2024

I have exactly the same problem. Swipe fails to work when loading the cell from xib; otherwise it works fine.

from mgswipetablecell.

siralam avatar siralam commented on July 25, 2024

Reporting same problem as above.

The way I do this is:

In ViewController:

        tableView.register(CustomTableCell.self, forCellReuseIdentifier: "Cell")
        tableView.dataSource = self
        tableView.delegate = self

CustomTableCell.swift:

class CustomTableCell: MGSwipeTableCell {
    
    @IBOutlet var rootView: UIView!
    @IBOutlet weak var itemName: UILabel!
    @IBOutlet weak var itemRating: UILabel!
    @IBOutlet weak var itemSwitch: UISwitch!
    
    required override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        commonInit()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        commonInit()
    }
    
    private func commonInit () {
        Bundle.main.loadNibNamed("CustomTableCell", owner: self, options: nil)
        addSubview(rootView)
        rootView.frame = self.bounds
        rootView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
    }
    
}

from mgswipetablecell.

bineshpavithran avatar bineshpavithran commented on July 25, 2024

same issue here, swiping is not working when cell is loaded from a xib file. Any solution?

from mgswipetablecell.

richardlevy avatar richardlevy commented on July 25, 2024

This is happening for me. I just migrated a cell from storyboard to a XIB to make it reusable and swipes don't work. I can see that it receives pan gestures OK and is setting offsets but nothing appears on the screen. I've got super calls to awakeFromNib, and initWithDecoder but nothing ever gets displayed.

I've even tried calling the interval initViews later in the lifecycle to see if that helps and it doesn't.

I've updated to the latest source too.

Still, nothing.

Did anyone crack this?

from mgswipetablecell.

richardlevy avatar richardlevy commented on July 25, 2024

I cracked this!

It was my fault of course. In the XIB, which I had created separately from the class, I had created my layout inside the default view (which was a UIView). I should have dragged a UITableViewCell in and created my view with that.

Once I did that it worked fine!

from mgswipetablecell.

Related Issues (20)

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.