我想attech UIActivityIndicator
與UITableView
那麼當第一次在iphone上的表活動加載必須開始閃爍,當表完全加載在iphone上時,當我點擊加載更多的單元格時,我也想顯示那一刻活動眨眼時更行敬請裝載告訴我,我該怎麼辦,這是代碼,如果你提前我怎麼可以在UITableView上添加UIActivityIndicator
#import "RootViewController.h"
#import "Tweet.h"
@implementation RootViewController
@synthesize customImage,pagecontrol,cell;//indexPath;
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad
{
pageSize = 2;
// totalpages =(NSInteger) (xmlParser.tweets)/5 ;
xmlParser = [[XMLParser alloc] loadXMLByURL:@"http://api.twitter.com/1/statuses/user_timeline/KentFranks.xml"];
[super viewDidLoad];
self.title = @"Tweets";
}
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if([xmlParser.tweets count]>pageSize)
{
return pageSize+1;
}
return xmlParser.tweets.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
//UIImage *twitterLogo = [[UIImage imageNamed:@"twitter-logo.png"]autorelease];
NSString *imagepath = [[NSBundle mainBundle] pathForResource:@"twitter-logo" ofType:@"png"];
UIImage *image =[[ UIImage alloc] initWithContentsOfFile:imagepath];
cell.imageView.image = image;
cell.detailTextLabel.text= @"Add Subtitle here";
Tweet *currentTweet = [[xmlParser tweets] objectAtIndex:indexPath.row];
if(indexPath.row<pageSize)
{
cell.textLabel.text = currentTweet.content;
}
else
{
cell.textLabel.text = @"Load more ";
}
NSLog(@"cell: %@",cell);
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
-(IBAction)loadmorebutton:(id)sender;
{
NSIndexPath *currentPath = [self.tableView indexPathForSelectedRow];
NSIndexPath *nextPath = [NSIndexPath indexPathForRow:currentPath.row+1 inSection:currentPath.section];
[self.tableView selectRowAtIndexPath:nextPath animated:YES scrollPosition:UITableViewScrollPositionMiddle];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row==pageSize)
{
pageSize=pageSize+2;
[tableView reloadData];
}
}
/*
-(IBAction)pagecontrol:(UIPageControl *)pageControl
{
[self.tableView reloadData];
}
-(IBAction)Pageindexchanges:(id)sender
{
NSLog(@"clicked page index: %i ",pagecontrol.currentPage);
}
*/
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 55;
}
#pragma mark -
#pragma mark Table view delegate
/*- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
*/
#pragma mark -
#pragma mark Memory management
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload
{
}
- (void)dealloc
{
[xmlParser release];
[super dealloc];
}
@end
,我與它的問題,我只是想表明對細胞活動的指標,在我點擊它必須停止動畫對細胞會上我已經點擊。但在你的代碼它仍然是動畫每先前的單元格,我點擊好心解決他的問題 – adnan
在didselected你可以通過點擊任何index.row單元格選擇停止動畫 –