UIBarButtonItem not clickable on iOS 11 beta 7? - uibutton

There is another question on SO about this but this has nothing to do with it because I think this has to do with a beta version of iOS 11.
I have these 2 UIButtons that are grouped inside a UIView. This UIView is put inside a UIBarButtonItem and the whole thing is set as Left Bar Button Items, using Interface Builder.
Each button, when clicked, show a popover, triggered by storyboard.
I am testing this on an iPad 3, running iOS 9, using Xcode 8. This works wonderfully.
Now I have decided to test this on my iPad Pro 9.7" that is running iOS 11 beta 7. I am using Xcode 9 beta 6. When I run this on the iPad Pro, all buttons on the navigation bar are dead. They don't respond to clicks. Now I try the same Xcode 9 beta 6 and run the app on the iPad 3 with iOS 9 and again, all work wonderfully.
I am compiling for iOS 9.1.
Buttons not even highlight to acknowledge the tap, as they do on iOS 9.
Is there an issue with iOS 11 beta 7 and bar button items?
Any ideas?

I found that the same code builded with XCode 8 works well on ios10-11, but when I build with XCode 9 UIBarButtonItem with a custom view don't respond to clicks.
looks that the problem appears because from ios 11 navigation bar uses auto layout instead of dealing with frames. The buttons on screen look well but seem that technically they are offscreen.
So my fix is to add auto layout constraint to my custom view.
//my custom view init
let view = MyCustomView()
view.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
let rightButtonItem = UIBarButtonItem(customView: view)
//constraints
let widthConstraint = view.widthAnchor.constraint(equalToConstant: 44)
let heightConstraint = view.heightAnchor.constraint(equalToConstant: 44)
heightConstraint.isActive = true
widthConstraint.isActive = true
//add my view to nav bar
self.rightBarButtonItem = rightButtonItem
After that custom right bar button receives clicks successfully.

I have discovered the problem! Amazing bug!
This is the drill. I was adding two buttons to the left navigation item by doing this:
create a view
add two UIButtons inside that view.
add that view to the left navigation item.
This was compiled for iOS 9 and works on a device with iOS 10 and below but not iOS 11.
The "correct" way of doing this is this
Drag an UIButton to the left navigation item.
Drag another UIButton to the left navigation item.
You will see that iOS allows that to happen and will manage both buttons under "navigation items".
this will work on all iOS versions I have tested from 9 thru 11.

I got this working by adding this method to the UIBarButtonItem:
[self.barBTNItem setWidth:44];

let tap:
UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(manualAdd.dismissKeyboard))
tap.cancelsTouchesInView = false // this line is required for xcode 9
view.addGestureRecognizer(tap)

I had the same issue when upgrading to iOS 11.
The size of the UIView containing the buttons were 0x0.
I fixed the height x width of the UIView on Interface Builder and it works after that.

Related

My UITableViewCell containing a UIScrollView stopped scrolling vertically in iOS 9

I just noticed a behavior change that seems related to migrating to iOS 9.
I have a UITableView. In the first UITableViewCell I have a UIScrollView that I use to page through images. It should only scroll left<-->right. Finger dragging up and down should drag the UITableView up and down. Up until iOS 9 it did do that beautifully... Now when I compile for iOS9 devices or simulator I can still scroll the images left<-->right but the table no longer scrolls up and down. Those touches just get sucked into the abyss.
Let me add that when I compile from Xcode 7 to my device running iOS 8.4 it still behaves as intended. Scrolls up and down when dragging in the embedded UIScrollView.
Furthermore, when I download my last released version (compiled on previously released Xcode for iOS 8.1 target I get the expected behavior on the iOS 9 phone.
Additional wrinkle of weirdness: if (back in xcode7 compiling live to iOS9 device again) I start scrolling vertically from one of the other cells and the table is still gliding to a stop THEN I CAN drag up and down from the UIScrollView. What the heck?
Anything obvious jump out here?
Thanks,
Bill
Something in iOS 9 changes with respect to self's frame, apparently. I had to change this:
self.scrollView.contentSize = CGSizeMake(self.frame.size.width*self.pageImages.count, self.frame.size.width);
to this:
self.scrollView.contentSize = CGSizeMake(self.frame.size.width*self.pageImages.count, self.window.frame.size.width);
See that reference to window in the final version? Second time that bit me. :)

iPhone 6+ does not have navigation bar back button item

