新的引用插座,查看UIviewcontroller

时间:2013-12-29 19:09:27

标签: ios objective-c uiviewcontroller

所以,我正在youtube上关注本教程。我想在我的应用中添加一个饼图。但是,当我尝试从我的PieChart view添加新的引用插座到my view controller(在5:01完成)时,Xcode不允许我这样做。有什么方法可以解决这个问题吗?

这是我的视图controller.m

//
//  checkAttendanceViewController.m
//  timetable app
//
//  Created by Robin Malhotra on 29/12/13.
//  Copyright (c) 2013 Robin's code kitchen. All rights reserved.
//

#import "checkAttendanceViewController.h"

@interface checkAttendanceViewController ()

@end

@implementation checkAttendanceViewController

@synthesize pieChartView;

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

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSMutableArray *array=[[NSMutableArray alloc]init];

    for (int i=0; i<5; i++)
    {
        NSNumber *number=[NSNumber numberWithInt:rand()%60+20];
        [array addObject:number];

    }

    [self.pieChartView renderInLayer:self.pieChartView dataArray:array];

        // Do any additional setup after loading the view.
}

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

@end

和我的viewcontroller.h

//
//  checkAttendanceViewController.h
//  timetable app
//
//  Created by Robin Malhotra on 29/12/13.
//  Copyright (c) 2013 Robin's code kitchen. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "DLPieChart.h"


@interface checkAttendanceViewController : UIViewController
@property(nonatomic,retain) IBOutlet DLPieChart *pieChartView;
@end

如果有人想自己尝试一下,我会发现dropbox链接(我知道我不应该共享外部链接,但是我已经粘贴了相应的代码,我不确定你是如何粘贴故事板的在stackoverflow中

3 个答案:

答案 0 :(得分:1)

当我遇到这种情况时,通常是因为xib中视图的类类型与源文件中的插座类类型不匹配。

  • 在故事板或xib中选择视图
  • 选择视图 - &gt;实用程序 - &gt;显示身份检查器(在Xcode右侧可见)
  • 确保“自定义类”文本字段设置为“DLPieChart”(插座中定义的类型)

答案 1 :(得分:0)

确定。我看到了这个问题。您错误地将viewController类的名称设置为“checkAttendanceViewContriller”而不是故事板视图控制器中的“checkAttendanceViewController”。更改名称,你会很高兴。

答案 2 :(得分:0)

好的,它突然开始工作了。我退出并重新启动了Xcode,清理了项目,瞧,它现在有效。我现在应该删除这个问题吗?。

相关问题