gpt4 book ai didi

iphone - 错误 : this class is not key value coding-compliant for the key projectToolBar?

转载 作者:可可西里 更新时间:2023-11-01 03:05:50 26 4
gpt4 key购买 nike

<分区>

嘿,我无法弄清楚我遇到的错误。我的应用程序正在运行,但我不确定我做了什么,但它现在打不开,而是出现此错误:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason:     '[<TaskViewController 0x16c9b0> setValue:forUndefinedKey:]: this class is not key value  coding-compliant for the key projectToolBar.'

任何想法可能是什么问题?如果需要,我可以添加我的项目代码...

编辑:

所以我看了看,在界面构建器/ Storyboard中有一个指向 projectToolBar 的链接,但在头文件中没有相应的行。我在 IB 中删除了问题,但是,现在我收到一个新错误并且它仍然无法正常工作。

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TaskViewController 0x132dd0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key projectView.'

这是我的 taskviewController 类:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "newTaskWindow.h"

@interface TaskViewController : UIViewController <DismissPopoverDelegate>{

IBOutlet UIScrollView *taskScrollView;
AppDelegate * _appDelegate;
UIDeviceOrientation orientation;
IBOutlet UIView *newTaskView;
IBOutlet UIBarButtonItem *newTaskButton;
IBOutlet UIBarButtonItem *newTeamMemberButton;
IBOutlet UIBarButtonItem *newProjectButton;
IBOutlet UIView*taskView;
IBOutlet UIToolbar *taskToolBar;
NSMutableArray *teamMembers;
NSMutableArray *projects;
NSMutableArray *tasks;
//UIPopoverController *taskPop;

int countForX;
int countForY;
int xOffSet;
int yOffset;
int xMult;
int yMult;
int viewContentSize;
int countForTaskView;
int maxCountForX;
int maxCountForY;
int incrementForYOffset;
int viewContentSizeBase;


}

- (IBAction)newTask:(id)sender;
- (IBAction)newTeamMember:(id)sender;
- (IBAction)newProject:(id)sender;
-(void)setTasksInScreen;


@property(nonatomic, retain) AppDelegate * appDelegate;
@property (nonatomic, retain) UIPopoverController *myPopover;
@end
@protocol NewsVcDelegate <NSObject>

- (void)FirstViewController:(TaskViewController*)controller didSelectObject:(id)object;

@end

//FirstViewController.m

#import "TaskViewController.h"
#import "newTaskWindow.h"
#import "TeamMember.h"
#import "Project.h"
#import "newTeamMemberWindow.h"
#import "newProjectWindow.h"

@implementation TaskViewController
@synthesize myPopover;
@synthesize appDelegate;

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
NSLog(@"Made it to TaskViewController");

self.appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];

[self setTasksInScreen];

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

}


