首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用展开式UITextField传递数据

用展开式UITextField传递数据
EN

Stack Overflow用户
提问于 2015-03-20 16:12:38
回答 1查看 141关注 0票数 0

我有两个视图: View1 (商店):NSString中存储的用于显示图像的URL。

View2 (ModifyShop):带有来自view1的URL的文本字段。

我可以将数据从view1传递给view2 :存储在NSString中的URL出现在文本字段中。

现在,我想用来自view2的文本字段修改这个URL,并修改view1中的NSString。我怎么能做到呢?

这是我的代码:

商店:

代码语言:javascript
复制
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.modifyButton setHidden:YES];
    dispatch_async(dispatch_get_global_queue(0,0), ^{
        self.imageButtonURL = @"http://bundoransurfshop.com/wp-content/uploads/2015/02/72-torq-pink.jpg";
        imageButtonData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:self.imageButtonURL]];
        if ( imageButtonData == nil )
            return;
        dispatch_async(dispatch_get_main_queue(), ^{
            self.imageButton.imageView.image = [UIImage imageWithData: imageButtonData];
        });
    });
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"modifyShop"]) {
        ShopModify *viewcontroller = (ShopModify *)segue.destinationViewController;
    viewcontroller.imageButtonURL = self.imageButtonURL;      }
}

-(IBAction)prepareForUnwind:(UIStoryboardSegue *)segue {
    NSLog(@"%@", self.imageButtonURL);}

ModifyShop:

代码语言:javascript
复制
- (void)viewDidLoad {
    [super viewDidLoad];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.photoURL.text = [NSString stringWithFormat:@"%@", self.imageButtonURL];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        Shop *viewcontroller = (Shop *)segue.destinationViewController;
        viewcontroller.imageButtonURL = self.photoURL.text;
}

这让我的应用程序崩溃了:

代码语言:javascript
复制
[Reports setImageButtonURL:]: unrecognized selector sent to instance
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-20 16:23:29

错误是,您正在绑定以在报表实例上设置imageButtonURL,而不是在Shop上设置您认为目标视图控制器是什么。似乎你的放松是错误的控制器。你一定是把松开的海格挂错了。您说您有两个视图(实际上是视图控制器),但是您还必须在应用程序中有一个Reports类。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29171113

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档