每次我运行我的应用程序时,它都会崩溃。但是,我在崩溃后再次运行,它不会再次崩溃并且应用程序可以正常运行。
它出什么问题了?
添加实现 drawRect 方法的 UIView 后出现随机错误。谁能帮忙???
我尝试分离我的程序。
实现 drawRect 方法后导致随机错误和崩溃。但我有任何想法关于 Y 它会发生.....有人可以帮助我吗?请
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 中:
视图控制器.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];
}