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 .
Nice Tutorial,but can u customize the progress view.
hi dee hi iphonetut.com admin found your website via search engine but it was hard to find and I see you could have more visitors because there are not so many comments yet. I have discovered website which offer to dramatically increase traffic to your si
(7) Responses to this post