when my UIViewController appears with a UICollectionView inside, the content scrolls up a little bit, when appearing.
I implemented scrollViewDidScroll: and I'm logging the contentOffset.y:
-20.000000
-20.000000
0.000000
0.000000
This only happens on iOS 11 (simulator and device), not on iOS 10 or iOS 9. Anyone else experiencing this?
EDIT VERY WEIRD thing: this only happens when viewDidLoad is NOT called, so e.g. when the UIViewController already exists and it is popped onto again, but not when first showing that UIViewController...
In iOS 11, contentInset.top can be added in UIScrollView and subclasses (UICollectionView, UITableView) while status bar, navigationBar or other content appear in your view hierarchy.
This inset come from new adjustedContentInset property. (doc : adjustedContentInset)
To remove this extra inset, set content inset adjustment on your scrollView to never :
[self.myScrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
More info in the WWDC17 video : Updating Your App for iOS 11 at 19'
Related
Here is my code. This may sound like redundant question but my scenario is different as I am not adding QLPreviewController as a subview but present as a controller.
After downloading from dropbox, I present it like-
self.pdfViewController = [[QLPreviewController alloc] init];
self.pdfViewController.delegate = self;
self.pdfViewController.dataSource = self;
[self presentViewController:self.pdfViewController animated:YES completion:nil];
and I also have QLPreviewControllerDataSource, QLPreviewControllerDelegate listed as the protocol. Besides, it is working if being run in earlier than iOS 10.0.
Please help me.
It looks like iOS 10 has changed the way that QLPreviewController is presented. On iOS 9 when I preview an image by presenting the QLPreviewController modally I see a nice zoom effect and the initial state of the preview is with a black background and the navigation and toolbar hidden. I can tap the image to make the bars visible (which changes the background to white). Tapping again toggles the state.
On iOS 10 the same code results in the white background view appearing and the zoom animation being incorrect (it seems to appear from off the bottom of the screen).
I found that implementing this practically undocumented new data source method for iOS 10 fixed the issue:
- (UIView* _Nullable)previewController:(QLPreviewController *)controller
transitionViewForPreviewItem:(id <QLPreviewItem>)item
{
return [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:MIDPhotoImageRowIndex_Image inSection:MIDPhotoSectionIndex_Image]];
}
The view I return is the same view that previewController:frameForPreviewItem:inSourceView: is using as the reference for the original content's frame (i.e. the image view in my table cell).
The documentation for this delegate method at the time of writing just says "No overview available".
Implementing that method did mean that the previewController:frameForPreviewItem:inSourceView: is now called on iOS 10. I just wish there was a way to default to the original black background without navigation bars.
I'd like to present an UIImagePickerController with the following code:
self.pickerController = [[UIImagePickerController alloc] init];
self.pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.pickerController.delegate = self;
[self presentViewController:self.pickerController animated:YES completion:nil];
It's working fine for iOS 7 and below, but in iOS 8 I got the following glitch:
While transitioning to the image picker controller (vertical cover animation), the background colour of the picker controller is invisible, revealing the presenting view controller beneath. After transition is finished, the picker's table view will be displayed abruptly without animation.
Sometimes, the picker's table view is not displayed at all, and instead I got a blank black screen. The navigation bar is still there, but no bar button items whatsoever, so user has to force quit the application.
Anyone know what's going on here?
So I managed to find the cause and fix for these problems and want to document it here:
The first problem occurred when I tried to compile to iOS 8 device from XCode 5.1. I switched to XCode 6 beta 2 and now it's working just fine.
The second problem occurred when I tried to reuse an UIImagePickerController that has been displayed before. Create a new instance instead before displaying, and it would be fixed.
Cheers.
The app has a UIView with a table view and a UISearchbar on it. The searchbar delegate methods are in the view controller for the UIView. Everything appears to be hooked up correctly.
This searchbar works correctly in iOS 5, but not in iOS6. When touched, the searchbar brings up the keyboard, but typing on the keyboard has no affect; the textDidChange delegate method is never called.
This occurs only when running on an iPad. The difference between the view on an iPad versus the iPhone is that the UIView with the UITableView and UISearchbar runs in a popover on the iPad. On an iPhone, it runs as a separate view. In both cases, once the view is opened, a UINavigationController manages the view. All the navigation up and down the nav controller works fine in both devices; the only difference is that the UISearchBar does not work running in the popover.
Obviously, something has changed between iOS 5 and iOS 6, but I haven't been able to figure out what, or how to make the searchbar work in an iOS 6 popover.
Any help will be greatly appreciated!
rokjarc is right. I have same problem. In my app'SearchBar Display Controller, SearchBar is not respond to keypad typing in ios6. But it is fine in ios5 simulater, ios6 simulater, iPhone 3GS, iPhone 4.
In MainWindow.xib,
1. Click "Window" icon in "objects" Box.
2. Show Attribute inspector
3. Expend window attribute.
4. Check "Visible at Launch" and "Full Screen at Launch"
5. Clean build and run.
6. Good. OK?
I just got the answer on my original problem. I discovered that the same thing was occurring in UITextFields and UITextViews. I sent the whole thing off to Apple Tech Support.
Turns out that you have to include this line of code:
[self.window makeKeyAndVisible];
in the application's delegate's didFinishLaunchingWithOptions: method. When I added this line, the problems went away.
Hope this helps.
I load two buttons in one view from the NIB.
I set this view as self.navigationItem.rightBarButtonItem in current viewController
I set actions for these buttons
Result:
Buttons work under ios6 - both simulator and device and not working on ios5 device.
Any idea to fix it?
I fixed it by set "Autosizing" in "Size inspector".
(in my case, the problem came from resize iPhone5 to iPhone4)
The problem is now solved. This was caused by setting UIViews objects in IB and then setting its class to UIButton. It should have no effect on buttons behaviour, but it had. The more wired was that it did work on iOS 6 and did not in iOS 5.
I am writing an augmented reality app. I can present my UI as an overlay over the UIImagePickerController by adding subviews to its cameraOverlayView. This has worked well all along, but in iOS 5, I can't see any of the subviews of cameraOverlayView.
What gives?