Draggable/tabbable UIPopOverController? - objective-c

I don't know if you people are familiar with the Blackboard Learn app for iPad. Well it has PopUp windows to show info.
Well, I would like to implement something similar on a iPad app, and I was wondering if it is possible to doit with UIPopOverControllers...
Basically you can open a view and drag it around and keep it on a border of the screen as a tab to show updates and so.
Is it possible to do something similar with UIPopOverControllers or UIViews (the dragging and the tabbing)?
Cheers from Mexico
UPDATE 1:
Well, I managed to load multiple UIViews, next thing goes to be able to drag 'em around, any suggestions?
UPDATE 2:
I tried to add the UIPanGestureRecognizer in otherView.m (the Pop Up Window), here's how it looks
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 is displayed in mainWindow directly from the appDelegate
- (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;
}
Hope you can help me out

As far as I know there is no mechanism to move a popover around on the screen - they are attached to a bar button or point in a view and that is where they exist until they are dismissed. Popovers also don't allow interaction with views (buttons, text fields etc) in the main view while they are visible.
Sounds like a great user interface concept though, good luck!!

Related

Spritekit iAds messing with scene size

I am making a game using spritekit and everything works perfectly except when I add the code to add an iAd. When I add the iAd everything works but it seems that the iAd is resizing the scene when it is being displayed.
This is my code to display the iAd, it is in the ViewController.m :
#import <iAd/iAd.h>
#import "ViewController.h"
#import "MainMenu.h"
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Configure the view.
SKView * skView = (SKView *)self.originalContentView;
skView.showsFPS = YES;
// Create and configure the scene.
SKScene * scene = [MainMenu sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
self.canDisplayBannerAds = YES;
// Present the scene.
[skView presentScene:scene];
}
Like I say, the iAd shows up, and all the function properly but the when the iAd is displayed it makes the scene smaller, is there a method or something that allows the scenes to not be resized?
An help is much appreciated, thanks!
Ok so I sort of figured it out, I was using scaleMode of SKSceneScaleModeAspectFit I have now changed it to SKSceneScaleModeFill this seems to make the scene shorter but it is not as noticeable as the aspectFit scale mode. I have also noticed that the iAd does not act like a sprite as it actually distorts or resizes the screen. If anyone knows how to create the iAd on top of the view, like sprite, please add a comment or solution.
EDIT
I have just figured out that one can add an ADBannerView to the viewcontroller in the interface builder, this will show the ad on all scenes. I am now trying to figure out how this can be set to not display on specific scenes seeing spritekit only uses one viewcontroller.
If you add the ad by adding in the AdBannerView then you have to create seperate methods in the view controller to turn the ads on or off, by creating these seperate methods it allows one to have manual control over the ads in the view controller from any scene.
In the view controller you have a scene that you create, this scene variable/object has a property of tag or userdata. So if your game goes to a different scene you can call
[super scene] setTag:x]
Every time that the NSTimer calls my control method it checks the value of the scenes tag in the view controller and based on that value it will remove or re-display the ad.
Just a thought, but you could also put the AdBannerView in via the Storyboard editor, and then set
self.canDisplayBannerAds = NO;
That way it will just overlay the SKScene instead of shrinking it.
Hope this helps!
There is another way to fix this problem. You might want to have a look at this Thread.
iAd in Spritekit
Just a sneak preview:
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.delegate = self;
[adView setFrame:CGRectMake(0, 0, 1024, 768)]; // set to your screen dimensions
[adView setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:adView];

UITextField not working inside a UITabBarController with IOS5

