ios把数据传递到另一个页面_如何在IOS中将数据从一个视图传递到另一个视图控制器?...

I am using Xcode 4.3.1. I have created the UI using Storyboard which has many View Controllers.

Issue

In my app i am using ShakeGesture. While shaking i am doing some operations, its working fine. But, when shaking get stopped i need to pass some values to another View controller to display it. I have seen many post it says how to pass value when button clicked,but no one related with my problem.

It would be great if you solve my issue

My question is

How to pass values from one View to another View controller after shaking get stopped?

I am looking for any examples or tutorials. Much appreciated.

EDIT

Exact function for the above question

I am having an button in First View Controller

When the button triggered it will popup pickerview with some datas. When the user selects it the picker value replaces the button value.

Then Shaking happens when it stopped i have to pass the data to other view controller.

Code

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {

if (event.subtype == UIEventSubtypeMotionShake)

{

// I need to pass data here. Thats i am confusing

}

}

Thanks for your help guys

解决方案

Create a segue by ctrl dragging from the first view controller to the second one in the storyboard. Click on the segue and go to the identity inspector (press command-option-3). In the identifier field give it a name, say "Shaking Stopped". Then in your motion ended method use...

[self performSegueWithIdentifier:@"Shaking Stopped" sender:self];

This will make the view switch to your second one. Then in your prepare for segue change it to this...(of course using your own values)

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

if ([segue.identifier isEqualToString:@"Shaking Stopped"]) {

*controller = segue.destinationViewController

//change your values in the other view controller here

controller.someValue = self.someValue //an example

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值