【发布时间】:2015-01-11 16:04:54
【问题描述】:
当我想在关闭模式后更新 UILabels 时遇到问题。 基本上我有: 带有一些 UILabel 和 UIButtons 的 ViewController 当我触摸一个按钮时,它会打开一个带有文本字段的模式,我在该文本字段中键入一些文本,该文本将保存到我所做的 CacheHandler 的实例中。 然后我用一个按钮关闭我的模式,我想看看我在 UILabel 中输入的文本。 文本保存在缓存中,我已经检查过了。当我从自定义 segue 调用它时,我有一种更新标签的方法,标签值为空。我哪里做错了?
自定义转场:
#import "DismissModalSegue.h"
#import "CreateSqeedViewController.h"
@implementation DismissModalSegue
- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
CreateSqeedViewController *destViewController = self.destinationViewController;
[sourceViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{
[destViewController updateLabels];
}];
}
@end
updateLabels 方法:
- (void)updateLabels {
NSLog(@"Updating labels: %@", [[[CacheHandler instance] createSqeed] place]);
/* displays what I want to display in my label */
NSLog(@"%@", whatLabel.text);
/* displays null */
whereLabel.text = [[[CacheHandler instance] createSqeed] place];
whatLabel.text = [[[CacheHandler instance] createSqeed] sqeedDescription];
NSString *peopleLabel = [NSString stringWithFormat:@"%@ / %@", [[[CacheHandler instance] createSqeed] peopleMin], [[[CacheHandler instance] createSqeed] peopleMax]];
whoLabel.text = peopleLabel;
whereLabel.text = [[[[CacheHandler instance] createSqeed] dateStart] description];
}
【问题讨论】:
-
为什么不使用在 VC 上调用方法的 unwind segue?并且不需要自定义 segue。
标签: ios objective-c uiviewcontroller uilabel segue