Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TedB · Feb 23, 2012 at 03:48 AM · iosnative pluginobjective-cviewcontroller

How to Display a UIPopOver on iPad

Using the NativeToolkit to call a view, I anticipated that I would be able to display a view that, when loaded, would immediately display a UIPopOverController.

The view, I imagine, would need to be a transparent view, and the UIPopOver would initialize with a separate view inside it containing the controls I wanted to display. When the player taps outside the PopOver, the PopOver view would be dismissed and the player would return back to Unity.

Is this the right way to do this? I am not having success. I did see another question here that partially addressed using UIPopOver with Unity, so I know it is technically possible. I just need the particulars on how to implement it.

I can display a view just fine. When I try to display my PopOver view, the app appears to be stuck and reports in the iOS SDK console: "PlayerLoop called recursively!". I am trying to be very basic just to get it working. Here is what I have.

In Unity, I have the script that came with NativeToolkit attached to an empty GameObject called GUI. It has, in part:

 if( GUI.Button( new Rect( 10, 10, 100, 40 ), "Load PopOver" ) ) // was xPos,yPos,width,height
         {
             NativeToolkitBinding.activateUIWithController( "PopOver" );
         }

In m XCode project, in the NativeTools folder, I have PopOver.h, PopOver.m and PopOver.xib.

PopOver.h:

 #import <UIKit/UIKit.h>
 
 
 @interface PopOver : UIViewController <UIPopoverControllerDelegate, UINavigationControllerDelegate> {
 
 }
 
 @end

PopOver.m:

 #import "PopOver.h"
 #import "TestViewController.h"
 
 @implementation PopOver
 
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
 
 /*
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     if (self) {
         // Custom initialization.
     }
     return self;
 }
 */
 
 
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
     [super viewDidLoad];
  
     TestViewController *testViewController = [[TestViewController alloc] init];
     UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:testViewController];
     [pop setDelegate:self];
     [pop presentPopoverFromRect:CGRectMake( 25, 25, 320, 400 ) 
                          inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny 
                        animated:YES];
     
     [pop setPopoverContentSize:CGSizeMake(320, 400)];
     [testViewController release];
 }


TestViewController.m:

 #import "TestViewController.h"
 #import "NativeToolkit.h"
 #import "PlayerPrefs.h"
 
 
 @implementation TestViewController
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 #pragma mark NSObject
 
 - (void)dealloc
 {
     [super dealloc];
 }
 
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {
     [super viewDidLoad];
     
     self.contentSizeForViewInPopover = CGSizeMake(320, 400);
 }
 
 
 - (IBAction)onTouchDone
 {
     [[NativeToolkit sharedManager] hideViewController:self];
 }


Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TedB · Mar 30, 2012 at 11:09 PM 0
Share

I have been successful in having a GUI button in Unity bring up a ViewController that in turn had an iOS UI button toolbar. When the iOS button is pressed, the UIPopOver openes just fine.

What I have not been able to yet accomplish is to open the UIPopover on top of my Unity3d scene without displaying an iOS ViewController window.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Using NavigationController in an iOS plugin 1 Answer

Sharing image and text using objective c native code 1 Answer

Issue with integration into native iOS app 1 Answer

Using an Objective-c framework directly in Unity 3d 3 Answers

iOS modal viewcontroller disappears 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges