我需要查看一個活動指標的子視圖。 這是我的代碼,但子視圖不會出現:如何查看具有活動指標的子視圖?
@interface ProgressViewController : UIViewController {
IBOutlet UIActivityIndicatorView *myActivityIndicator;
}
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *myActivityIndicator;
@end
@implementation ProgressViewController
@synthesize myActivityIndicator;
- (void)viewDidLoad {
[myActivityIndicator startAnimating];
[super viewDidLoad];
}
- (void)viewWillDisappear:(BOOL)animated {
[myActivityIndicator stopAnimating];
}
@end
#import "ProgressViewController.h"
@interface MyViewController : UIViewController {
ProgressViewController *progressViewController;
}
@property (nonatomic, retain) ProgressViewController *progressViewController;
@end
@implementation MyViewController
@synthesize progressViewController
- (void)viewDidLoad
{
progressViewController = [[ProgressViewController alloc] initWithNibName:@"ProgressViewController" bundle:nil];
[self.view addSubview:progressViewController.view];
sleep(4);
[progressViewController.view removeFromSuperview];
[super viewDidLoad];
}
@end
你有一個XIB連接到這個代碼? – Tim 2011-04-26 15:36:20