I have developed an app in Xcode 5 before the new versions of iOS and iPhone 6/6+. It was working well in Xcode 5 with its simulators (iPhone retina 4 inches, etc.) but now that I have updated to Xcode 6 and I run my app in new simulators, it works great in the iPhone 4s, 5, 5s, and 6 simulators but not in the iPhone 6+ simulator.
I have a table view in my first view controller. If you tap on a cell the push segue brings you to an another view controller. There are two problems:
In every view controller, the top of the object (e.g. table view or a UIImage) is not shown and the scene is deficient.
when we go to the second view controller there is no back button item on the top in order to return to the home view controller.
How can I fix this? What is the problem?
I believe there is a bug in the iPhone 6+ simulator - I have also observed a similar behavior, but only on the simulator. Running the app on a real iPhone 6+ works as expected - the navigation bar is there as are all the buttons.
Its because iPhone 6+ simulator screen is too big to fit in some mac screen.
In a view controller the top object is not cut off, just use mouse scroller to scroll up to see the top object.
In second view controller again use mouse scroller to see back button.

Xcode 6, scroll view renders different in iOS7

I am making an app in Swift, with Xcode 6 beta 7, with base SDK iOS8. I want to build a form inside a scrollview with autolayout, and I am following this How-to.
It renders as expected in iOS 8 (simulator, both iPhone 4 and 5), but in iOS7.1 (Simulator or device) the scroll view seems to shift left, leaving no margin on the left and a bigger margin on the right, and the scroll indicator doesn't appear.
iOS8:
iOS7:
Is there anything I can do to fix this? Or should I wait Apple to fix this backward compatibility issue?

Making a nav controller work the same in iOS 6 and iOS 7

How can a navigation bar be supported in both iOS 6 and iOS 7 with a UIContainerView via a storyboard?
I am updating an iOS 6 app to iOS 7, but want to continue to support iOS 6. I have a main top level view that is embedded within a UINavigationController. The view within the navigation controller has a container view in it. I am using a storyboard to lay out the view.
On iOS 7 the navigation controller uses the entire screen, and I've set it up to put the container view content below the navigation bar. In iOS 6 the content of the view does not go under the navigation bar, so I have a blank gap below the nav bar.
Normally I would just reset the origin of the offending view on iOS6 (in ViewDidLoad or somesuch) and go on my way. However since my content is in a UIContainerView, I can't seem to change the frame after it loads. (I have tried this in prepareForSegue: when loading the UIContainerView. I'm open to having done this wrong? heh)
The closest I have found is using the following code under iOS 7 to make the nav bar opaque and keep the content out from under it, then using the entire space for my UIContainerView.
// tell the view to not extend below this nav bar
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
This solution works but has the side effect of showing the status bar as black (since it's more or less "blank" under the status bar). Alternatively, if I put the top edge of the container view below the status bar, on iOS 6 I have a big gap below the navigation bar.
I can eliminate the use of a navigation controller, but that seems a bit heavy handed in this situation and I'd like to use that as a last resort.
I've found the solution to this.
You need to set the barTintColor in iOS 7, which also seems to color the main status bar, as well as setting the nav bar to not be transparent like this:
mainController.navigationBar.barTintColor = [SRPRTabletHelpers customUserColor];
mainController.navigationBar.translucent = NO;
The non-transparency was the key, while setting the color sets not only the regular nav bar, but the color beneath the status bar as well.
I also needed to change my containerView top edge to be the full height of my view contained within the navigation controller, now that it is not transparent, and it works the same on both iOS6 and iOS 7.
While you mention to have already solved this, your method seems to require a lot of manual code and if checks. The iOS 7 UI Transition guide, in the Supporting iOS 6 chapter mentions another way: first design your interface for iOS7 as you have done, with your view extending below the navigation bar.
Then, in the interface builder open the size inspector for UI elements and modify the iOS 6/7 deltas. These values are applied when the storyboard is not run on iOS 7. For example, in your case you can select all your visual elements, then set the Y delta to -44, which is the standard navigation height. That will make the UI go up on iOS6, compensating the fact that the view doesn't go under the navigation bar.

ios7 - iPhone 5 giving white space at the top

Client has come back to me on projects saying they see white space on the top (they can't see the default things like time, wifi signal, etc) at the top.
This is happening when they installed iOS7 on their iPad.
Any idea why this is happening?
Note:
I have navigation bar as image. I hide the navigation bar and put navigation bar as an image.
Downvoters
I know this is not a perfect question for SO, but I thought to ask to take inputs. Tomorrow I am going to study on it.
try to insert following code into your viewDidLoad:
if( [self respondsToSelector:#selector(edgesForExtendedLayout)] ) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
Otherwise you could try it, by removing the UIStatusBar. Select your Project, go to the section General and select Hide during application launch inside the subsection Deployment Info. Next you have to add the attribute inside the Info section called View controller-based status bar appearance and set it to NO.
It's due to the status bar.
In your XIB or Storyboard chose to view your xib as iOS 6 :
On your view, add a Content View (you will add your outlets elements inside this content view) and add a Y delta of 20 (for the status bar) :
Now, if you compile your app on iOS 7 or iOS 6, your view will go up or down and you won't have the space anymore.