//create new Team member in popover myPopover
-(IBAction)newTeamMember:(id)sender{

if ([self.myPopover isPopoverVisible]) {
//using the setters and getters "goes thru the proper channels" when accessing objects
[self.myPopover dismissPopoverAnimated:YES];
} else {

newTeamMemberWindow *teamMemberWindow = [[newTeamMemberWindow alloc]init];
[teamMemberWindow setDelegate:self];
UIPopoverController *teamMemberPop = [[UIPopoverController alloc]initWithContentViewController:teamMemberWindow];


[teamMemberPop setDelegate:self];



[teamMemberPop setPopoverContentSize:CGSizeMake(300, 450)];
//NSLog(@"Got to 6");
self.myPopover = teamMemberPop;
[self.myPopover presentPopoverFromBarButtonItem:newTeamMemberButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

}

//Create new Project in popover myPopover
-(IBAction)newProject:(id)sender{

if ([self.myPopover isPopoverVisible]) {
//using the setters and getters "goes thru the proper channels" when accessing objects
[self.myPopover dismissPopoverAnimated:YES];
} else {

newProjectWindow *projectWindow = [[newProjectWindow alloc]init];
[projectWindow setDelegate:self];
UIPopoverController *projectPop = [[UIPopoverController alloc]initWithContentViewController:projectWindow];


[projectPop setDelegate:self];


[projectPop setPopoverContentSize:CGSizeMake(300, 450)];

self.myPopover = projectPop;
[self.myPopover presentPopoverFromBarButtonItem:newProjectButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

}



//Create new Task in popover myPopover
-(IBAction)newTask:(id)sender{

if ([self.myPopover isPopoverVisible])
{

[self.myPopover dismissPopoverAnimated:YES];

} else {



NSString* test1 = [[NSString alloc]initWithFormat:@"Robby"];
[teamMembers addObject:test1];
newTaskWindow *newTaskWin = [[newTaskWindow alloc]init];
[newTaskWin setDelegate:self];
UIView *test = [[UIView alloc]init];
[newTaskWin setTeamMembers:teamMembers];
test = newTaskWin.view;

UIPopoverController *taskPop = [[UIPopoverController alloc]initWithContentViewController:newTaskWin];


[taskPop setDelegate:self];


[taskPop setPopoverContentSize:CGSizeMake(300, 450)];

self.myPopover = taskPop;
[self.myPopover presentPopoverFromBarButtonItem:newTaskButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

}

}

-(void)setTasksInScreen{


//remove all views that were in The task view. If you don't do this, a new view is placed on top everytime you call setTasksInScreen method and the buttons begin to overlap.

for (UIView *view in [taskView subviews]) {
[view removeFromSuperview];
}

//The placement of the buttons is different depending on which orientation we are in. We handle this with an if statement

if((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){

countForX = 0;
countForY = 0;
xOffSet = 27;
yOffset = 60;
maxCountForX = 3;
maxCountForY = 4;
incrementForYOffset = 911;
xMult = 250;
yMult = 210;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 911;
NSLog(@"Portrait view");

}
else{
countForX = 0;
countForY = 0;
maxCountForX = 4;
maxCountForY = 3;
incrementForYOffset = 654;
xOffSet = 41;
yOffset = 50;
xMult = 240;
yMult = 200;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 654;
NSLog(@"LandScape view");
}

//Create Scrollview to be able to scroll through the different tasks
taskScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height -45)];

tasks = [[NSMutableArray alloc] initWithArray:self.appDelegate.tasks];



Task *tempTask = [[Task alloc]init];
for(int i =0; i < [tasks count]; i++){
tempTask = [tasks objectAtIndex:i];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//Set the style that you want the date to be here (ie. MM-DD-YYYY ect)
[formatter setDateStyle:NSDateFormatterFullStyle];
NSDate *endDateForButton = [tempTask endDate];


//Use custom Button so that you can add in background pic


UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];


button.frame = CGRectMake(xOffSet+(countForX*xMult), yOffset +(countForY*yMult), 215, 156);
UIImage *buttonBackground = [UIImage imageNamed:@"rectangleImage.png"];
[button setBackgroundImage:buttonBackground forState:UIControlStateNormal];

//add labels to button for information
UILabel *taskName = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 200, 45)];
taskName.text = [tempTask taskName];
[taskName setTextAlignment:UITextAlignmentCenter];
[button addSubview:taskName];

//Label that says "Due on"

UILabel *dueLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 50, 200, 45)];
dueLabel.text = @"Due on";
[dueLabel setTextAlignment:UITextAlignmentCenter];
[button addSubview:dueLabel];


UILabel *endDate = [[UILabel alloc]initWithFrame:CGRectMake(5, 80, 200, 45)];
endDate.text = [formatter stringFromDate:[tempTask endDate]];
[endDate setTextAlignment:UITextAlignmentCenter];
[button addSubview:endDate];



countForX++;

if(countForX >= maxCountForX)
{

countForY++;
countForX = 0;

}

if(countForY >=maxCountForY)
{

countForY = 0;
countForX = 0;
yOffset +=incrementForYOffset;
countForTaskView++;

}

[taskScrollView addSubview:button];


}//for loop

[taskView addSubview:taskScrollView];
[taskView bringSubviewToFront:taskToolBar];

//[taskScrollView addSubview:viewForTaskScrollView];

viewContentSize = viewContentSizeBase * (countForTaskView);
taskScrollView.contentSize = CGSizeMake(taskView.frame.size.width, viewContentSize);
[taskScrollView setPagingEnabled:YES];
}

-(void)setProjectsInScreen{


//remove all views that were in The task view. If you don't do this, a new view is placed on top everytime you call setTasksInScreen method and the buttons begin to overlap.

for (UIView *view in [taskView subviews]) {
[view removeFromSuperview];
}

//The placement of the buttons is different depending on which orientation we are in. We handle this with an if statement

if((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){

countForX = 0;
countForY = 0;
xOffSet = 27;
yOffset = 60;
maxCountForX = 3;
maxCountForY = 4;
incrementForYOffset = 911;
xMult = 250;
yMult = 210;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 911;
NSLog(@"Portrait view");

}
else{
countForX = 0;
countForY = 0;
maxCountForX = 4;
maxCountForY = 3;
incrementForYOffset = 654;
xOffSet = 41;
yOffset = 50;
xMult = 240;
yMult = 200;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 654;
NSLog(@"LandScape view");
}

//Create Scrollview to be able to scroll through the different tasks
taskScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height -45)];



projects = [[NSMutableArray alloc] initWithArray:self.appDelegate.projects];



Project *tempProject = [[Project alloc]init];
for(int i =0; i < [tasks count]; i++){
tempProject = [tasks objectAtIndex:i];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];


