将数组发送到viewcontroller

时间:2014-05-27 05:33:47

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

如何通过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];

1 个答案:

答案 0 :(得分: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是“下一个”视图控制器中的属性。