`
zjjzmw1
  • 浏览: 1353791 次
  • 性别: Icon_minigender_1
  • 来自: 开封
社区版块
存档分类
最新评论

block动画TableViewController的navigation

    博客分类:
  • iOS
阅读更多

block动画TableViewController的navigation

image1=[[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"pingguo.jpg"]];

image1.frame=CGRectMake(100, 100, 100, 110);

[self.view addSubview:image1];

[UIViewbeginAnimations:@"animate1"context:image1];

[UIViewsetAnimationDuration:2];

[UIViewsetAnimationDelegate:self];

// [UIView setAnimationDidStopSelector:@selector(animationDidStop: finished: context:)];

// [image1 setCenter:CGPointMake(image1.center.x+100, image1.center.y+200)];

[UIViewanimateWithDuration:4animations:^{

[image1 setCenter:CGPointMake(image1.center.x+100, image1.center.y+200)];

} completion:^(BOOL finished) {

[image1removeFromSuperview];

}

];

[UIViewcommitAnimations];

 

}

//-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context{

// [(UIImageView *)context removeFromSuperview];

//}

 
TableViewController
在TableViewController.h里一定要继承UITableVIewController.
这样实现的代理就自动生成了
 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

self.window = [[[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]] autorelease];

// Override point for customization after application launch.

self.window.backgroundColor = [UIColorwhiteColor];

[self.windowmakeKeyAndVisible];

 

TableViewController *table = [[TableViewControlleralloc] initWithStyle:UITableViewStyleGrouped];//使TabkeViewController初始化

 

UINavigationController *nav = [[UINavigationControlleralloc] initWithRootViewController:table]; //初始化nav 并把TableViewController作为navigation的主窗口显示

[self.windowsetRootViewController:nav];

[table release];

[nav release];

 

returnYES;

}

 
 

@interface TableViewController : UITableViewController {

 

NSArray *array;

}

 

 

#import "TableViewController.h"

#import "MyViewController.h"

 

@implementation TableViewController

 

- (id)initWithStyle:(UITableViewStyle)style

{

self = [super initWithStyle:style];

if (self) {

array = [[NSArray alloc] initWithObjects:@"one", nil];

}

returnself;

}

 

- (void)viewDidLoad

{

[superviewDidLoad];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return array.count;

}

 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

 

if (!cell) {

cell = [[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier] autorelease];

}

//下面三行是自己写的。

NSString *string = [array objectAtIndex:[indexPath row]];

 

[cell.textLabel setText:string];

 

return cell;

}

 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

 

MyViewController *myph = [[MyViewControlleralloc] init];

[self.navigationControllerpushViewController:myph animated:YES];

[myph release];

}

 

 

 

@end

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics