2016-03-24 17 views
0

Ich möchte ADLivelyTableView verwenden, aber es konnte nicht gut funktionieren.ADLivelyTableView kann nicht verwendet werden

https://github.com/applidium/ADLivelyTableView

Hier ist mein 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; 

---- ---- Festcode

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

und der Fehler von "Cast des Block-Zeigertyps" ADLivelyTransform "(aka" NSTimerInt ercal (^) CALayer * __ stark, float) ') bis C Zeigertyp 'const void *' erfordert eine Brücke cast“verursacht bei

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

so dass ich diesen Code Kommentar aus und es gelang ihm aufzubauen.

Die Tabellenansichtszellen wurden jedoch nicht animiert.

was soll ich tun?

Antwort

0

Sie können versuchen, Arc für die Datei ADLivelyTableView.m zu deaktivieren, Compilerflag -fno-objc-arc hinzufügen. Weitere Einzelheiten finden Sie unter How can I disable ARC for a single file in a project?

Falls Sie jemals brauchen, hier ist meine ViewController.m Datei. Sie können einfach ein neues Projekt erstellen und Ihren ViewController-Code damit ersetzen, und Sie werden eine Animation sehen.

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

Thanks.The Fehler nicht erscheinen, aber die tableViewCell Animation hat nicht funktioniert ..... – bao

+0

Sie sollten Tableview Delegatmethoden implementieren, was meinst du nicht funktioniert? – gabbler

+0

Sind "tableView.delegate = self;" und "" nicht "TableView Delegate-Methoden"? Ich meine "nicht funktioniert" funktioniert nicht die Tableviewcell Animation, die von links erscheinen. – bao

Verwandte Themen