【发布时间】:2012-07-19 04:26:56
【问题描述】:
我在 TableViewController 上有一个 UIActivityIndicatorView。当我在 init 中开始制作动画时,我会看到活动指示器,但是当我将 start 命令移动到其他任何地方时,它将无法工作/显示。有谁知道我做错了什么,我似乎无法在这里找到它。我希望它在我加载数据时显示。
TableViewController.h
#import <UIKit/UIKit.h>
@interface CategoryTableViewController : UITableViewController {
NSArray *cats;
UIActivityIndicatorView *activityIndicator;
}
@end
TableViewController.m
#import "CategoryTableViewController.h"
#import "NieuwsDataManager.h"
#import "CategoryTableCell.h"
#import "NiewsCategory.h"
#import "NieuwsTableViewController.h"
@implementation CategoryTableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
cats = [[NSArray alloc ] initWithArray:[NieuwsDataManager sharedInstance].newsCategories];
self.title = @"Nieuws" ;
activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame: CGRectMake(100,150,120,120)];
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
[self.view addSubview:activityIndicator];
}
return self;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[activityIndicator startAnimating];
NiewsCategory *cat = [[NieuwsDataManager sharedInstance].newsData objectForKey:[cats objectAtIndex:indexPath.row]];
[[NieuwsDataManager sharedInstance] getNewsByCategory:cat];
NieuwsTableViewController *nt = [[NieuwsTableViewController alloc] initWithCategory:cat];
[activityIndicator stopAnimating];
[self.navigationController pushViewController:nt animated:YES];
[nt release];
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}
【问题讨论】:
标签: iphone ios uiactivityindicatorview