button.frame = CGRectMake(xOffSet+(countForX*xMult), yOffset +(countForY*yMult), 215, 156);
UIImage *buttonBackground = [UIImage imageNamed:@"rectangleImage.png"];
[button setBackgroundImage:buttonBackground forState:UIControlStateNormal];

//add labels to button for information
UILabel *projectName = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 200, 45)];
projectName.text = [tempProject projectName];
[projectName setTextAlignment:UITextAlignmentCenter];
[button addSubview:projectName];

//Label that says "Due on"

UILabel *dueLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 50, 200, 45)];
dueLabel.text = @"Due on";
[dueLabel setTextAlignment:UITextAlignmentCenter];
[button addSubview:dueLabel];




countForX++;

if(countForX >= maxCountForX)
{

countForY++;
countForX = 0;

}

if(countForY >=maxCountForY)
{

countForY = 0;
countForX = 0;
yOffset +=incrementForYOffset;
countForTaskView++;

}

[taskScrollView addSubview:button];


}//for loop

[taskView addSubview:taskScrollView];
[taskView bringSubviewToFront:taskToolBar];

//[taskScrollView addSubview:viewForTaskScrollView];

viewContentSize = viewContentSizeBase * (countForTaskView);
taskScrollView.contentSize = CGSizeMake(taskView.frame.size.width, viewContentSize);
[taskScrollView setPagingEnabled:YES];
}

-(void)setTeamMembersInScreen{


//remove all views that were in The task view. If you don't do this, a new view is placed on top everytime you call setTasksInScreen method and the buttons begin to overlap.

for (UIView *view in [taskView subviews]) {
[view removeFromSuperview];
}

//The placement of the buttons is different depending on which orientation we are in. We handle this with an if statement

if((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){

countForX = 0;
countForY = 0;
xOffSet = 27;
yOffset = 60;
maxCountForX = 3;
maxCountForY = 4;
incrementForYOffset = 911;
xMult = 250;
yMult = 210;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 911;
NSLog(@"Portrait view");

}
else{
countForX = 0;
countForY = 0;
maxCountForX = 4;
maxCountForY = 3;
incrementForYOffset = 654;
xOffSet = 41;
yOffset = 50;
xMult = 240;
yMult = 200;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 654;
NSLog(@"LandScape view");
}

//Create Scrollview to be able to scroll through the different tasks
taskScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height -45)];

tasks = [[NSMutableArray alloc] initWithArray:self.appDelegate.tasks];



Task *tempTask = [[Task alloc]init];
for(int i =0; i < [tasks count]; i++){
tempTask = [tasks objectAtIndex:i];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//Set the style that you want the date to be here (ie. MM-DD-YYYY ect)
[formatter setDateStyle:NSDateFormatterFullStyle];
NSDate *endDateForButton = [tempTask endDate];


//Use custom Button so that you can add in background pic


UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];


button.frame = CGRectMake(xOffSet+(countForX*xMult), yOffset +(countForY*yMult), 215, 156);
UIImage *buttonBackground = [UIImage imageNamed:@"rectangleImage.png"];
[button setBackgroundImage:buttonBackground forState:UIControlStateNormal];

//add labels to button for information
UILabel *taskName = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 200, 45)];
taskName.text = [tempTask taskName];
[taskName setTextAlignment:UITextAlignmentCenter];
[button addSubview:taskName];

//Label that says "Due on"

UILabel *dueLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 50, 200, 45)];
dueLabel.text = @"Due on";
[dueLabel setTextAlignment:UITextAlignmentCenter];
[button addSubview:dueLabel];


UILabel *endDate = [[UILabel alloc]initWithFrame:CGRectMake(5, 80, 200, 45)];
endDate.text = [formatter stringFromDate:[tempTask endDate]];
[endDate setTextAlignment:UITextAlignmentCenter];
[button addSubview:endDate];



countForX++;

if(countForX >= maxCountForX)
{

countForY++;
countForX = 0;

}

if(countForY >=maxCountForY)
{

countForY = 0;
countForX = 0;
yOffset +=incrementForYOffset;
countForTaskView++;

}

[taskScrollView addSubview:button];


}//for loop

[taskView addSubview:taskScrollView];
[taskView bringSubviewToFront:taskToolBar];

//[taskScrollView addSubview:viewForTaskScrollView];

viewContentSize = viewContentSizeBase * (countForTaskView);
taskScrollView.contentSize = CGSizeMake(taskView.frame.size.width, viewContentSize);
[taskScrollView setPagingEnabled:YES];
}


- (void) dismissPopover:(NSString *)data
{ /* Dismiss you popover here and process data */


[self.myPopover dismissPopoverAnimated:YES];
[self setTasksInScreen];

//[myPopover dismissPopoverAnimated:YES];


}


// Some method, when you create popover


-(BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController{
return YES;
}

-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{


}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{

[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

- (void)deviceOrientationDidChange:(NSNotification *)notification {

[self setTasksInScreen];

}

@结束

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