gpt4 book ai didi

iOS 动画问题

转载 作者:行者123 更新时间:2023-11-28 21:33:48 24 4
gpt4 key购买 nike

希望有人能帮助我。最近,我的 View 中的动画一直存在问题。我一直无法找到它的解决方案,但直到现在它一直很好,因为 View 内没有发生任何重大事件,但现在我在单击表格单元格后在 View 内显示了一个警报 View 。警报 View 来自屏幕的右上角,沿着屏幕向下,随着黑色背景变大。我只是想让它出现而不会从右上角掉下来。我一直使用相同的方法来显示警报 View ,以前在我的 View 中从未出现过动画问题。我将在下面附上 gif 的链接。我还将添加 View 的代码。

动图:

https://imgflip.com/gif/x61vg

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];

在设置动画选项之后。

关于iOS 动画问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34718472/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com