gpt4 book ai didi

ios - 无法使用 ADLilyTableView

转载 作者:行者123 更新时间:2023-11-30 13:34:50 24 4
gpt4 key购买 nike

我想使用 ADLivelyTableView,但它不能很好地工作。

https://github.com/applidium/ADLivelyTableView

这是我的代码。

◯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;

----固定代码----

- (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];
}
<小时/>

以及“将 block 指针类型“ADLivelyTransform”(又名“NSTimerIntercal(^)CALayer *__strong,float)”转换为 C 指针类型“const void *”需要桥转换”的错误在

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

所以我注释掉这段代码并构建成功。

但是 tableView 单元格没有动画。

我该怎么办?

最佳答案

您可以尝试对ADLivelyTableView.m文件禁用arc,添加编译器标志-fno-objc-arc。更多详情请参见How can I disable ARC for a single file in a project?

如果您需要它,这是我的 ViewController.m 文件。您只需创建一个新项目并用它替换您的 ViewController 代码,您就会看到动画。

#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;
}

关于ios - 无法使用 ADLilyTableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36197178/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com