Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func updateCell(path:Int){
- self.data = self.getData.feed
- let indexPath = NSIndexPath(forRow: path, inSection: 0)
- self.tableView.beginUpdates()
- self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade) //try other animations
- self.tableView.endUpdates()
- }
- override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
- var cell:PhotoCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as PhotoCell
- if data[indexPath.row].objectId == ""{
- //getData.getData(self, cellId: indexPath.row)
- getData.FeedQueue(self, cellId: indexPath.row)
- }else if data[indexPath.row].loading == 0{
- getData.FeedQueue(self, cellId: indexPath.row)
- }else{
- if Coz().CheckSystemVersion("8.0"){
- var subviews = cell.subviews
- for view in subviews{
- view.removeFromSuperview()
- }
- }else{
- for view in cell.contentView.subviews{
- if view.isKindOfClass(UIView){
- view.removeFromSuperview()
- }
- }
- }
- }
- let screenSize: CGRect = UIScreen.mainScreen().bounds
- let screenWidth = screenSize.width;
- var rect = CGRectMake(0, 0, screenWidth, screenWidth)
- var imageSizes:CGFloat = 40
- let imgButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
- imgButton.tag = indexPath.row
- imgButton.frame = rect
- imgButton.setBackgroundImage(data[indexPath.row].file, forState: .Normal)
- imgButton.addTarget(self, action: "imgButton:", forControlEvents: UIControlEvents.TouchUpInside)
- cell.addSubview(imgButton)
- var sumLike = data[indexPath.row].likeCount - data[indexPath.row].dislikeCount
- cell.setTableUp(data[indexPath.row].file, tTag:indexPath.row, screenWidth:screenWidth, commentCount:data[indexPath.row].commentCount, sumLikeCount:sumLike, identification:data[indexPath.row].objectId, sender:self, feed:data[indexPath.row], from:"FeedVC")
- return cell
- }
- ////////
- PhotoCell class
- ///////
- var IdOfObject:String = ""
- var senderView:AnyObject!
- var cellData:FeedData!
- var cellTag:Int!
- var fromView:String!
- var thisImage:UIImage!
- override func awakeFromNib() {
- super.awakeFromNib()
- }
- override func setSelected(selected: Bool, animated: Bool) {
- super.setSelected(selected, animated: animated)
- // Configure the view for the selected state
- }
- func setTableUp(tImage:UIImage, tTag:Int, screenWidth:CGFloat, commentCount: Int, sumLikeCount:Int, identification:String, sender:AnyObject, feed:FeedData, from:String){
- thisImage = tImage
- fromView = from
- cellTag = tTag
- cellData = feed
- senderView = sender
- IdOfObject = identification
- backgroundColor = Coz.GlobalVariables.ThemeSecondColor
- var rect = CGRectMake(0, 0, screenWidth, screenWidth + 38)
- frame = rect
- var imageSizes:CGFloat = 30
- var imageTintColors:UIColor = Coz.GlobalVariables.ThemeColor
- var clickedId = IdOfObject
- var idForUserDefaults = "p" + clickedId
- var userDefaults = NSUserDefaults.standardUserDefaults()
- var defaultValue: AnyObject? = userDefaults.valueForKey(idForUserDefaults)
- //Control Bar Under The Picture
- var controlBar:UIView = UIView(frame: CGRectMake(0, screenWidth, screenWidth, 38))
- //Like Up Button
- let upButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
- upButton.tag = tTag
- upButton.frame = CGRectMake(10, 5, imageSizes, imageSizes)
- upButton.tintColor = imageTintColors
- upButton.setImage(UIImage(named: "up.png"), forState: UIControlState.Normal)
- upButton.addTarget(self, action: "upButtonAction:", forControlEvents: UIControlEvents.TouchUpInside)
- if defaultValue?.integerValue == 1{
- upButton.tintColor = UIColor.blueColor()
- }
- controlBar.addSubview(upButton)
- //Like Count Label
- let likeCount = UILabel(frame: CGRectMake(40, 5, imageSizes, imageSizes))
- likeCount.textColor = imageTintColors
- likeCount.text = String(sumLikeCount)
- likeCount.font = UIFont(name: Coz.GlobalVariables.ThemeFontName, size: 17)
- likeCount.textAlignment = NSTextAlignment.Center
- controlBar.addSubview(likeCount)
- //Like Down Button
- let downButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
- downButton.tag = tTag
- downButton.frame = CGRectMake(70, 5, imageSizes, imageSizes)
- downButton.tintColor = imageTintColors
- downButton.setImage(UIImage(named: "down.png"), forState: UIControlState.Normal)
- downButton.addTarget(self, action: "downButtonAction:", forControlEvents: UIControlEvents.TouchUpInside)
- if defaultValue?.integerValue == -1{
- downButton.tintColor = UIColor.blueColor()
- }
- controlBar.addSubview(downButton)
- //Comment Button
- let commentButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
- commentButton.tag = tTag
- commentButton.frame = CGRectMake(screenWidth - screenWidth/5 - 25 - imageSizes, 5, imageSizes, imageSizes)
- commentButton.tintColor = imageTintColors
- commentButton.setImage(UIImage(named: "comment.png"), forState: UIControlState.Normal)
- commentButton.addTarget(self, action: "commentButtonAction:", forControlEvents: UIControlEvents.TouchUpInside)
- controlBar.addSubview(commentButton)
- //Comment Count Label
- let commentCountLabel = UILabel(frame: CGRectMake(screenWidth - screenWidth/5 - 25 - imageSizes, 2.5, imageSizes, imageSizes))
- commentCountLabel.textColor = imageTintColors
- commentCountLabel.text = String(commentCount)
- commentCountLabel.textAlignment = NSTextAlignment.Center
- commentCountLabel.font = UIFont(name: Coz.GlobalVariables.ThemeFontName, size: 17)
- controlBar.addSubview(commentCountLabel)
- //Share Button
- let shareButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
- shareButton.tag = tTag
- shareButton.frame = CGRectMake(screenWidth - screenWidth/5 - 10, 4, screenWidth/5, imageSizes)
- shareButton.tintColor = imageTintColors
- shareButton.backgroundColor = Coz.GlobalVariables.ThemeColor
- shareButton.setTitle(NSLocalizedString("shareButton", comment: ""), forState: UIControlState.Normal)
- shareButton.setTitleColor(backgroundColor, forState: UIControlState.Normal)
- shareButton.titleLabel?.font = UIFont(name: Coz.GlobalVariables.ThemeFontName, size: 17)
- shareButton.addTarget(self, action: "shareButtonAction:", forControlEvents: UIControlEvents.TouchUpInside)
- shareButton.layer.cornerRadius = 5
- shareButton.clipsToBounds = true
- controlBar.addSubview(shareButton)
- addSubview(controlBar)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement