カスタムUIViewで次のメソッドを使用して、メモリの問題があります(はい;)iOSは初めてです)。
ヘッダーファイル
....
@property (nonatomic, retain) NSString * pressureTextLabel;
....
実装は、タッチに関連付けられた圧力で円とラベルを描画します。指で触れるたびに、このビューのオブジェクトが作成されます。
- (void)drawRect:(CGRect)theRect{
CGRect rect = self.bounds;
CGRect ringRect = CGRectInset(rect, 100, 100);
// Outer ring.
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:ringRect];
ringRect = CGRectInset(rect, 60, 60);
[path appendPath:[UIBezierPath bezierPathWithOvalInRect:ringRect]];
path.usesEvenOddFillRule = YES;
[self.color set];
[path fill];
//text label
rect = CGRectMake(100, 20, 100, 100);
//This one seems to be the troublemaker
[pressureTextLabel drawInRect:rect withFont:[UIFont systemFontOfSize:14.0]];
}
この特定のタッチの感知圧力を更新するために、この次のメソッドがコントローラーによって呼び出されない限り、すべて正常に機能します。
-(void) setTouchPressureTo: (float) pressure{
pressureTextLabel = [NSString stringWithFormat:@"%f", pressure];
[self setNeedsDisplay];
}
次のエラーが表示されます。
*** -[CFString drawInRect:withFont:]: message sent to deallocated instance 0x16e8c0
アプリケーションがクラッシュした後、デバッグ コンソールでメモリ トレースを調査する必要がありましたshell malloc_history <PID> 0x17dfb0
。その結果、コンソールは次を返します。
malloc_history cannot examine process 5838 because the process does not
存在。
だからここに質問:
- ここで明らかな保持、解放の問題を誰かが見ることができますか?
- どうすれば
malloc_history <PID> <Address
> 動作しますか?
お時間をいただき、リダイレクトと回答をありがとうございました!
キリスト教徒