我正在开发这个应用程序并且它一直运行得非常好然后我尝试运行应用程序并且没有理解为什么segue没有运行,因为它总是假设在应用程序时执行打开。我然后按下一个执行相同segue的按钮,应用程序就会崩溃。
这是错误消息:
2014-04-04 16:30:54.733 On Tour Company[3854:60b] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
2014-04-04 16:30:55.043 On Tour Company[3854:60b] Current user: (null)
2014-04-04 16:30:55.246 On Tour Company[3854:60b] Push notifications are not supported in the iOS Simulator.
2014-04-04 16:31:00.593 On Tour Company[3854:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<LoginViewController 0x9bad0e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key barSignUp.'
*** First throw call stack:
(
0 CoreFoundation 0x02af11e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x023b48e5 objc_exception_throw + 44
2 CoreFoundation 0x02b80fe1 -[NSException raise] + 17
3 Foundation 0x02074d9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x01fe11d7 _NSSetUsingKeyValueSetter + 88
5 Foundation 0x01fe0731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x02042b0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7 UIKit 0x0132b1f4 -[UIRuntimeOutletConnection connect] + 106
8 libobjc.A.dylib 0x023c67de -[NSObject performSelector:] + 62
9 CoreFoundation 0x02aec76a -[NSArray makeObjectsPerformSelector:] + 314
10 UIKit 0x01329d4d -[UINib instantiateWithOwner:options:] + 1417
11 UIKit 0x015d88bd -[UIStoryboard instantiateViewControllerWithIdentifier:] + 220
12 UIKit 0x015d8eb6 -[UIStoryboardSegueTemplate _perform:] + 88
13 UIKit 0x0119541c -[UIViewController performSegueWithIdentifier:sender:] + 72
14 On Tour Company 0x000076bf -[BlogTableViewController logout:] + 143
15 libobjc.A.dylib 0x023c6880 -[NSObject performSelector:withObject:withObject:] + 77
16 UIKit 0x010763b9 -[UIApplication sendAction:to:from:forEvent:] + 108
17 UIKit 0x013638df -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
18 libobjc.A.dylib 0x023c6880 -[NSObject performSelector:withObject:withObject:] + 77
19 UIKit 0x010763b9 -[UIApplication sendAction:to:from:forEvent:] + 108
20 UIKit 0x01076345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
21 UIKit 0x01177bd1 -[UIControl sendAction:to:forEvent:] + 66
22 UIKit 0x01177fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
23 UIKit 0x01177243 -[UIControl touchesEnded:withEvent:] + 641
24 UIKit 0x010b5ddd -[UIWindow _sendTouchesForEvent:] + 852
25 UIKit 0x010b69d1 -[UIWindow sendEvent:] + 1117
26 UIKit 0x010885f2 -[UIApplication sendEvent:] + 242
27 UIKit 0x01072353 _UIApplicationHandleEventQueue + 11455
28 CoreFoundation 0x02a7a77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
29 CoreFoundation 0x02a7a10b __CFRunLoopDoSources0 + 235
30 CoreFoundation 0x02a971ae __CFRunLoopRun + 910
31 CoreFoundation 0x02a969d3 CFRunLoopRunSpecific + 467
32 CoreFoundation 0x02a967eb CFRunLoopRunInMode + 123
33 GraphicsServices 0x02a1a5ee GSEventRunModal + 192
34 GraphicsServices 0x02a1a42b GSEventRun + 104
35 UIKit 0x01074f9b UIApplicationMain + 1225
36 On Tour Company 0x0000316d main + 141
37 libdyld.dylib 0x03642701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
这是该集合中第一个视图控制器的代码。在视图下将加载(使用解析后端)我检查谁登录到应用程序,如果没有人,它想进入登录屏幕。我不知道为什么不是。
#import "BlogTableViewController.h"
@interface BlogTableViewController ()
@end
@implementation BlogTableViewController
-(void) viewDidLoad {
[super viewDidLoad];
[self.tabBarController.tabBar setHidden:NO];
}
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tabBarController.tabBar setHidden:NO];
PFUser *currentUser = [PFUser currentUser];
if ([currentUser isEqual: @"nil"]) {
[self performSegueWithIdentifier: @"showLogin" sender: self];
}
else{
NSLog(@"Current user: %@", currentUser.username);
}
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"
forIndexPath:indexPath];
// Configure the cell...
return cell;
}
- (IBAction)logout:(id)sender {
[PFUser logOut];
[self performSegueWithIdentifier: @"showLogin" sender: self];
}
@end
这里只是为了帮助它是segue的代码。大多数代码都与使用解析后端登录用户有关,但现在是。
#import "LoginViewController.h"
@interface LoginViewController ()
@end
@implementation LoginViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Hello");
[self.tabBarController.tabBar setHidden:YES];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.usernameField resignFirstResponder];
[self.passwordField resignFirstResponder];
}
- (IBAction)login:(id)sender {
NSString *username = self.usernameField.text;
NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([username length] == 0 || [password length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!" message:@"Make sure you enter a username and password!"delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alertView show];
}
else{
[PFUser logInWithUsernameInBackground:username password:password block:^(PFUser *user, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertView show];
}
else{
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
}
}
@end
答案 0 :(得分:5)
在Interface Builder中检查您的插座。看起来barSignUp
插座连接错误。