因为传递数据而缓慢的segue?

时间:2016-07-11 17:51:43

标签: ios objective-c uiviewcontroller uistoryboardsegue

我的应用中有两个UIViewController。在执行segue之前,其中一个将数据传递给另一个。然而,这个segue真的很慢,需要几秒钟。这是代码:

- (IBAction)barButtonRight:(id)sender {
    [[self.restaurant current] setName:self.textField.text];
    [self performSegueWithIdentifier:@"showRestaurant" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"showRestaurant"]) {
        UINavigationController *navController = segue.destinationViewController;
        RestaurantViewController *viewController = [navController.viewControllers objectAtIndex:0];
        viewController.restaurant = self.restaurant;
    }
}

当我评论viewController.restaurant = self.restaurant时,segue处于正常速度。有什么想过我怎么解决这个问题?

===

编辑:

事实证明,UITextView方法中的viewDidLoad使其变慢。这是代码:

self.myTextView = [[UITextView alloc] init];
self.myTextView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
self.myTextView.backgroundColor = [UIColor whiteColor];
self.myTextView.textColor = [UIColor textColor];
self.myTextView.font = [UIFont fontWithName:@"Raleway-Light" size:self.myTextView.font.pointSize];

0 个答案:

没有答案