Custom ProgressView in Iphone


In this tutorial we will see the how we can create the custom progress view in iphone . This is the window  based app.Here are some steps for it…

 

 

1. Open the xcode & choose "File->New Project".

2. Select "Application" from left menu and then "Window-based Application".

3.Name your project as "ProgressViewBar" and save the project.

4.Now just select "ProgressViewBarViewController.h" file from left menu.

 

#import <UIKit/UIKit.h>


@interface ProgressViewBarViewController : UIViewController {

IBOutlet UIProgressView *progressView;

IBOutlet UIWebView *webView;

NSTimer *timer;

double mynumber;

    IBOutlet UIButton *button;

IBOutlet UITextField *textField;

}

@property(nonatomic,retain)IBOutlet UIProgressView *progressView;

@property(nonatomic,retain)IBOutlet UIWebView *webView;

@property(retain,nonatomic)IBOutlet UITextField *textField;

@property(nonatomic,readwrite)double mynumber;

 

-(IBAction)loadWeb;

-(void)loadTimer;

@end

 

5. Now select "ProgressViewBarViewController.m" file from menu for implementation.

#import "ProgressViewBarViewController.h"


@implementation ProgressViewBarViewController

@synthesize webView, progressView,textField,mynumber;




-(void)loadTimer

{

if (!webView.loading) {

mynumber = 0;

progressView.progress = mynumber;

}

else {

  mynumber = mynumber + 0.1;

  progressView.progress = mynumber;

}

}



-(IBAction)loadWeb

{

NSString *string1 = @"http://";

NSString *string2 = textField.text;

NSString *newString;

newString = [string1 stringByAppendingString:string2];

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:newString]]];

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

}

- (void)viewDidLoad {

    [super viewDidLoad];

mynumber = 0;

}





-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

[textField resignFirstResponder];

}



- (void)dealloc {

[progressView release];

[textField release];

    [super dealloc];

}


@end


 

6. Then Quit and Save the Interface Builder.


7. Now you are ready for  click on "Build & Go" button. 


Now you can see the output in iphone simulator .

 

 

 

 

 

 



(5) Responses to this post

Sabedrida Sep 11 2011 at 07:55:27

edgeramimmivY Sep 13 2011 at 17:51:36

Uncentababe Sep 20 2011 at 00:39:36

Uncentababe Sep 20 2011 at 18:36:43

Diaskdrieda Oct 17 2011 at 22:24:08


Leave your comment here






User Login




New User Forgot password

Newsletter Subscribe

Advertisement

 
 
 
quick contact