iOS 动画问题

标签 ios objective-c uialertview ios-animations

希望有人能帮助我。最近,我的 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/

相关文章:

iOS UITableViewController 单元格在第一次更改时调整单元格高度后跳出位置

ios - 在我的应用程序中访问 iCloud 联系人时导致 iOS 崩溃

ios - 如何制作 uiview 的波浪边框?

ios - 如何在 Xcode 中的委托(delegate)方法(用户定义)中显示警报框?

ios - 如何在不同分辨率的不同设备上使用图像?

ios - UITableView 页脚、 Storyboard和 Xcode 6 的自动布局问题

ios - 如果 UIAlertView 被弃用,为什么它在 iOS 8 中仍然有效?

ios - AlertController 不在窗口层次结构中

ios - 如何在 UICollectionview 中使用 SDWebImage Frame 工作来从 Web 服务中解析图像?

objective-c - 为什么我不能在头文件中定义纯 C 函数?