每次我运行我的应用程序时都会崩溃。 但是,我在崩溃后再次运行,它不会再次崩溃,应用程序可以正常运行。
它有什么不对吗?
我添加了一个实现了drawRect方法的UIView后出现了随机错误。 谁能帮忙???
我尝试将我的程序分开。
实现drawRect方法后导致radom错误并崩溃。 但我有任何关于Y的想法它会发生..... 谁能帮我?? PLS
StickView.m
#import "StickView.h"
@implementation StickView
- (void)drawRect:(CGRect)rect
{
// Drawing code
UIBezierPath *rectPath = [[UIBezierPath alloc] init];
[rectPath moveToPoint:CGPointMake(0, 0)];
[rectPath addLineToPoint:CGPointMake(0 + self.bounds.size.width, 0)];
[rectPath addLineToPoint:CGPointMake(0 + self.bounds.size.width, 0 + self.bounds.size.height)];
[rectPath addLineToPoint:CGPointMake(0, 0 + self.bounds.size.height)];
[rectPath closePath];
[[UIColor blackColor] setStroke];
[rectPath stroke];
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
我只是调用StickView的属性并将其添加到我的ViewController:
ViewController.m
#import "DetailViewController.h"
#import "StickView.h"
@interface DetailViewController ()
@end
@implementation DetailViewController
-(StickView *)stickView
{
if (!_stickView) {
_stickView = [[StickView alloc] init];
}
return _stickView;
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
-(void)viewDidLoad
{
[super viewDidLoad];
}