Reputation: 827
Hopefully someone can help me out. Recently I have been having issues with the animations inside my view. I have been unable to find a solution to it but until now it has been fine as nothing major was going on inside the view, but now I have an alert view showing inside the view after I click a table cell. The alert view comes from the top right hand corner of the screen and goes down the screen and gets bigger with the black background. I just want it to appear without coming down from the right hand top corner. I have always used the same method of showing alert views and never had animation issues before in my views. I will attach a link to the gif below. I will also add the code for the view.
GIF:
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
Thanks!
Upvotes: 0
Views: 110
Reputation: 827
I have found the solution, along with Vu's answer I done the following in my other view which was displaying track1.
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"track1"];
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:vc animated:YES completion:NULL];}
Changing it to the following and along with the solution Vu had fixed my issues:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"track1"];
[self presentViewController:vc animated:NO completion:NULL];}
Upvotes: 0
Reputation: 234
Do you use
[UIView beginAnimations: context:];
somewhere in your code?
Make sure call
[UIView commitAnimations];
right after setting animation option.
Upvotes: 2