线程1信号放置按钮或标签iOS时出现SIGABRT错误

时间:2014-03-17 10:39:41

标签: ios objective-c uibutton uilabel sigabrt

我无法弄清楚为什么我无法在文件中添加任何标签或按钮。每次我这样做都会遇到线程1错误。

@interface PuzzleView : UIView


@property (nonatomic, assign) int row;
@property (nonatomic, assign) int col;
@property (nonatomic, assign) CGFloat dw;
@property (nonatomic, assign) CGFloat dh;

-(NSMutableArray *) getNeighborsForPoint:(CGPoint) point inArray:(NSMutableArray *)array;
-(void) uncover:(CGPoint) point;



@property (retain, nonatomic) IBOutlet UITextField *unflaggedshow;

- (IBAction)swipe:(UISwipeGestureRecognizer *)recognizer;

@end

实施档案

@implementation PuzzleView

@synthesize unflaggedshow=_unflaggedshow;

- (void)drawRect:(CGRect)rect
{
 _unflaggedshow.text=[[NSString alloc]initWithFormat:@"%0.0d",unflaggedmine1];
}

- (void)dealloc {
    [_unflaggedshow release];
    [super dealloc];
}
@end

drawRect中有更多代码,我只是把主要内容放在这里。有人可以告诉我为什么我收到线程1信号SIGBART错误。

由于

这些是错误:

#import <UIKit/UIKit.h>

#import "TabBarAppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([TabBarAppDelegate class]));
    }
}

错误:

