Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can these message be scrolled? #9

Open
satyamub opened this issue Feb 11, 2016 · 7 comments
Open

Can these message be scrolled? #9

satyamub opened this issue Feb 11, 2016 · 7 comments

Comments

@satyamub
Copy link

I wanted to unhide the cells so that they don't get invisible. That I am able to do however if user wants to see the previous messages then it is not scrolling!!!

@satyamub
Copy link
Author

Can you please help me out?

@yoavlt
Copy link
Owner

yoavlt commented Feb 11, 2016

Sorry, it's not supported yet. Now, PeriscommentView hide comments automatically.

@satyamub
Copy link
Author

I am able to unhide and I am able to see them however they don't scroll. can you please add scrollview to the periscommentview so that added cell will will be scrolled. You know some people will seek like this. With intelligent like you people can make this

@satyamub
Copy link
Author

public class PeriscommentView: UIView {

private var visibleCells: [PeriscommentCell] = []
private var config: PeriscommentConfig

var scrollView: UIScrollView!
var containerView = UIView()

convenience override init(frame: CGRect) {
    let config = PeriscommentConfig()
    self.init(frame: frame, config: config)
    self.scrollView = UIScrollView()
    self.scrollView.frame = CGRectMake(0, 0, 600, 600)
    self.scrollView.contentSize = CGSizeMake(600, 600)

    //scrollView.frame = view.bounds
    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 800, 800)


    scrollView.addSubview(containerView)
    self.addSubview(scrollView)
}

required public init(coder aDecoder: NSCoder) {
    self.config = PeriscommentConfig()
    super.init(coder: aDecoder)!
    self.scrollView = UIScrollView()
    self.scrollView.frame = CGRectMake(0, 0, 600, 600)
    self.scrollView.contentSize = CGSizeMake(600, 600)

    //scrollView.frame = view.bounds
    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 800, 800)


    scrollView.addSubview(containerView)
    self.addSubview(scrollView)
}
init(frame: CGRect, config: PeriscommentConfig) {
    self.config = config
    super.init(frame: frame)
    self.scrollView = UIScrollView()
    self.scrollView.frame = CGRectMake(0, 0, 600, 600)
    self.scrollView.contentSize = CGSizeMake(600, 600)

    //scrollView.frame = view.bounds
    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 800, 800)


    scrollView.addSubview(containerView)
    self.addSubview(scrollView)
}

override public func willMoveToSuperview(newSuperview: UIView?) {
    super.willMoveToSuperview(newSuperview)
    setupView()
}

private func setupView() {
    self.backgroundColor = config.layout.backgroundColor
}

public func addCell(cell: PeriscommentCell) {
    cell.frame = CGRect(origin: CGPoint(x: 0, y: self.frame.height), size: cell.frame.size)
    visibleCells.append(cell)
    self.containerView.addSubview(cell)

    UIView.animateWithDuration(self.config.appearDuration, delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
        let dy = cell.frame.height + self.config.layout.cellSpace
        for c in self.visibleCells {
            let origin = c.transform
            let transform = CGAffineTransformMakeTranslation(0, -dy)
            c.transform = CGAffineTransformConcat(origin, transform)
        }
    }, completion: nil)

    UIView.animateWithDuration(self.config.disappearDuration, delay: self.config.appearDuration, options: UIViewAnimationOptions.CurveEaseIn, animations: { () -> Void in
       // cell.alpha = 0.0
    }) { (Bool) -> Void in
       // cell.removeFromSuperview()
       // self.visibleCells.removeAtIndex(self.visibleCells.indexOf(cell)!)
    }
}

public func addCell(profileImage: UIImage, name: String, comment: String) {
    let rect = CGRect.zero
    let cell = PeriscommentCell(frame: rect, profileImage: profileImage, name: name, comment: comment, config: self.config)

    self.addCell(cell)
}

}

@satyamub
Copy link
Author

I am trying to add a scrollview and then in that I am adding a container view so that cells can be added to it and can be scrolled however its not working!!

@satyamub
Copy link
Author

I have tried to add the scrollview. Its like floating the comments. Can you please look into it

import UIKit

public class PeriscommentView: UIView {

private var visibleCells: [PeriscommentCell] = []
private var config: PeriscommentConfig

var scrollView: UIScrollView!
var containerView = UIView()

convenience override init(frame: CGRect) {
    let config = PeriscommentConfig()
    self.init(frame: frame, config: config)
    self.scrollView = UIScrollView()
    scrollView.frame = self.bounds
    self.scrollView.contentSize = CGSize(width:800, height: 800)



    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 800, 800)

    self.scrollView.userInteractionEnabled = true
    scrollView.addSubview(containerView)
    self.addSubview(scrollView)
}

required public init(coder aDecoder: NSCoder) {
    self.config = PeriscommentConfig()
    super.init(coder: aDecoder)!
    self.scrollView = UIScrollView()
    scrollView.frame = self.bounds
    self.scrollView.contentSize = CGSize(width:800, height: 800)



    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 800, 800)

    self.scrollView.userInteractionEnabled = true
    scrollView.addSubview(containerView)
    self.addSubview(scrollView)
}
init(frame: CGRect, config: PeriscommentConfig) {
    self.config = config
    super.init(frame: frame)
    self.scrollView = UIScrollView()
    scrollView.frame = self.bounds
    self.scrollView.contentSize = CGSize(width:800, height: 800)



    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 800, 800)

    self.scrollView.userInteractionEnabled = true
    scrollView.addSubview(containerView)
    self.addSubview(scrollView)

}

