خرید بک لینک

Vote count: 0

I have One Tableview and Using custom Cell and in this Cell i have one TextView. The Problem is When i long press on this TextView Then automatically Show canPerformAction I have To Stop this because i have use my custom Popup (Copy and Delete) using longPress Else if This canPerformAction is not stoppable Then i have add Two parameter (Copy and Delete) and This delete function how to Remove Cell . Please Help me Here is my Code ON VIEW CONTROLLER

/*  override func canBecomeFirstResponder() -> Bool {
        retu false
    }
    */


    override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
        // You need to only retu true for the actions you want, otherwise you get the whole range of
        //  iOS actions. You can see this by just removing the if statement here.
        currentPopTipView?.dismissAnimated(true)
        //print(sender)

    if ( action == Selector("paste:") || action == Selector("cut:") ||
        action == Selector("copy:") ||
        action == Selector("select:") ||
        action == Selector("selectAll:") ||
        action == Selector("delete:") ||
        action == Selector("makeTextWritingDirectionLeftToRight:") ||
        action == Selector("makeTextWritingDirectionRightToLeft:") ||
        action == Selector("toggleBoldface:") ||
        action == Selector("toggleItalics:") ||
        action == Selector("toggleUnderline:")) {
            retu false
        }

        UIMenuController.sharedMenuController().menuVisible = false;
        self.resignFirstResponder();

        retu false;
    }
     func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{

  let longPress: UILongPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: "cellLongPressed_left:")
            longPress.delegate = self
            longPress.minimumPressDuration = 1
            longPress.numberOfTouchesRequired = 1

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

            cell.TypeOFPage = 0
            cell.selectionStyle = UITableViewCellSelectionStyle.None

            cell.addGestureRecognizer(longPress)

            cell.textView.selectable = true;

            cell.textView.scrollEnabled = false
           cell.textView.text = getMessage
}

ON TABLEVIEW CELL

class ChatCell_left: UITableViewCell {

  @IBOutlet var lbl_message:UILabel!
  @IBOutlet var lbl_time:UILabel!
   @IBOutlet var outzSideView:UIView!
   @IBOutlet weak var textView: UITextView! 
    var TypeOFPage:Int!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)


        textView?.layer.coerRadius = 10.0
        textView?.layer.masksToBounds = true

        lbl_time?.layer.coerRadius = 8.0
        lbl_time?.layer.masksToBounds = true

        // Configure the view for the selected state
    }
    func setCellText_message(text:String){
        textView.text = text
        textView.resolveHashTags_WWW()

    }
    func textView(textView: UITextView, shouldInteractWithURL URL: NSURL, inRange characterRange: NSRange) -> Bool {

        let link = "(URL)"
        if (TypeOFPage == 0) // Friend page
        {
            NSNotificationCenter.defaultCenter().postNotificationName("Click_link_friend_chat", object: link,
                userInfo: nil)
        }else    // stranger
        {

            NSNotificationCenter.defaultCenter().postNotificationName("Click_link_Stranger_chat", object: link,
                userInfo: nil)
        }


        retu false;
    }




    override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
        // You need to only retu true for the actions you want, otherwise you get the whole range of
        //  iOS actions. You can see this by just removing the if statement here.



        if ( action == Selector("paste:") || action == Selector("cut:") ||
            action == Selector("copy:") ||
            action == Selector("select:") ||
            action == Selector("selectAll:") ||
            action == Selector("delete:") ||
            action == Selector("makeTextWritingDirectionLeftToRight:") ||
            action == Selector("makeTextWritingDirectionRightToLeft:") ||
            action == Selector("toggleBoldface:") ||
            action == Selector("toggleItalics:") ||
            action == Selector("toggleUnderline:")) {
                retu false
        }
         UIMenuController.sharedMenuController().menuVisible = false;
        self.resignFirstResponder();
        retu false;
    }

}

I cant able to off textview userInteractionEnabled because in this textview link is clickable so if we off userInteractionEnabled then link is not click Please give me solution .

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 1 ارديبهشت 1395 ساعت: 16:02

صفحه بندی