IOS 在actionSheet中加载progressView实例

作者:朱克锋

邮箱:[email protected]

转载请注明出处:http://blog.csdn.net/linux_zkf


actionSheet中加载progressView实例

@interface TestViewController : UIViewController <UIActionSheetDelegate>

{

float amountDone;

UIProgressView *progressView;

UIActionSheet *actionSheet;

}

@property (retain) UIActionSheet *actionSheet;

@end


@implementation TestViewController

@synthesize actionSheet;


// 回调

- (void) incrementBar: (id) timer

{

    amountDone += 1.0f;

    [progressView setProgress: (amountDone / 20.0)];

if (amountDone > 20.0

{

[self.actionSheet dismissWithClickedButtonIndex:0 animated:YES];

self.actionSheet = nil;

[timer invalidate];

}

}

// actionSheet中加载progressView

-(void) action: (UIBarButtonItem *) item

{

amountDone = 0.0f;

    self.actionSheet = [[[UIActionSheet alloc] initWithTitle:@"加载数据。。。\n\n\n" delegate:nil cancelButtonTitle:nil destructiveButtonTitle: nil otherButtonTitles: nil] autorelease];

progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0.0f, 40.0f, 220.0f, 90.0f)];

    [progressView setProgressViewStyle: UIProgressViewStyleDefault];

    [actionSheet addSubview:progressView]; 

    [progressView setProgress:(amountDone = 0.0f)];

    [actionSheet showInView:self.view];

progressView.center = CGPointMake(actionSheet.center.x, progressView.center.y);

[progressView release];

[NSTimer scheduledTimerWithTimeInterval: 0.35 target: self selector:@selector(incrementBar:) userInfo: nil repeats: YES];

}

你可能感兴趣的:(ios,timer,action,float,interface)