iOS 动画问题
iOS Animation Issues
希望有人能帮助我。最近,我的视图中的动画一直存在问题。我一直无法找到解决方案,但直到现在它都很好,因为视图内没有发生任何重大事件,但现在我在单击 table 单元格后在视图内显示了一个警报视图。警报视图来自屏幕的右上角,沿着屏幕向下,随着黑色背景变大。我只是想让它出现而不会从右上角掉下来。我一直使用相同的方法来显示警报视图,以前在我的视图中从未出现过动画问题。我将在下面的 gif 中附加一个 link。我还将添加视图的代码。
动图:
Track1.h
//
// Track1.h
// uDropOff 3
//
// Created by Curtis Boylan on 06/01/2016.
// Copyright © 2016 Curtis Boylan. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TableViewCell.h"
@interface Track1 : UIViewController <UITableViewDelegate,UITableViewDataSource>
- (IBAction)back;
@property (weak, nonatomic) IBOutlet UITextField *trackingnumber;
- (IBAction)track;
@property (weak, nonatomic) IBOutlet UITableView *tableViewObject;
@end
Track1.m
//
// Track1.m
// uDropOff 3
//
// Created by Curtis Boylan on 06/01/2016.
// Copyright © 2016 Curtis Boylan. All rights reserved.
//
#import "Track1.h"
#import "TableViewCell.h"
@interface Track1 ()
@end
@implementation Track1
{
NSMutableArray *tableAray;
}
- (void)viewDidLoad {
[super viewDidLoad];
tableAray = [[NSMutableArray alloc] initWithObjects:@"test",@"test2", nil];
// [self webstuff1];
// Do any additional setup after loading the view.
// UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
// [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
// [self.table addSubview:refreshControl];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)back {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"main"];
[self presentViewController:vc animated:YES completion:NULL];
}
- (IBAction)track {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// saving an NSString
[prefs setObject:self.trackingnumber.text forKey:@"uDropOffTracking"];
Track1 *track2 = [self.storyboard instantiateViewControllerWithIdentifier:@"track2"];
[self presentViewController:track2 animated:NO completion:nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableAray count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 70;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"TableViewCell";
TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil];
cell = [nibArray objectAtIndex:0];
}
cell.tracking.text = [tableAray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIAlertView *selectedAlert = [[UIAlertView alloc]
initWithTitle:[NSString stringWithFormat:@"%@ Selected", [tableAray objectAtIndex:indexPath.row]] message:[NSString stringWithFormat:@"It takes 20 mins to prepare!"] delegate:nil cancelButtonTitle:@"Got It" otherButtonTitles:nil];
[selectedAlert show];
}
@end
谢谢!
你用
[UIView beginAnimations: context:];
代码中的某处?
确保打电话
[UIView commitAnimations];
设置动画选项后。
我找到了解决方案,连同 Vu 的回答我在显示 track1 的另一个视图中完成了以下操作。
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"track1"];
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:vc animated:YES completion:NULL];}
将其更改为以下内容以及 Vu 解决了我的问题:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"track1"];
[self presentViewController:vc animated:NO completion:NULL];}
希望有人能帮助我。最近,我的视图中的动画一直存在问题。我一直无法找到解决方案,但直到现在它都很好,因为视图内没有发生任何重大事件,但现在我在单击 table 单元格后在视图内显示了一个警报视图。警报视图来自屏幕的右上角,沿着屏幕向下,随着黑色背景变大。我只是想让它出现而不会从右上角掉下来。我一直使用相同的方法来显示警报视图,以前在我的视图中从未出现过动画问题。我将在下面的 gif 中附加一个 link。我还将添加视图的代码。
动图:
Track1.h
//
// Track1.h
// uDropOff 3
//
// Created by Curtis Boylan on 06/01/2016.
// Copyright © 2016 Curtis Boylan. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TableViewCell.h"
@interface Track1 : UIViewController <UITableViewDelegate,UITableViewDataSource>
- (IBAction)back;
@property (weak, nonatomic) IBOutlet UITextField *trackingnumber;
- (IBAction)track;
@property (weak, nonatomic) IBOutlet UITableView *tableViewObject;
@end
Track1.m
//
// Track1.m
// uDropOff 3
//
// Created by Curtis Boylan on 06/01/2016.
// Copyright © 2016 Curtis Boylan. All rights reserved.
//
#import "Track1.h"
#import "TableViewCell.h"
@interface Track1 ()
@end
@implementation Track1
{
NSMutableArray *tableAray;
}
- (void)viewDidLoad {
[super viewDidLoad];
tableAray = [[NSMutableArray alloc] initWithObjects:@"test",@"test2", nil];
// [self webstuff1];
// Do any additional setup after loading the view.
// UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
// [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
// [self.table addSubview:refreshControl];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)back {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"main"];
[self presentViewController:vc animated:YES completion:NULL];
}
- (IBAction)track {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// saving an NSString
[prefs setObject:self.trackingnumber.text forKey:@"uDropOffTracking"];
Track1 *track2 = [self.storyboard instantiateViewControllerWithIdentifier:@"track2"];
[self presentViewController:track2 animated:NO completion:nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableAray count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 70;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"TableViewCell";
TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil];
cell = [nibArray objectAtIndex:0];
}
cell.tracking.text = [tableAray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIAlertView *selectedAlert = [[UIAlertView alloc]
initWithTitle:[NSString stringWithFormat:@"%@ Selected", [tableAray objectAtIndex:indexPath.row]] message:[NSString stringWithFormat:@"It takes 20 mins to prepare!"] delegate:nil cancelButtonTitle:@"Got It" otherButtonTitles:nil];
[selectedAlert show];
}
@end
谢谢!
你用
[UIView beginAnimations: context:];
代码中的某处?
确保打电话
[UIView commitAnimations];
设置动画选项后。
我找到了解决方案,连同 Vu 的回答我在显示 track1 的另一个视图中完成了以下操作。
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"track1"];
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:vc animated:YES completion:NULL];}
将其更改为以下内容以及 Vu 解决了我的问题:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"track1"];
[self presentViewController:vc animated:NO completion:NULL];}