0

I want to use ADLivelyTableView but it couldn't work well.

https://github.com/applidium/ADLivelyTableView

Here is my code.

◯ViewController.h

#import "ADLivelyTableView.h"

@interface ViewController : GAITrackedViewController<UITableViewDelegate, UITableViewDataSource>
{

   ADLivelyTableView * tableView;

}

@property (nonatomic, retain) ADLivelyTableView *tableView;

◯ViewController.m

#import "ViewController.h"
#import "ADLivelyTableView.h"

@implementation ViewController
@synthesize tableView;

----Fixed code----

- (void)viewDidLoad {

    tableView = [[ADLivelyTableView alloc]initWithFrame:rect style:UITableViewStylePlain];
    //[transitionButton release];

    tableView.delegate = self;
    tableView.dataSource = self;
    tableView = (ADLivelyTableView *)self.tableView;
    tableView.initialCellTransformBlock = ADLivelyTransformFan;

    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
    NSString *cellIdentifier = @"Cell";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell){// yes
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

    [uv addSubview:tableView];

    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    //return self.feedManager.feedArray.count;

    return [[APP_DELEGATE titlearray] count];

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        NSString *cellIdentifier = @"Cell";
        UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        if (!cell){// yes
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        }

        // Update Cell
        [self updateCell:cell atIndexPath:indexPath];

        return cell;

}

- (void)updateCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{

        // Update Cells

        cell.backgroundColor = [UIColor clearColor];

        cell.textLabel.text = [[APP_DELEGATE titlearray] objectAtIndex:indexPath.row];

        cell.textLabel.textColor = [UIColor blackColor];
        cell.textLabel.font = [UIFont fontWithName:@"HiraKakuProN-W3" size:15];
        cell.textLabel.adjustsFontSizeToFitWidth = YES;
        cell.textLabel.minimumScaleFactor = 10.0f;
        cell.textLabel.numberOfLines = 0;

        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle != UITableViewCellEditingStyleDelete) {
        return;
    }

    [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    [self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationAutomatic];
}

and the error of "Cast of block pointer type "ADLivelyTransform" (aka "NSTimerIntercal(^)CALayer *__strong,float)') to C pointer type 'const void *' requires a bridge cast" caused at

if (block != _transformBlock) {
        Block_release(transformBlock);
        _transformBlock = Block_copy(block);
}

so I comment out this code and build succeeded.

But the tableView cells didn't animate.

what should I do?

K.K.D
  • 917
  • 1
  • 12
  • 27

1 Answers1

0

You can try to disable arc for the file ADLivelyTableView.m, add compiler flag -fno-objc-arc. More detail please see How can I disable ARC for a single file in a project?

In case you ever need it, here is my ViewController.m file. You can simply create a new project and replace your ViewController code with it, and you will see animation.

#import "ViewController.h"
#import "ADLivelyTableView.h"

@interface ViewController ()<UITabBarControllerDelegate, UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) ADLivelyTableView *tableView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    CGRect rect = self.view.bounds;
    self.tableView = [[ADLivelyTableView alloc]initWithFrame:rect style:UITableViewStylePlain];
     self.tableView = (ADLivelyTableView *)self.tableView;
     self.tableView.initialCellTransformBlock = ADLivelyTransformFan;

     self.tableView.delegate = self;
     self.tableView.dataSource = self;

    [self.view addSubview: self.tableView];

    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"TheCell"];

    // Do any additional setup after loading the view, typically from a nib.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TheCell" forIndexPath:indexPath];

    cell.textLabel.text = @"abc";

    UIColor * altBackgroundColor = [UIColor colorWithWhite:0.9f alpha:1.0f];
    cell.backgroundColor = [indexPath row] % 2 == 0 ? [UIColor whiteColor] : altBackgroundColor;
    cell.textLabel.backgroundColor = cell.backgroundColor;

    return cell;
}
Community
  • 1
  • 1
gabbler
  • 13,626
  • 4
  • 32
  • 44
  • You should implement tableview delegate methods, what do you mean by didn't work? – gabbler Mar 25 '16 at 15:49
  • Are "tableView.delegate = self;" and "" not "tableview delegate methods" ? I mean "didn't work" is not working the tableviewcell animation which appear from left. – K.K.D Mar 26 '16 at 08:41
  • Have you implemented `cellForRowAthIndexPath` method? – gabbler Mar 26 '16 at 08:44
  • yes, it does.I can succeed build, but the tableViewCell Animation doesn't work. – K.K.D Mar 29 '16 at 03:41
  • I basically used the same code as yours, except that in `viewDidLoad`, registered a cell class, `[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];` and I don't have tag and `updateCell ` method. – gabbler Mar 29 '16 at 04:14
  • I see.I added registered a cell class's code and fixed my code.(please check upside code) But the animation didn't work yet..... – K.K.D Mar 29 '16 at 05:21
  • There are duplicate code in your viewDidLoad method. If it didn't work delete those unnecessary code such as commitEditingStyle and pinpoint the problem. – gabbler Mar 29 '16 at 06:35
  • I want to add subView on UIView, but I can succeed only when I add subView on self.view.... – K.K.D Mar 29 '16 at 12:17
  • Sorry, I succeeded it! Thank you very much, you are god.And I'm sorry for my naive English.Thank you very much!!! – K.K.D Mar 29 '16 at 12:28