Progress

헤더 파일


@interface ViewController : UIViewController

{

    NSTimer *timer;

    UIActivityIndicatorView *syActivityView;

}


- (void) update : (NSTimer *)sender;


메인 파일


- (void)viewDidLoad

{

    [super viewDidLoad];

    

    UIProgressView *myProgressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];

    

    CGRect progressFrame = CGRectMake(10, 100, 300, 25);

    

    [myProgressView setFrame:progressFrame];

    [myProgressView setProgress:0.0];

    

    [self.view addSubview:myProgressView];

    [myProgressView release];

    

    timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(update:) userInfo:myProgressView repeats:YES];

    

    syActivityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    

    CGRect syFrame = CGRectMake(120, 130, 50, 50);

    

    [syActivityView setFrame:syFrame];

    

    [syActivityView startAnimating];

    [self.view addSubview:syActivityView];

    [syActivityView release];

}


- (void) update:(NSTimer *)sender

{

    UIProgressView *progress = [sender userInfo];

    

    if(progress.progress == 1.0)

    {

        [timer invalidate];

        [syActivityView stopAnimating];

    }

    else 

    {

        progress.progress += 0.01;

    }

}

'Developer > iOS - Objective-C' 카테고리의 다른 글

Gesture  (0) 2012.09.12
메모리 해제 (dealloc, release)  (0) 2012.09.11
Progress  (0) 2012.09.11
ScrollView  (0) 2012.09.11
AlertView / ActionSheet 활용  (0) 2012.09.10
Notification 활용  (0) 2012.09.10

이 글을 공유하기


댓글(0)

Designed by CMSFactory.NET