UIToolbar not responding to touch - ios

I'm having a similar problem as asked here: UIToolbar at the bottom not working in Retina 4 simulator.
My UIToolbar is not responding to touch on my iPhone 4. The toolbar is visible and at the bottom of the screen. Only when I move it up it will respond to touches.
so far no solution has worked for me.I'm using a storyboard and I have tried
enabling use full screen on all viewcontrollers and putting self.view.frame = [UIScreen mainScreen].bounds;in all my viewdidload methods.
I've also tried placing [window setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; in my appdelegate.

found the problem. I was initialising one of my VC's with the wrong frame size.

Related

UIViewController view not size correctly when running iOS7 simulator

I have a custom UIViewController which create a view containing an action bar at the top (view with 4 buttons), a tableview and then another view below the tableview. Layout is done all in code and is not using auto layout.
Everything works perfectly on various device with iOS 7.0 and 7.0.2, but in the simulator, the root view of the controller get anchored at the top right corner of the screen (0,0) instead of below the navigation bar.
I'm going to force the relay out in the viewDidAppear: method, but this seem like a hack...
Thanks for any insights
Edit: added an image. You can see the UIView highlighted. As ManicMonkOnMac mentioned, the UIView is under the toolbar (but this only happens in the simulator, on the device, the view lines up fine)
In the loadView method on the controller, i set the frame when creating the view:
- (void)loadView
{
// Our parent view controller will resize us appropriately. The size set
// here is a convenience for initial view layout.
self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
But this frame is later changed. Not by my code, though, but by UIkit code)
Edit2: addded loadView method body
EDIT: After going through session 201 of WWDC 2013, I think I have the solution.
in iOS 7 there is a property that you can set on your view controllers to specify whether you want the views to be overlapped by navigation bar.
viewController.edgesForExtendedLayout = UIRectEdgeNone;//UIRectEdgeAll specifies that nav bars should overlap the view.
Unlike iOS 6, navigation bars are placed over the views in iOS 7.
Use the frame size that excludes the navigation bar.
code:
CGRect frame = CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y+self.navigationController.navigationBar.frame.size.height,self.view.frame.size.width,self.view.frame.size.height);
CustomView *view = [[CustomView alloc] initWithFrame:frame];
[self.view addSubview: view];

AdView Banner (SubView) covers the bottom toolbar in my app. How do I make sure the toolbar is fixed below the banner?

The code I am using to fix the adbanner to the bottom of the screen on any resolution is:
[adView setFrame:CGRectMake([UIScreen mainScreen].bounds.size.width-adView.frame.size.width,
[UIScreen mainScreen].bounds.size.height-adView.frame.size.height - [UIApplication sharedApplication].statusBarFrame.size.height,
adView.frame.size.width,
adView.frame.size.height)];
I just need some help in ensuring that my toolbar doesnt get covered. How do I do this?

UITabBarController not responding

I'm using a UITabBarController with UINavigationControllers like this
I add this to the view using
tabctrl.view.frame = CGRectMake(0, 0, 320, 548);
[self.view addSubview:tabctrl.view];
The screen looks like
But I can't switch to other tab(ie, touching on tabctrl's tab has no response)
If I change the frame like
tabctrl.view.frame = CGRectMake(0, 0, 320, 488);
then the screen looks like,
Now, I can touch the tab and switch to required viewcontroller. How to solve this issue?
I need to get access to the tabctrl when its frame height is 568.
I'm using xcode 4.6.2 and ios simulator 4inch retina.
Use this code:
[appDelegate.window setRootViewController:tabctrl];
rather than:
tabctrl.view.frame = CGRectMake(0, 0, 320, 568);
[self.view addSubview:tabctrl.view];
Your tabbar controller might be behind something else on the bottom of the screen. You can test it with code:
[self.view bringSubviewToFront: tabctrl]
If this fixes your problem, try to find which view is in front of your tabbar controller
Set your rootViewController's wantsFullScreenLayout property to YES
tabbarController.wantsFullScreenLayout = YES
This should solve your tabbar switching issue on 4-inch screen

Subview is not oriented properly

I have created a subview which is used as a HUD in an iOS app. The app supports portrait and landscape display orientations.
The subview appears in portrait mode sometimes even if the mode is landscape. The subview is added by these lines:
self.infoHUDViewController = [[[InfoHUDViewController alloc] initWithNibName:#"InfoHUD" bundle:nil] autorelease];
[self.view addSubview:self.infoHUDViewController.view];
So it works very well if the subview is added in the viewDidLoad method. However, it does not work in landscape mode if the view is added in an IBAction method which responds to a button press. The subview appears as if in portrait mode (it appears 90° rotated, fills only the half screen width, and extends beyond the screen bounds).
What is really odd: In the init method of the subview's view controller the display orientation is correctly set to landscape. Am I missing something here?
I found a fix for this problem.
I added
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {
self.view.frame = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f);
} else {
self.view.frame = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);
}
to the viewDidLoad method. Now everything works as excepted in all situations.

IOS: How to add one image just above Navigation Bar

I want to add a image just above the navigation bar. Here is the final result picture I want:
click me
At the beginning, I think it is quite simple:
Using UIBuilder add one UIImage and one UIView
Add navigation bar controller to UIView as its root view
The Hierarchy I thought should like this: UIViewController->UIView->NavigationBarController.(Here the UIView is one subview of the view of UIViewController)
Below is one of the code I tried, subView is the IBOutlet of one UIView builed by UIBuilder
UINavigationController *test;
test=[[UINavigationController alloc]init];
[[subView window] setRootViewController:test];
[subView.window makeKeyAndVisible];
But after trying several times,I found it is not working.
Does anyone do the same work before? If so, please give me some suggestions.
self.navigationController.navigationBar.frame = CGRectMake(0, //height of imageView//, self.view.bounds.size.width, 44.0f);
CodaFi's suggestion is almost there.
Try this:
test.view.frame = CGRectMake(0, //height of imageView//, self.window.bounds.size.width, //(total height of content... e.g. 460.0f if you leave the status bar visible)-(height of imageView)//);
There is one thing to note though... The navigation controller likes to take up all the usable space on screen so sometimes it will automatically resize its view to a rect like this, {{0.0f,0.0f},{320.0f,460.0f}} after rotating the device. I have experienced this many times on the iPad. You might have to start listening for the rotation event, and reset the frame of the navigation controller's view on every rotation to one that doesn't block your image.

Resources