1.Createカカオアプリケーションオートスクロールproblen
2.Create新しいクラス "StretchView"(サブクラスNSViewの)
3.Openインタフェースビルダーを(ベースの文書ではない)と、「スクロール表示をドラッグ(クラス同一ウィンドウ内)スクロールビュー 『とクラスセット『StretchViewを』"メインウィンドウ
4.Chooseに』
contentviewのサイズは500×500であるとstrechviewのサイズであります500 * 500 (水平スクロールが有効) 。
次に、数字を1,2,3,4 ......水平に1つずつ描き始めます。 番号がレンジャーから外れているとき(x posが500より大きい)、私はStretchViewの幅を 増やします。 (すべてが、この時点までの罰金作品)
それから私は毎回、私は最後の数が を見ることがcoulde StretchViewの幅を広げるように 自動的に最後までスクロールする水平スクロールバーを作ってみました。ここで
はコードです:
//The timer is called every sec
-(void)myTimerAction:(NSTimer *) timer
{
NSLog(@"myTimerAction");
//......
int i = _myArray.count;
NSRect rect = [self frame];
int width = rect.size.width;
//The width between two number is 10
//When the x pos of current num is bigger then the scroll's width
if((i * 10) > width) {
//reset the width
width = i * 10;
[self setFrameSize:CGSizeMake(width, rect.size.height)];
//How to make it autoscroll???
//...............................
}
//......
[self setNeedsDisplay:YES];
}
そして何が問題なのですか? – MSalters