배열의 문자열을 드로잉에 그리려하고 있지만 그려지지 않았습니다. drawRect 코드는 다음과 같습니다.배열의 문자열을 그리기에서 그리기
- (void)drawRect:(CGRect)rect
{
UIFont *font = [UIFont systemFontOfSize:14];
CGRect ourRect;
ourRect.origin.x=ourRect.origin.y=20.0;
ourRect.size.width=130.0;
ourRect.size.height= 100.0;
CGPoint pointer;
pointer.x=pointer.y=20;
NSString*string;
string=[[NSString alloc] init];
[string drawAtPoint:pointer withFont:font];
NSMutableArray * whatShouldIDraw=[[NSMutableArray alloc]init];
whatShouldIDraw=[self.dataSource whatToDraw:self];
NSUInteger i;
for (i=0; i<[whatShouldIDraw count]; i++) {
[[[whatShouldIDraw objectAtIndex:i] equationBit] drawAtPoint:[[whatShouldIDraw objectAtIndex:i]drawPoint] withFont:font];
}
}
데이터 소스 프로토콜은보기의 컨트롤러에 구현되어 있습니다. 배열의 객체는 문자열과 그 문자열을 그리는 지점을 보유하는 클래스입니다. NSLog를 사용하여 객체가 실제로 배열에 제대로 배치되었는지 확인했습니다. 또한 setNeedsDisplay를 뷰에 보내는 행이 있습니다. 이 코드를 실행하면 빈 상태가되어 어떤 일이 잘못 될지 잘 모릅니다. 이것은 응용 프로그램 내에서 입력되는 데이터로 drawRect를 실행하게 한 첫 번째 시도이므로 데이터 소스 프로토콜을 어떻게 구현했는지에 따라 문제가 발생한다고 생각합니다.