12
मैं एक चैट इतिहास दृश्य में चिकनी स्क्रॉलिंग को लागू करने की कोशिश कर रहा हूं, हालांकि यदि मैं जो सामग्री जोड़ता हूं वह काफी बड़ा है, तो चिकनी स्क्रॉल केवल कुछ पंक्तियों के लिए स्क्रॉल करेगी।NSTextView, पाठ और चिकनी स्क्रॉलिंग को जोड़ना
मेरा पहला अनुमान यह था कि दृश्य ने खुद को फिर से नहीं खींचा था .. मामला नहीं, यहां तक कि तत्काल ड्राइंग को मजबूर करने के दौरान भी - यह अभी भी टूट जाता है।
- (void)scrollAnimated:(BOOL)animated
{
if(animated)
{
NSClipView *clipView = [[_chatHistoryView enclosingScrollView] contentView];
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.100f];
NSPoint constrainedPoint = [clipView constrainScrollPoint:NSMakePoint(0, CGFLOAT_MAX)];
[[clipView animator] setBoundsOrigin:constrainedPoint];
[NSAnimationContext endGrouping];
}
else
{
NSRange range;
range.location = [[_chatHistoryView textStorage] length];
range.length = 1;
[_chatHistoryView scrollRangeToVisible:range];
}
}
मैं क्या गलत कर रहा हूं?
मुझे यकीन है कि यह आपकी समस्या का समाधान नहीं होगा, लेकिन गैर-एनिमेटेड कोड में अपने रेंज के रूप में सीमा से बाहर हो जाएगा लंबाई + 1 पर समाप्त हो जाएगा। – mattmook
थोड़ी देर के लिए उस कोड का उपयोग कर रहे थे, मुझे शायद दस्तावेज़ों में देखना होगा कि आखिरी चार के (स्थान + 1) क्यों (लंबाई (स्थान + 1) मुझे लगता है) स्वीकार किया जा रहा है। –