iOS8 Keyboard Extension clipsToBounds - swift

I'm trying to write a custom keyboard for iOS8 and so far, minus the odd hiccup, I've not had too many issues. However, when I create a view and add it as a subview of a UIButton I've added to the keyboard view the newly added view is clipped at the top of the keyboard view. From what I can tell, the hierarchy is as follows:
UIView (popup) -> UIButton (actual "key") -> UIInputView
With this hierarchy, the top-level UIView is being clipped inside the UIInputView. Each UIView has had clipsToBounds set to false, and I also set the UIView (self.view) to false within the UIInputViewController, but that doesn't seem to have helped.
It could be that this is a restriction of the extension system currently, but hopefully it's something silly I'm doing!

This is actually not possible. According to the docs it states "In addition, it is not possible to display key artwork above the top row, as the system keyboard does on iPhone when you tap a key in the top row.", which is a shame.
Thanks to #Spentak for pointing that out

Related

Touch detection problems with custom View inside UIView NOT UIScrollView

I was googling for a while and I found similar problems but when the custom View is inside a ScrollView, but that is not my case.
I have a custom view that consists of a UILabel behind a UITextField, so I can animate that label later.
The problem is that when I add a View in my ViewController and in the Identity Inspector I set the Class as my custom class, when I use the application the UITextField within my custom view does not receive the touches well and it takes time to gain focus and therefore to open the keyboard. The strange thing is that if I move that same arrangement of views to my main ViewController in Storyboard everything works fine. Why doesn't it do it when I place it using the described method?
I plans to reuse this custom view a lot, so putting logic and views in each ViewController is not an option.
Thanks in advance
Well, the problem was in the constraints of the container UIView. That means, the UIView in my main ViewController. The Height of the UIView was a little bit smaller than the space required for my custom view, so although my custom view seemed to draw correctly, it was not receiving the gestures correctly. The solution was simply increase the height to the correct value occupied by my custom View. Thanks a lot!

Adding ViewController's View as subview to UIPageViewController in iOS 8 gives weird UINavigationBar while show/hide

I have been working on a project where I needed to show list of images with zoom / swipe feature as presented view modal. I created custom ImageViewer using ContainerView in which I have added UIPageViewController. And on demand, I added ImageViews over the UIPageViewcontroller's view. When user taps to imageView, the top UINavigation gets shown and hidden on toggle basis.
Everything worked as expected in iOS 7.1 and less. However when I tested the functionality in iOS 8 devices and simulator, the ImageViews were not added to UIPageViewController in TopLeft ( beneath UINavigationBar ). It is added below the NavigationBar as shown in bug_iOS_8.png below.
Once I touch the buggy view, it repositions itself to correct position as in image expected.png below.
I have created and tested the issue in sample project and it seems it is bug in iOS 8 itself with UIPageViewController. I went through couple of questions regarding weird behavior of UIPageViewController too. Please check the sample app here and kindly let me know if anyone has any hints on what is going on.
Thank you for your time and help.
PS: BTW I am using following version of Xcode.
Update 1:
I have tried as per the pin suggestions. However, the problem aligning is with the main view of UIViewController rather than its subview. In below image, Yellow is main View of UIViewController and red one is added subview, I added pin to "red" on in reference to superview "yellow" one. Please check following screen shots.
On startup.
After touch on screen.
Kind Regards,
check in storyboard for particular viewController and make sure Extended Edges >> Under top bars is not selected.
I had a very similar issue and the way i fixed it was select the view being added to the UIPageViewController in the storyboard and selected the pin options. Below in the image you can see the Constrain to margins options, make sure you unselect that. Also when choosing what view to pin it to make sure you select the superview and not the Top Layout Guide.
Curious are you hiding your nav controller like this?
[self.navigationController setNavigationBarHidden:YES];
also if you have multiple Nav controllers, you might need to check you are referencing the correct one.
If you want it to be hidden when you present the ViewController you should move it to
-(void) ViewWillAppear{
}

UISearchBar: how can I stop it resizing when clicked?

I have a UISearchBar (with UISearchDisplayController) as title view of UINavigationBar. There are also two buttons on either side of the searchbar within the navbar.
When clicking on UISearchBar, it becomes wider and covers the button on the right of it.
How can I stop it from becoming wider?
Things tried but didn't work -->
The widened search bar then becomes the original size if the device is rotated.
So, tried calling [searchBar setNeedsLayout] in -searchBarTextDidBeginEditing
All different auto-resizing mask options in IB
Edit: Didn't mention, but this is on iPhone (as we can put searchbar inside toolbar in iPad..)
Actually, taking hint from this answer if the search bar is put in UIView of desired size then this is set as title view of NavBar, it doesn't go wider !
But... Since you can't make cancel button to show/not show as you wish, I realized it's not so useful.
(As seen in this question/answer etc)

MKMapView hides all controls on the view

I have added UIButton, UITextField and MKMapView in UIViewController. I bind all controls to properties. But when I run application there is no button and textField, only map. I have navigation controller and I was thinking that it hides controls but no. Is there any additional option that must be set when adding more controls with MKMapView in one View?
And I forgot to tell. In UITextField I have hardcoded value ("London") and in set location on map I get value from that UITextField and it works. So field is somewhere on the screen but it seams that map hides it somehow.
But, if I in view editor make map smaller it somehow fine. But why I must make it so small in editor to be fine in run mode?
maybe you should bring your UIButton, UITextField with
[self.view bringSubviewToFront:UIView]
to the front.

Make subview rotate too when device is rotated iPhone/iPad

Let me explain what I mean when I say that I want to rotate my subview too. I placed a lot of images to make my self clear. This may look like to much but it is not. Just wanted to be clear.
In the nib file that I am currently working on, I have a UIView and button.
The UIView that I created in interface builder is connected with the IBOutlet named ViewMain:
and the button executes the following method:
and what that method does is that it places the view from another nib file in the UIView controller that I created in interface builder. The nib file that I am actually placing is:
I just placed random controls to illustrate better my point.
so everything so far is great (the view from anotherViewController shows up on ViewMain when the user presses the button)
EVERYTHING LOOKS GREAT BUT NOTE WHAT HAPPENS WHEN I ROTATE MY DEVICE:
I would like my subview (anotherViewController.view) to ratate as well. I don't mind if it is bigger than ViewMain because I can have a transparent background. I just need to rotate it as well. How can I do that?
Define shouldAutorotateToInterfaceOrientation: in you UIViewController so that it always returns YES:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
Look here for more details.
You should also take care to correctly define the autoresizing behavior of your view and subviews, so that everything is fine when autorotating.
EDIT:
to set the autoresize property for a view in Interface Builder, select the view then go to the "View Size" pane in the Info window and set "Autosizing" as in the image below.