2014-03-17 06:44:24.836 TabBar-DoubleTap[4603:70b] application:didFinishLaunchingWithOptions
2014-03-17 06:44:24.839 TabBar-DoubleTap[4603:70b] FirstViewController/viewDidLoad
2014-03-17 06:44:24.841 TabBar-DoubleTap[4603:70b] Application windows are expected to have a root view controller at the end of application launch
2014-03-17 06:44:24.844 TabBar-DoubleTap[4603:70b] -----------total mines: 0 ------------
2014-03-17 06:44:24.844 TabBar-DoubleTap[4603:70b] value of gridvalrow from puzzle 12
2014-03-17 06:44:24.844 TabBar-DoubleTap[4603:70b] value of gridvalcol from puzzle 18
2014-03-17 06:44:24.845 TabBar-DoubleTap[4603:70b] field being set ***********
2014-03-17 06:44:24.845 TabBar-DoubleTap[4603:70b] total fields set 400 ******
2014-03-17 06:44:24.846 TabBar-DoubleTap[4603:70b] mine desnity**********  72
2014-03-17 06:44:24.847 TabBar-DoubleTap[4603:70b] ------------------------------------Unflagged Mines 21827753 
2014-03-17 06:44:24.847 TabBar-DoubleTap[4603:70b] PuzzleView/drawRect()
2014-03-17 06:44:25.911 TabBar-DoubleTap[4603:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<PuzzleView 0x8b44840> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key unflagged.'
*** First throw call stack:
(
    0   CoreFoundation                      0x01bb65e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x014c98b6 objc_exception_throw + 44
    2   CoreFoundation                      0x01c466a1 -[NSException raise] + 17
    3   Foundation                          0x000ff9ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    4   Foundation                          0x0006bcfb _NSSetUsingKeyValueSetter + 88
    5   Foundation                          0x0006b253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
    6   UIKit                               0x004b9e0b -[UIView(CALayerDelegate) setValue:forKey:] + 168
    7   Foundation                          0x000cd70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
    8   UIKit                               0x006f1a15 -[UIRuntimeOutletConnection connect] + 106
    9   libobjc.A.dylib                     0x014db7d2 -[NSObject performSelector:] + 62
    10  CoreFoundation                      0x01bb1b6a -[NSArray makeObjectsPerformSelector:] + 314
    11  UIKit                               0x006f056e -[UINib instantiateWithOwner:options:] + 1417
    12  UIKit                               0x00562605 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
    13  UIKit                               0x00562dad -[UIViewController loadView] + 302
    14  UIKit                               0x005630ae -[UIViewController loadViewIfRequired] + 78
    15  UIKit                               0x005635b4 -[UIViewController view] + 35
    16  UIKit                               0x0059a3ae -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 407
    17  UIKit                               0x00599bd2 -[UITabBarController transitionFromViewController:toViewController:] + 63
    18  UIKit                               0x00595fbb -[UITabBarController _setSelectedViewController:] + 279
    19  UIKit                               0x00595e9c -[UITabBarController setSelectedViewController:] + 180
    20  UIKit                               0x00599ace -[UITabBarController _tabBarItemClicked:] + 312
    21  libobjc.A.dylib                     0x014db874 -[NSObject performSelector:withObject:withObject:] + 77
    22  UIKit                               0x004510c2 -[UIApplication sendAction:to:from:forEvent:] + 108
    23  UIKit                               0x0045104e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    24  UIKit                               0x006ff659 -[UITabBar _sendAction:withEvent:] + 479
    25  libobjc.A.dylib                     0x014db81f -[NSObject performSelector:withObject:] + 70
    26  UIKit                               0x004510c2 -[UIApplication sendAction:to:from:forEvent:] + 108
    27  UIKit                               0x0045104e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    28  UIKit                               0x005490c1 -[UIControl sendAction:to:forEvent:] + 66
    29  UIKit                               0x00549484 -[UIControl _sendActionsForEvents:withEvent:] + 577
    30  UIKit                               0x005490f6 -[UIControl sendActionsForControlEvents:] + 48
    31  UIKit                               0x00703f80 -[UITabBar(Static) _buttonUp:] + 123
    32  libobjc.A.dylib                     0x014db874 -[NSObject performSelector:withObject:withObject:] + 77
    33  UIKit                               0x004510c2 -[UIApplication sendAction:to:from:forEvent:] + 108
    34  UIKit                               0x0045104e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    35  UIKit                               0x005490c1 -[UIControl sendAction:to:forEvent:] + 66
    36  UIKit                               0x00549484 -[UIControl _sendActionsForEvents:withEvent:] + 577
    37  UIKit                               0x00548733 -[UIControl touchesEnded:withEvent:] + 641
    38  UIKit                               0x0048e51d -[UIWindow _sendTouchesForEvent:] + 852
    39  UIKit                               0x0048f184 -[UIWindow sendEvent:] + 1232
    40  UIKit                               0x00462e86 -[UIApplication sendEvent:] + 242
    41  UIKit                               0x0044d18f _UIApplicationHandleEventQueue + 11421
    42  CoreFoundation                      0x01b3f83f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    43  CoreFoundation                      0x01b3f1cb __CFRunLoopDoSources0 + 235
    44  CoreFoundation                      0x01b5c29e __CFRunLoopRun + 910
    45  CoreFoundation                      0x01b5bac3 CFRunLoopRunSpecific + 467
    46  CoreFoundation                      0x01b5b8db CFRunLoopRunInMode + 123
    47  GraphicsServices                    0x02a4c9e2 GSEventRunModal + 192
    48  GraphicsServices                    0x02a4c809 GSEventRun + 104
    49  UIKit                               0x0044fd3b UIApplicationMain + 1225
    50  TabBar-DoubleTap                    0x00002992 main + 130
    51  TabBar-DoubleTap                    0x00002905 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

我想我已经开始工作了。我试图同时使用标签和按钮。我删除了标签,现在它正常工作。

2 个答案:

答案 0 :(得分:1)

看起来您曾经有一个名为unflagged的插座,不再存在。可能您将名称更改为unflaggedshow

您需要删除不存在的插座连接(并将其连接到确实存在的插座)。

答案 1 :(得分:0)

drawRect被调用时,尚未配置出口。因此,您无法使用drawRect更新用户界面。

而不是drawRect您可以使用-(void)didMoveToSuperview方法来自定义UI。但是,除了特殊情况之外,最好在从父viewController初始化时自定义UIView子视图,您可以拥有所需的一切,更重要的是它是同步调用。