如何在iPhone应用程序中通过弹出框传递字符串值

时间:2014-10-28 09:34:27

标签: iphone

我有一个UIViewcontroller和一个自定义UIPopovercontroller

我无法将NSString值传递给UIPopovercontroller类。

这是示例代码。

  UINavigationController* contentViewController = [[UINavigationController alloc] initWithRootViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"MoveToObjectViewController"]];
popoverController = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
    popoverController.delegate = self;
[popoverController presentPopoverFromRect:CGRectZero inView:nil permittedArrowDirections:WYPopoverArrowDirectionNone animated:YES];

请帮帮我。

1 个答案:

答案 0 :(得分:0)

为您的WYPopoverController创建一个属性,并在呈现之前进行设置

WYPopoverController.h

@interface WYPopoverController : UIPopoverController

... 

@property (nonatomic,strong) NSString * YOUR_PROPERTY_NAME;

@end

...您使用它的文件

popoverController = [[WYPopoverController alloc] initWithContentViewController:contentViewController]; 

popoverController.YOUR_PROPERTY_NAME=@"Some serious shit";

[popoverController presentPopoverFromRect:CGRectZero inView:nil permittedArrowDirections:WYPopoverArrowDirectionNone animated:YES];