我有一个按钮,有这个动作:
@IBAction func btnLogin(_ sender: Any) {
if(userName.text! == "staff" && password.text! == "pass") {
performSegue(withIdentifier: "showStaffPage", sender: self)
} else if (userName.text! == "driver" && password.text! == "pass") {
performSegue(withIdentifier: "showDriverPage", sender: self)
} else if (userName.text! == "parent" && password.text! == "pass") {
performSegue(withIdentifier: "showParentPage", sender: self)
} else {
errorMsg.alpha = 1;
}
}
它适用于"驱动程序"并且对于" parent",但是它为" staff"提供了以下错误。我尝试过清洁工作,并确保所有名称和位置都有效且仍然存在。不知道该怎么办。
2018-05-15 09:22:10.089411-0400 After School Tracker[12989:162055] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/user136086/Library/Developer/CoreSimulator/Devices/EE08864F-5D96-49E7-8E52-AFE0056A6BA2/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-05-15 09:22:10.089849-0400 After School Tracker[12989:162055] [MC] Reading from private effective user settings.
2018-05-15 09:22:20.767770-0400 After School Tracker[12989:162055] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<After_School_Tracker.StaffViewController 0x7fd191f16d80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewHere.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d1811e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000010c816031 objc_exception_throw + 48
2 CoreFoundation 0x000000010d1810b9 -[NSException raise] + 9
3 Foundation 0x000000010c237b47 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKit 0x000000010d799f20 -[UIViewController setValue:forKey:] + 87
5 UIKit 0x000000010da87d56 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010d123e8d -[NSArray makeObjectsPerformSelector:] + 317
7 UIKit 0x000000010da86700 -[UINib instantiateWithOwner:options:] + 1856
8 UIKit 0x000000010d7a1137 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
9 UIKit 0x000000010d7a1a64 -[UIViewController loadView] + 177
10 UIKit 0x000000010d7a1d81 -[UIViewController loadViewIfRequired] + 175
11 UIKit 0x000000010d7a25d4 -[UIViewController view] + 27
12 UIKit 0x000000010d7d3c6e -[UINavigationController _startCustomTransition:] + 945
13 UIKit 0x000000010d7ea5e2 -[UINavigationController _startDeferredTransitionIfNeeded:] + 714
14 UIKit 0x000000010d7eb8cc -[UINavigationController __viewWillLayoutSubviews] + 150
15 UIKit 0x000000010da43bd7 -[UILayoutContainerView layoutSubviews] + 231
16 UIKit 0x000000010d6cd808 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515
17 QuartzCore 0x0000000113b7561a -[CALayer layoutSublayers] + 177
18 QuartzCore 0x0000000113b7982b _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
19 QuartzCore 0x0000000113b0029f _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343
20 QuartzCore 0x0000000113b2d940 _ZN2CA11Transaction6commitEv + 568
21 UIKit 0x000000010d5f834f _UIApplicationFlushRunLoopCATransactionIfTooLate + 167
22 UIKit 0x000000010df5d532 __handleEventQueueInternal + 6875
23 CoreFoundation 0x000000010d123bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x000000010d1084af __CFRunLoopDoSources0 + 271
25 CoreFoundation 0x000000010d107a6f __CFRunLoopRun + 1263
26 CoreFoundation 0x000000010d10730b CFRunLoopRunSpecific + 635
27 GraphicsServices 0x0000000112cfda73 GSEventRunModal + 62
28 UIKit 0x000000010d5fe0b7 UIApplicationMain + 159
29 After School Tracker 0x000000010bef43b7 main + 55
30 libdyld.dylib 0x00000001115ec955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
答案 0 :(得分:1)
当故事板场景有一个过时的IBOutlet
到不再存在的东西时会发生这种情况。当我创建StaffViewController
,将其连接到Interface Builder中的某些内容,然后在代码中删除关联的IBOutlet
定义时,这种情况一直发生在我身上。不幸的是,这只是一个运行时问题(意味着编译器不会捕获它)。
在Interface Builder中打开from django.db import models
#from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.db.models.signals import post_save
from django.contrib.auth.models import AbstractUser
class Title(models.Model):
value = models.CharField(max_length=100, null=True, blank=True)
def __str__(self):
return self.value
class Meta:
db_table = 'title'
class User(AbstractUser):
title = models.ForeignKey(Title, on_delete=models.CASCADE, null=True, blank=True)
class Meta:
db_table = 'user'
,然后打开 Connections Inspector 并查找仍然连接但已从相关代码文件中删除的AUTH_USER_MODEL = 'student.User'
。< / p>
答案 1 :(得分:0)
'[<After_School_Tracker.StaffViewController 0x7fd191f16d80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewHere.
这意味着您的班级中缺少名为viewHere
的IBOutlet。
如果你添加它,我认为它将解决问题
答案 2 :(得分:0)
问题出在
的目的地StaffViewController
是类viewHere
,有一个名为[Serializable]
public class Company : Base.BaseEntity
{
public long CompanyId { get; set; }
public string CompanyName { get; set; }
public string TimeZone { get; set; }
public string Address { get; set; }
public long? CityId { get; set; }
public long? StateId { get; set; }
public int Zip { get; set; }
public string Telephone { get; set; }
public string Fax { get; set; }
public string EmailAddress { get; set; }
public string FederalEin { get; set; }
public string WebPage { get; set; }
public string StateEmployerNumber { get; set; }
public long? AdministratorId { get; set; }
public string OfflineAdlLockoutTime { get; set; }
public bool? IsAllowWindowsAuthentication { get; set; }
public virtual ICollection<CommunityType> CommunityTypeList { get; set; }
}
的视图,您在类代码中删除但仍在IB中