Are there any restrictions on a UITextField when placed inside a tabview which not the main interface. In other words
Working fine scenario
1. A tab based application, with one of the view having a UITextField.
2. The tabview is the main interface for the application.
This works fine without any glitches
Not-working so fine scenario.
1. A tab based application, but the tab view is not the mainview.
2. There is another view MainWindow.xib with some intro animation, which then calls and shows the tabview.
3. UITextfield in such tabviews does'nt seem to work - especially in IOS5. Both methods work fine till IOS 4.3
4. The textfield is visible, but tapping it does not show any keyboard, if i call becomeFirstResponder via code, the keyboard is shown but is not responsive.
Any suggestions
The code is pretty standard
in the AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
tabViewController = [[tabView alloc] initWithNibName:#"tabView" bundle:nil];
[self.window addSubview:tabViewController.view];
//self.window.rootViewController=tabViewController
[self.window makeKeyAndVisible];
return YES;
}
tabViewController has a ProfileViewController with a simple textfield.
The textfield works fine if i do this
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
tabViewController = [[tabView alloc] initWithNibName:#"tabView" bundle:nil];
profileView=[[Profile alloc] initWithNibName:#"Profile" bundle:nil];
//calling the view directly without using a tab view
[self.window addSubview:profileView.view];
[self.window makeKeyAndVisible];
return YES;
}
Is there something else that needs to be done for IOS5 when the tab view is not the main interface? I have been cracking my head at this for a few days, all my apps with a UITextfield inside a tabview are not usable in ios5. Any help is highly appreciated
Edit: Uploaded the project file http://www.mediafire.com/?xjuc4udlph78saj - XCode 4.2 on Lion
It is a simple project with two options, Creating a tabbarcontroller from the delegate itself, and i also have a view(tabView) with a tabbarcontroller. There are 2 views for the tabbar FirstViewController & SecondViewController.
In the AppDelegate.m if using method 1(create UITabBarController inside AppDelegate, all is well). If i choose to add a subview of tabView, the uitextfield does not work.
I have not really handled the releasing of objects, since this is test project and it is only for proof of concept.
Thanks
After hours of searching, fiddling and experimenting. I have found out the solution.
This seems to happen when there are more than one UIWindow in the application.
In my case, i was diong this
AppDelegate starts off with its own UIWindow Once i have played some
startup animations, i try to display another view with a
tabbarcontroller, and ofcoures a window to hold the UITabBarController
The second window (even after setting it to makeKeyAndVisible) seems
to be blocking keyboard events fore UITextField inside the
UITabBarController.
The following has worked for me:
Rather than having the second view with its own window, i had it with a UITabBarController, and a UIView/UIWindow(this is for the sake of having a default view for the nib file). And when i needed to show the tabbarview i have used this
[[[UIApplication sharedApplication] keyWindow] setRootViewController:TabBar]
I am not sure of a better way, but that have worked for me. In short, i have found that having another UIWindow inside the app causes issues with becomeFirstResponder.

UIView is shown displaced to the top

I have a simple app that has two view controllers. Both of them have a UINavigationBar at the top, as a header. The second UIViewController is displayed as a modal view, when the user clicks on a button on the first one.
When my app first launches, the initial view doesn't completely cover the main UIView and seems "pushed" to the top (see image below).
After I click on the "instructions" button, which displays another view with presentModalViewController:animated:, and dismiss the modal ViewController, everything is displayed correctly.
Anybody knows what I might be doing wrong?
I have nothing in viewWillAppear, and this is my viewDidLoad
- (void)viewDidLoad {
[super viewDidLoad];
if (!self.model) {
self.model = [[FRRSushiRiceModel alloc] init];
[[self.header.items objectAtIndex:0] setTitle: #"Perfect Sushi Rice: Ingredients"];
}
}
and my application:didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Create and add the main controller (ingredients)
self.ingredientsController = [[FRRIngredientsViewController alloc] init];
[window addSubview:self.ingredientsController.view];
[window makeKeyAndVisible];
return YES;
}
This small project reproduces this behavior:
Test Case
Did you untick the "Wants Full Screen" setting in IB, either for the UINavigationController or UIViewController?
I found the error, guys.
Basically I was trusting the system to correctly set the frame of my views to match the usable portion of the screen. This works when you add it to some controller of controllers (such as UINavigationController), or add it via IB.
If you add your controllers programmatically, you need to set the view's frame explicitly. A good default is:
[[UIScreen mainScreen] applicationFrame]
represents the part of the screen available to applications: the whole screen minus the status bar.

iPad SplitView Application not taking up entire window

I am working on a split-view based application for the iPad. I created a menu overlay system that has a button that leads into the split-view application. See comment for image
When you click the enter button, however, it results in this:
http://commandoswat.webs.com/Screen%20shot%202010-09-16%20at%201.37.11%20PM.png
Here is my code for the application delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch.
mainMenuController = [[MainMenuController alloc]init];
mainMenuController.sWindow = window;
mainMenuController.sController = splitViewController;
// Add the split view controller's view to the window and display.
[window addSubview:mainMenuController.view];
[window makeKeyAndVisible];
return YES;
}
Here is my code for the MainMenuController Enter Button:
-(IBAction) enterButton{
[self.view removeFromSuperview];
[sWindow addSubview:sController.view];
}
How do I make the split view take up the entire screen?
Any suggestions?
Thanks
Looks to me that your detail view isn't sized properly, and/or doesn't have its autoresizingMask property set appropriately (to have flexible width).

How to switch page on iPhone?

HI, everyone,
I want to ask a question about the iPhone application. I am writing a program. The program will ask the user the enter some information and press enter, after that the program will process and get some information, then the program will display the tab page with 3 tabs.
However, I don't know how to switch the page after the user enter the information, I have write the following code.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview: tabBarController.view]; // add the tab page to the view controller
MyViewController *aViewController = [[MyViewController alloc] initWithNibName:nil bundle:[NSBundle mainBundle]];
[self setMyViewController:aViewController];
[aViewController release];
UIView *controllersView = [myViewController view];
[window addSubview:controllersView]; // add the first page to the windows in order to let the user enter info.
[controllersView release];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
If I add the tabBarController first, the controllersView will not appear, if I change the seuqence, it don't know how to make the controllersView disappear to let the tabBarController appears.
And the process is done in the MyViewController.m. Can I
1) remove the controllersView in the MyViewController.m after I complete all the process and
2) display the tabBarController.view ?
Thank you very much.
You need to use a UINavigationController as the root view-controller for your window. You can then push the first UIViewController (MyViewController) on as the top view.
(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
When its time for the tab view to appear push it onto the Navigation Controllers stack. To get back to your top view pop the ViewController off the stack
[self.navigationController popViewControllerAnimated:YES];