How can I connect one of my View with UIView class?

In my xib file I have some View. And I have PainView class (UIView). In the identity inspector I set PaintView for this View, and made @property (strong, nonatomic) IBOutlet PaintView *paintView;

It was working Ok, until I desided to change draw method. I copied code from this file and pasted in PaintView.m (same with PaintView.h).

But it only works if I write

[self.view addSubview:[[PaintView alloc] initWithFrame:self.view.bounds]];

But it creates new layer over all other layers, buttons etc. And I need to connect this class with existing View.

I tried paintView = [[PaintView alloc] initWithFrame:self.view.bounds]; but it didnt work.

In console it always says invalid context:

<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextGetBaseCTM: invalid context 0x0
<Error>: CGContextConcatCTM: invalid context 0x0
<Error>: CGContextSetBaseCTM: invalid context 0x0
<Error>: CGContextSetBaseCTM: invalid context 0x0

Can you help me, please? Thanks in advance.


you need to implement another init method with the same initialization as in initWithFrame: It's name is:

- (id)initWithCoder:(NSCoder *)coder 

initWithCoder: is the init method, that is called for view, loaded from NIB files.

Need Your Help

Is there a non-heuristic way of finding the encoding of a string (ie. list)?

unicode encoding utf-8 erlang

For IoDevices one can use io:getopts/1 for example but I couldn't find any method for plain strings.

Completion Handler crash in AutoRenewable In-Appurchase

ios iphone transactions crash completionhandler

I'm making an application in which,I have to make my Inappurchase product auto renewable,for this, after reading Apple documents i came to know that after every transaction for autorenewable produc...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.