Ich habe ein Problem, ich kann nicht ändern frame.size.width in 3rd Party lib. Konnte keine normale Lösung finden, um die Breite zu ändern, also entschied ich mich, objc/Laufzeit auszuführen.Objective-C Laufzeit ändern schreibgeschützte Eigenschaft des initialisierten Objekts
Ich habe ViewController und seine Eigenschaft DTAttributedTextView * v.
@interface DTAttributedTextView : UIScrollView
{
// ivars needed by subclasses
DTAttributedTextContentView *_attributedTextContentView;
}
@property (nonatomic, strong) NSAttributedString *attributedString;
@property (nonatomic, DT_WEAK_PROPERTY) IBOutlet
id<DTAttributedTextContentViewDelegate> textDelegate;
@property (nonatomic, strong) IBOutlet UIView *backgroundView;
....
@end
v bekam @property (.., nur lesbar) DTAttributedTextContentView * attributedTextContentView
@interface DTAttributedTextContentView : UIView
{
NSAttributedString *_attributedString;
DTCoreTextLayoutFrame *_layoutFrame;
UIEdgeInsets _edgeInsets;
NSMutableDictionary *customViewsForAttachmentsIndex;
BOOL _flexibleHeight;
// for layoutFrame
NSInteger _numberOfLines;
NSLineBreakMode _lineBreakMode;
NSAttributedString *_truncationString;
}
attributedTextContentView bekam @property DTCoreTextLayoutFrame * layoutFrame
@interface DTCoreTextLayoutFrame : NSObject
{
CGRect _frame;
NSArray *_lines;
NSArray *_paragraphRanges;
NSArray *_textAttachments;
NSAttributedString *_attributedStringFragment;
}
Also im Grunde muss ich Änderung
self.v.attributedTextContentView.layoutFrame.frame.size.width
für eine pitty i cant
objc_setAssociatedObject(self.v.attributedTextContentView.layoutFrame,@"frame.size.width",@200,OBJC_ASSOCIATION_ASSIGN);
objc_setAssociatedObject(self.v.attributedTextContentView.layoutFrame,@"frame",CGRectMake(0,0,200,1000),OBJC_ASSOCIATION_ASSIGN);
, weil ich nicht ivars durch Punktnotation noch
, zugreifen noch CGStruct als CGFloat erforderlich Ereignis, wenn & senden.Als eine andere Lösung für diese Situation sehe ich Erstellen von Objekt für Objekt mit Laufzeit und dann den Zeiger ändern. Vielleicht könnten einige Schritte mit Kopieren gemacht werden. Mein Problem ist, dass ich total neu in objc/Runtime und auch Dokumentation ist wirklich schlecht. Ich kämpfe, um diese bedeutende Technologie zu lernen, also bin ich absichtlich nicht das genaue Problem, das andere Wahlen benutzt.
Jede Hilfe würde sehr geschätzt werden. Vielen Dank im Voraus.
BTW Ich löste das ursprüngliche Problem mit Rahmen, mit Standart Objekt Erstellung. Die Verwendung der Laufzeit für die dynamische Wertänderung ist jedoch immer noch aktuell. – KysokZla