【问题标题】:Sending Array to viewcontroller将数组发送到视图控制器
【发布时间】:2014-05-27 05:33:47
【问题描述】:

如何通过 segue 将数据从一个视图控制器发送到另一个?

country = [[NSMutableArray alloc]initWithObjects:@"Afghanistan", @"Albania", 
@"Algeria", @"American Samoa", @"Andorra", @"Angola", @"Anguilla", @"Antarctica", 
@"Antigua and Barbuda", @"Argentina", @"Armenia", @"Aruba", @"Australia",
@"Austria", @"Azerbaijan", @"Bahamas", @"Bahrain", @"Bangladesh", @"Barbados",
@"Belarus", @"Belgium", @"Belize", @"Benin", @"Bermuda", @"Bhutan", @"Bolivia", 
@"Bosnia and Herzegovina", @"Botswana", @"Brazil", nil];


- (IBAction)onContactClick:(id)sender {

//[self performSegueWithIdentifier:@"TableViewController" sender:self];

【问题讨论】:

    标签: ios objective-c segue uistoryboardsegue xcode-storyboard


    【解决方案1】:

    使用 SMQuickSegue https://github.com/stefanomondino/SMQuickSegue 真的很简单,按照说明和示例通过 cocoapods 包含它(或者只需在下载后拖动 .h 和 .m 文件),将文件导入视图控制器(如果你扩展 SMQuickViewController可以)然后

    - (IBAction)onContactClick:(id)sender {
     [self performSegueWithIdentifier:@"TableViewController" parameters:@{@"country_array":country];
     }
    

    其中 country 是您的数组,而 country_array 是“下一个”视图控制器中的一个属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-07
      • 2018-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多