使进度视图可见
|
我正在使用一个非常简单的iOS应用程序来开始编程。这是一个基于选项卡的应用程序,因此有一个MainWindow.xib以及FirstView.xib和SecondView.xib。所有这些都是在第一个视图中发生的。我想在“第一视图”中添加一个进度栏,当我添加对象时,它会附加到FirstView.xib上并显示出来,然后让我四处移动。为了进行测试,将alpha设置为1.00,将进度设置为0.5。无论如何,无论我做什么,它都不会显示。我究竟做错了什么?
AppDelegate.m:
@synthesize window=_window;
@synthesize tabBarController=_tabBarController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Add the tab bar controller\'s current view as a subview of the window
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
}
- (void)applicationWillTerminate:(UIApplication *)application
{
}
- (void)dealloc
{
[_window release];
[_tabBarController release];
[super dealloc];
}
@end
FirstViewController.h:
#import <UIKit/UIKit.h>
NSTimer *stopWatchTimer;
NSDate *startDate;
@interface FirstViewController : UIViewController {
UILabel *label;
UILabel *stopWatchLabel;
UIProgressView *progressBar;
UIButton *topButton;
}
@property (nonatomic, retain) IBOutlet UILabel *stopWatchLabel;
@property (nonatomic, retain) IBOutlet UIProgressView *progressBar;
- (IBAction)onStartPressed:(id)sender;
- (IBAction)onStopPressed:(id)sender;
- (IBAction)onResetPressed:(id)sender;
@end
FirstViewController.m
#import \"FirstViewController.h\"
@implementation FirstViewController
@synthesize progressBar;
@synthesize stopWatchLabel;
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.*/
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn\'t have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren\'t in use.
}
- (void)viewDidUnload
{
[self setStopWatchLabel:nil];
[topButton release];
topButton = nil;
[super viewDidUnload];
// Release any[progress release];
progressBar = nil;
[progressBar release];
progressBar = nil;
[self setProgressBar:nil];
//retained subviews of the[self setProgressBar:nil];
// e.g. self.myOutlet = nil;
}
static NSInteger counter=0;
static NSInteger secs=0;
static NSInteger mins=0;
static NSInteger hrs=0;
- (void)dealloc
{
[stopWatchLabel release];
[label release];
[topButton release];
[super dealloc];
}
-(void)updateTimer {
//updates the timer }
-(void)clearTimer {
//clears the timer
}
-(void)stopTimer{
//stops the timer }
- (IBAction)onStartPressed:(id)sender {
//stopWatchLabel.text=@\"Start Pressed\";
progressBar.alpha=1.0;
//run timer }
- (IBAction)onStopPressed:(id)sender {
[self stopTimer];
}
- (IBAction)onResetPressed:(id)sender {
[self stopTimer];
[self clearTimer];
}
@end
没有找到相关结果
已邀请:
1 个回复
仇聘发栖
编辑:可能与您的问题完全无关,但这全是错误的:
您可能希望它看起来像以下内容:
确保您了解自己做错了什么。正确执行这一点非常重要,否则应用程序将泄漏和/或崩溃。 您的其余代码实际上并没有执行任何操作。您似乎正在IB中做所有事情,所以我想这就是您的问题所在。