0

カスタム フレームワークを使用しており、'TableView' と 'TableViewCell' のサブクラスをカスタム フレームワークに設定する必要があります。私は通常、ID インスペクターを使用してこれを簡単に実行しますが、プログラムですべてを作成したため、その方法がわかりません。ストーリーボードも使用していません。任意のヒント?

- -編集 - -

TableViewController.h

#import <UIKit/UIKit.h>
#import "Tasks.h"
#import "Properties2ViewController.h"
#import "PKRevealController.h"
#import "FMMoveTableView.h"
#import "FMMoveTableViewCell.h"
#import "DetailViewController.h"
@interface ToDoTableViewController : UITableViewController <Properties2ViewControllerDelegate, UITableViewDelegate, FMMoveTableViewDataSource>
@property (strong, nonatomic) NSMutableArray *taskArray;
-(IBAction)addCell:(id)sender;
@end

TableViewController.m

#import "ToDoTableViewController.h"

@implementation ToDoTableViewController
@synthesize taskArray;
- (id)init {
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
        UINavigationItem *i = [self navigationItem];
        [i setTitle:@"Task List"];
        [[i title] uppercaseString];
        UIBarButtonItem *bbi = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addCell:)];
        [[self navigationItem] setRightBarButtonItem:bbi];
        [self.tableView setSeparatorColor:[UIColor colorWithRed:26.0/255 green:188.0/255 blue:156.0/255 alpha:1.0f]];
        [self.tableView setBackgroundView:nil];
        [self.tableView setBackgroundColor:[UIColor colorWithRed:26.0/255 green:188.0/255 blue:156.0/255 alpha:1.0f]];
    }
    return self;
}
- (id) initWithStyle:(UITableViewStyle)style{
    return [self init];
}
-(void) viewDidLoad{
    FMMoveTableView *mtc = [[FMMoveTableView alloc]init];
    [mtc setDataSource:self];
    [self.tableView setDelegate:self];
    taskArray = [[NSMutableArray alloc] init];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    if (!cell)
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"UITableViewCell"];
    NSString *detailText = [NSString stringWithFormat:@"%.0f", [[taskArray objectAtIndex:[indexPath row]] timeInterval]];

    [[cell textLabel] setText:[[taskArray objectAtIndex:[indexPath row]] taskName]];
    cell.textLabel.text = [[[taskArray objectAtIndex:[indexPath row]] taskName] uppercaseString];
    [[cell textLabel] setFont:[UIFont fontWithName:@"AvenirNext-DemiBold" size:15]];
    [cell setBackgroundColor:[UIColor colorWithRed:236.0/255 green:240.0/255 blue:241.0/255 alpha:1.0f]];
    cell.textLabel.textColor = [UIColor colorWithRed:26.0/255 green:188.0/255 blue:156.0/255 alpha:1.0f];

    [[cell detailTextLabel] setText:detailText];
    [[cell detailTextLabel] setFont:[UIFont fontWithName:@"Avenir-Black" size:16]];
    return cell;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [taskArray count];
}
-(IBAction)addCell:(id)sender{
    Properties2ViewController *pvc = [[Properties2ViewController alloc]init];
    [pvc setDelegate:self];
    [self presentViewController:pvc animated:YES completion:NULL];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self tableView] reloadData];
    }
-(void)properties2ViewControllerDidEnterPropertiesSuccesfully:(Tasks *)t{
    if (![[t taskName] isEqual: @""]) {
    [taskArray addObject:t];
    }
    [self.tableView reloadData];
}
-(void)moveTableView:(FMMoveTableView *)tableView moveRowFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath{
    [tableView moveRowAtIndexPath:fromIndexPath toIndexPath:toIndexPath];
    [tableView reloadData];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    Tasks *task = [taskArray objectAtIndex:[indexPath row]];
    DetailViewController *dvc = [[DetailViewController alloc]init];
    [dvc setTestTask:task];
    [[self navigationController] pushViewController:dvc animated:YES];
   // PKRevealController *pkrc = [[PKRevealController alloc]initWithFrontViewController:self rightViewController:dvc options:nil];
    //[pkrc showViewController:dvc animated:YES completion:NULL];

}
-(void)loadView{
    [super loadView];
}
@end
4

2 に答える 2

0
于 2013-06-30T04:04:04.047 に答える