Je travaille sur une application iOS très simple pour démarrer la programmation. C'est une application basée sur un onglet, donc il y a un MainWindow.xib avec un FirstView.xib et SecondView.xib. Tout cela se passe dans la première vue. Je veux ajouter une barre de progression à la première vue, et quand j'ai ajouté l'objet il s'est attaché à FirstView.xib et apparaît et me permet de le déplacer. Pour tester, l'alpha est fixé à 1,00 et la progression est fixée à 0,5. Indépendamment de cela, il n'apparaît pas, peu importe ce que je fais. Qu'est-ce que je fais mal?Rendre la vue Progression visible
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 {
//[email protected]"Start Pressed";
progressBar.alpha=1.0;
//run timer }
- (IBAction)onStopPressed:(id)sender {
[self stopTimer];
}
- (IBAction)onResetPressed:(id)sender {
[self stopTimer];
[self clearTimer];
}
@end
Comment sommes-nous censés savoir ce que vous faites mal quand nous ne savons pas ce que vous faites? Il est beaucoup plus facile de vous aider si vous postez du code. Sinon, nous tirons juste dans l'obscurité. –
Vous n'ajoutez pas le contrôleur de vue FirstView au contrôleur de tabulation ou Erik n'a pas ajouté la barre de progression comme sous-vue du FirstView. Si vous le faites bien, nous aurons besoin de voir plus d'informations comme le code pour comprendre le problème. –
J'ai ajouté le code au délégué et aux contrôleurs de vue. Je peux joindre le fichier .xib quelque part aussi bien si nécessaire. – Laxsnor