【问题标题】:Draggable/tabbable UIPopOverController?可拖动/可选项 UIPopOverController?
【发布时间】:2011-06-17 22:27:19
【问题描述】:

我不知道你们是否熟悉 iPad 版 Blackboard Learn 应用程序。它有弹出窗口来显示信息。

好吧,我想在 iPad 应用程序上实现类似的东西,我想知道是否可以使用 UIPopOverControllers 来实现...

基本上,您可以打开一个视图并将其拖动并保持在屏幕的边框上作为一个标签来显示更新等等。

是否可以用 UIPopOverControllers 或 UIViews 做类似的事情(拖动和标签)?

来自墨西哥的欢呼


更新 1:

好吧,我设法加载了多个 UIView,接下来可以拖动它们,有什么建议吗?


更新 2:

我尝试在 otherView.m(弹出窗口)中添加 UIPanGestureRecognizer,如下所示

otherView.h

@interface otherView : UIViewController <UIGestureRecognizerDelegate>{

        UIPanGestureRecognizer *drag;
}

@property (nonatomic, retain) UIPanGestureRecognizer *drag;

...

otherView.m

- (void)viewDidLoad {
    [super viewDidLoad];

    // Drag
    drag = [[UIPanGestureRecognizer alloc]
                                         initWithTarget:self action:@selector(dragAction)];

    [self.view addGestureRecognizer:drag];
    [drag release];
}

otherView直接从appDelegate显示在mainWindow中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after app launch.

    // Set the view controller as the window's root view controller and display.
    //self.window.rootViewController = self.viewController;
    [window addSubview:viewController.view];
    [window addSubview:secondView.view];
    [self.window makeKeyAndVisible];

return YES;
}

希望你能帮帮我

【问题讨论】:

    标签: objective-c ios cocoa-touch uiview view


    【解决方案1】:

    据我所知,没有机制可以在屏幕上移动弹出框 - 它们附加到条形按钮或视图中的点,并且它们一直存在,直到它们被解除。弹出框也不允许在可见时与主视图中的视图(按钮、文本字段等)进行交互。

    听起来像是一个很棒的用户界面概念,祝你好运!

    【讨论】:

    • 然后我想我可以加载一个 UIView,但我不确定这是否可能(按下按钮时打开一个较小的 UIView,而主视图在背景中仍然可见)。
    • 好吧,我设法加载了多个 UIView,接下来可以拖动它们,有什么建议吗?
    • 为你想要移动的 UIView 创建一个UIPanGestureRecognizer。小心测量相对于视图父级的位置,否则移动视图可能会混淆手势。
    • 我应该在哪里声明 UIPanGestureRecognizer?在委托中,主窗口或较小的窗口(显示为弹出窗口且可拖动的窗口)。在更新 2 中有我尝试过的内容
    • 我认为你声明它的位置并不重要,但你将它附加到你想要移动的视图上:[theMovingView addGestureRecognizer: myPanGesture]; 并将手势上的目标和选择器分配给这样的东西:[myPanGesture addTarget:myMainViewController action:@selector(doSomethingWithPanGesture:)]; 并且您的方法将在您的视图控制器类中定义为 - (void)doSomethingWithPanGesture:(UIGestureRecognizer*)gesture {} 手势非常好用 - 玩得开心!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-03
    • 2018-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-25
    相关资源
    最近更新 更多