override public func willMoveToSuperview(newSuperview: UIView?) {
    super.willMoveToSuperview(newSuperview)
    setupView()
}

private func setupView() {
    self.backgroundColor = config.layout.backgroundColor
}

public func addCell(cell: PeriscommentCell) {
    cell.frame = CGRect(origin: CGPoint(x: 0, y: self.frame.height), size: cell.frame.size)
    visibleCells.append(cell)
    self.containerView.addSubview(cell)

    UIView.animateWithDuration(self.config.appearDuration, delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
        let dy = cell.frame.height + self.config.layout.cellSpace
        for c in self.visibleCells {
            let origin = c.transform
            let transform = CGAffineTransformMakeTranslation(0, -dy)
            c.transform = CGAffineTransformConcat(origin, transform)
        }
    }, completion: nil)

    UIView.animateWithDuration(self.config.disappearDuration, delay: self.config.appearDuration, options: UIViewAnimationOptions.CurveEaseIn, animations: { () -> Void in
       // cell.alpha = 0.0
    }) { (Bool) -> Void in
       // cell.removeFromSuperview()
       // self.visibleCells.removeAtIndex(self.visibleCells.indexOf(cell)!)
    }
}

public func addCell(profileImage: UIImage, name: String, comment: String) {
    let rect = CGRect.zero
    let cell = PeriscommentCell(frame: rect, profileImage: profileImage, name: name, comment: comment, config: self.config)

    self.addCell(cell)
}

}

@satyamub
Copy link
Author

Everything is up and its scrolling however edge insect issue is there why can you please check

//
// PeriscommentView.swift
// PeriscommentView
//
// Created by Takuma Yoshida on 2015/04/08.
// Copyright (c) 2015 Uniface, Inc. All rights reserved.
//

import UIKit

public class PeriscommentView: UIView {

private var visibleCells: [PeriscommentCell] = []
private var config: PeriscommentConfig

var scrollView: UIScrollView!
var containerView = UIView()

convenience override init(frame: CGRect) {
    let config = PeriscommentConfig()
    self.init(frame: frame, config: config)
    self.scrollView = UIScrollView()
    scrollView.frame = CGRectMake(0, 0, 600, 800)
    self.scrollView.contentSize = CGSize(width:600, height: 800)
    self.scrollView.contentInset = UIEdgeInsets(top: 380.0, left:  0.0, bottom: 0.0, right: 0.0)


    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 600, 1000)

    self.scrollView.userInteractionEnabled = true
    scrollView.addSubview(containerView)
    self.addSubview(scrollView)
}

required public init(coder aDecoder: NSCoder) {
    self.config = PeriscommentConfig()
    super.init(coder: aDecoder)!
    self.scrollView = UIScrollView()
    scrollView.frame = CGRectMake(0, 0, 600, 800)
    self.scrollView.contentSize = CGSize(width:600, height: 800)
    self.scrollView.contentInset = UIEdgeInsets(top: 380.0, left:  0.0, bottom: 0.0, right: 0.0)



    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 600, 1000)

    self.scrollView.userInteractionEnabled = true
    scrollView.addSubview(containerView)
    self.addSubview(scrollView)
}
init(frame: CGRect, config: PeriscommentConfig) {
    self.config = config
    super.init(frame: frame)
    self.scrollView = UIScrollView()
    scrollView.frame = CGRectMake(0, 0, 600, 800)
    self.scrollView.contentSize = CGSize(width:600, height: 800)
    self.scrollView.contentInset = UIEdgeInsets(top: 380.0, left:  0.0, bottom: 0.0, right: 0.0)



    containerView = UIView()
    containerView.frame = CGRectMake(0, 0, 600, 1000)

    self.scrollView.userInteractionEnabled = true
    scrollView.addSubview(containerView)
    self.addSubview(scrollView)

}

override public func willMoveToSuperview(newSuperview: UIView?) {
    super.willMoveToSuperview(newSuperview)
    setupView()
}

private func setupView() {
    self.backgroundColor = config.layout.backgroundColor
}

public func addCell(cell: PeriscommentCell) {
    cell.frame = CGRect(origin: CGPoint(x: 0, y: self.frame.height), size: cell.frame.size)
    visibleCells.append(cell)
    self.containerView.addSubview(cell)

    UIView.animateWithDuration(self.config.appearDuration, delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
        let dy = cell.frame.height + self.config.layout.cellSpace
        for c in self.visibleCells {
            let origin = c.transform
            let transform = CGAffineTransformMakeTranslation(0, -dy)
            c.transform = CGAffineTransformConcat(origin, transform)
        }
        }, completion: nil)

    UIView.animateWithDuration(self.config.disappearDuration, delay: self.config.appearDuration, options: UIViewAnimationOptions.CurveEaseIn, animations: { () -> Void in
        // cell.alpha = 0.0
        }) { (Bool) -> Void in
            // cell.removeFromSuperview()
            // self.visibleCells.removeAtIndex(self.visibleCells.indexOf(cell)!)
    }
}

public func addCell(profileImage: UIImage, name: String, comment: String) {
    let rect = CGRect.zero
    let cell = PeriscommentCell(frame: rect, profileImage: profileImage, name: name, comment: comment, config: self.config)

    self.addCell(cell)
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants