Git Product home page Git Product logo

Comments (14)

Yourney avatar Yourney commented on August 29, 2024
    var cell = tableView.dequeueReusableCellWithIdentifier("SwipeableCell") as? MGSwipeTableCell

    if (cell == nil) {
        cell = MGSwipeTableCell(style: UITableViewCellStyle.Default, reuseIdentifier: "SwipeableCell")
    }

    let deleteButton = MGSwipeButton(title: "Delete", backgroundColor: UIColor.redColor(), callback: {
        (sender: MGSwipeTableCell!) -> Bool in
        // do Stuff 
        return true
    })
    cell?.leftButtons = [deleteButton]

from mgswipetablecell.

artworkad avatar artworkad commented on August 29, 2024

@Reza-Rg if you want to know how to use the *.h files in swift read this http://stackoverflow.com/a/24005242/401025

from mgswipetablecell.

theHellyar avatar theHellyar commented on August 29, 2024

Can you go into more depth on this...sorry I am not getting this to work...

from mgswipetablecell.

artworkad avatar artworkad commented on August 29, 2024

@theHellyar do you have a specific problem? What I did was:

  • install MGSwipeTableCell via cocoapods

  • create a "MyBridgingHeader.h" file if you haven't already and add

    #import "MGSwipeTableCell.h"
    #import "MGSwipeButton.h"

Then under Targets -> Build Settings -> Swift Compiler you have to add the file as Objective-C Bridging Header like described here http://stackoverflow.com/a/24005242/401025

from mgswipetablecell.

theHellyar avatar theHellyar commented on August 29, 2024

do you have a project to see it all linked up? I did those steps and the autofill was working for it but was't able to get the swipe actions to work.

If you could share your project or a sample project that had it all working together I would be abel to identify my problem....

from mgswipetablecell.

artworkad avatar artworkad commented on August 29, 2024

@theHellyar will do but probably not today, stay tuned.

from mgswipetablecell.

theHellyar avatar theHellyar commented on August 29, 2024

Nice. Got it working just wondering how to implement this with my own custom cell class

MGSwipeTableCell

var cell = tableView.dequeueReusableCellWithIdentifier("PriceListCell") as? MGSwipeTableCell

vs my custom UITableViewCell

var cell:PriceListCell = tableView.dequeueReusableCellWithIdentifier("PriceListCell") as PriceListCell

this was my issue from the start

from mgswipetablecell.

artworkad avatar artworkad commented on August 29, 2024

@theHellyar your custom cell class has to inherit from MGSwipeTableCell

from mgswipetablecell.

theHellyar avatar theHellyar commented on August 29, 2024

@artworkad Thanks so much. Got it working.

from mgswipetablecell.

grantkemp avatar grantkemp commented on August 29, 2024

Thanks guys, we should add this to readme.

from mgswipetablecell.

Reza-Rg avatar Reza-Rg commented on August 29, 2024

Thanks for your reply! I implemented this library in my swift project.

from mgswipetablecell.

MHX792 avatar MHX792 commented on August 29, 2024

I have a CustomCell class that inherits from MGSwipeTableCell:

class CustomCell: MGSwipeTableCell {
// properities
}

These are the settings for the prototype cell in Main.storyboard:

screen shot 2015-04-26 at 15 50 15

screen shot 2015-04-26 at 15 50 21

I've got this in ViewController.swift:

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! CustomCell

        let deleteButton = MGSwipeButton(title: "Delete", backgroundColor: UIColor.redColor(), callback: {
            (sender: MGSwipeTableCell!) -> Bool in
            // do Stuff
            return true
        })
        cell.leftButtons = [deleteButton]

        cell.textLabel?.text = arr[indexPath.row]
        return cell
    }

Building fails and I get these error messages:

screen shot 2015-04-26 at 15 45 06

When CustomCell class inherits from UITableViewCell the errors go away:

class CustomCell: UITableViewCell {
// properities
}

Note that I have to outcomment let deleteButton = ... and cell.leftButtons = [deleteButton] for it to work, since it doesn't inherit from MGSwipeTableCell anymore.

I think demo project with a sample swift integration would be really nice!

Edit:

I readded the .m and .h files to xcode now with these settings. Now swiping works:

screen shot 2015-04-26 at 16 05 29

Nevertheless it would still be good to see a demo project with swift integration. Keep up the good work!

from mgswipetablecell.

sravich avatar sravich commented on August 29, 2024

Whats the line we should be putting into our pod file? Sorry I am new to this is it
pod "MGSwipeTableCell"

from mgswipetablecell.

werediver avatar werediver commented on August 29, 2024

Important note: if you use Cocoapods with use_frameworks! option to install MGSwipeTableCell as a dynamic framework, you don't need the bridging header file. Instead you should use import MGSwipeTableCell in Swift code.

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.