Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Mac OS X Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-10-2011, 02:35 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 5
supersurabbit is on a distinguished road
Default Autoscroll problen…

1.Create a cocoa application (not document-based)

2.Create a new class "StretchView"(subclass NSView)

3.Open the Interface builder and drag a "Scroll view" to the main window

4.Choose the "Scroll view" and set the class "StretchView" (in class identity window)

The size of the contentview is 500*500 and the size of the strechview is also 500*500 (horizontal Scroll is enabled).

Then I start to draw some numbers(1,2,3,4......) horizontally one after the other. When the number is out of ranger(the x pos is larger than 500) I increase the width of the StretchView. (Everything works fine up till this point)

Then I tried to make the horizontal scroller to automatically scroll to the end so that everytime I increase the width of the StretchView the last number coulde be seen.

Here's the code:

//The timer is called every sec
-(void)myTimerActionNSTimer *) 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];
}
supersurabbit is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 370
8 members and 362 guests
husthlj, illogical, LegionMD, LunarMoon, mer10, Murphy, padsoftware, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,677
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, husthlj
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:12 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0