【问题标题】:Segue to class using UIScrollView and NSNotificationCenter使用 UIScrollView 和 NSNotificationCenter 继续上课
【发布时间】:2013-08-05 17:02:38
【问题描述】:

我正在制作一个 iPhone 应用程序,该应用程序显示一个 UIScrollView,其中包含从数据库中获取的行中的数据。

ViewController1:

-(void)viewDidLoad 
{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(eventHandler:) name:@"onEvent" object:nil];
}

- (IBAction) eventHandler:(NSNotification *) notification {
    [RequestRowView initialize];
}

在请求行视图中:

-(IBAction)onSelected:(id)sender {

    [[NSNotificationCenter defaultCenter] postNotificationName:@"onEvent" object:nil];

    Globals* global = [Globals getInstance];
    global.fulfillRequestLocationName = name;
    global.fulfillRequestCityStateZip = cityStateZip;
    global.fulfillRequestExpirationDate = endDateTime;

    NSLog(@"global vars are %@ %@ %@", global.fulfillRequestLocationName, global.fulfillRequestCityStateZip, global.fulfillRequestExpirationDate);   
}

UIScrollView 中的行显示正常,但每当我单击该行时,它只会执行 NSLog。

我的问题是:我如何让它转入另一种观点?

在一些事情中,我在类中创建了一个隐藏按钮,该按钮使用 [performSegueWithIdentifier] 执行 IBAction 函数,但我收到接收类没有该标识符的错误。

这是我对 NSNotificationCenter 不理解的问题,还是我在创建按钮时错误地调用了类的实例?

【问题讨论】:

    标签: xcode uiscrollview segue nsnotificationcenter


    【解决方案1】:

    知道了!我在 View Controller (http://www.youtube.com/watch?v=XApYtAlRDVE) 中创建了一个自定义按钮 segue,并在我的 eventHandler 函数中定义了 [self nextButton]。

    但是,当它转到下一个视图时,变量不会立即显示。我单击返回“主页”,然后再次选择该行,然后变量才会显示在它们各自的标签中。

    这是否与 Xcode 中如何定义全局变量有关?

    【讨论】:

      猜你喜欢
      • 2013-01-15
      • 2021-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多