使用故事板在UITableView中显示plist的问题? (Xcode中)

时间:2013-04-05 19:52:14

标签: xcode uitableview plist

我之前已经在另一个项目上完成了这项工作,然后让它工作了,但是我无法找到为什么这部分编程不起作用。 它显示的表中没有任何plist数据。 请仔细查看我的代码,看看你是否能找到我犯错的地方,谢谢。

#import "MarketViewController.h"
#import "SecondViewController.h"
#import "ECSlidingViewController.h"
#import "MenuViewController.h"

@interface MarketViewController ()

@end

@implementation MarketViewController
@synthesize shares, shareValues, number, shareName;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {

    }
    return self;
}

- (void)viewDidLoad
{


    self.navigationItem.title = @"Stock Market";
    NSString *sharesFile = [[NSBundle mainBundle] pathForResource:@"Shares" ofType:@"plist"];

    shares = [[NSDictionary alloc] initWithContentsOfFile: sharesFile];
    shareValues = [shares objectForKey:@"Share Values"];
    shareName = [shares objectForKey:@"Share Names"];

    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.view.layer.shadowOpacity = 0.75f;
    self.view.layer.shadowRadius = 10.0f;
    self.view.layer.shadowColor = [UIColor blackColor].CGColor;


    if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
        self.slidingViewController.underLeftViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
    }


    [self.view addGestureRecognizer:self.slidingViewController.panGesture];

    self.menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _menuBtn.frame = CGRectMake(8, 10, 34, 24);
    [_menuBtn setBackgroundImage:[UIImage imageNamed:@"menuButton.png"] forState:UIControlStateNormal];
    [_menuBtn addTarget:self action:@selector(revealMenu:) forControlEvents:UIControlEventTouchUpInside];


    [self.view addSubview:self.menuBtn];



}

//Table View

- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [shares count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    static NSString *cellIdentifier = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
    }


    NSString *nameOfShare = [shareName objectAtIndex:[indexPath row]];
    NSString *valueOfShare = [shareValues objectAtIndex:[indexPath row]];
    cell.detailTextLabel.text = valueOfShare;
    cell.textLabel.text = nameOfShare;
    return cell;
    self.title = @"Stock Market";


}

- (IBAction)revealMenu:(id)sender
{
    [self.slidingViewController anchorTopViewTo:ECRight];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

我的。文件如下:

#import <UIKit/UIKit.h>

@interface MarketViewController : UIViewController
<UITableViewDataSource, UITableViewDelegate>


@property (strong, nonatomic) UIButton *menuBtn;
@property (nonatomic, readonly) NSDate *CurrentDate;
@property (nonatomic, strong) NSDictionary *shares;
@property (nonatomic, strong) NSArray *shareValue;
@property (nonatomic, strong) NSArray *number;
@property (nonatomic, strong) NSArray *shareName;
- (NSString*)filePath;
- (void)openDB;



@end

0 个答案:

没有答案
相关问题