How to size an iOS UIDatePicker - ios

So I have a UIDatePicker in my app.
When I run my app on the simulator this is displayed, with only one complete row being displayed either side of the selected time.
When I deploy the app to my iPhone, this is displayed, with two complete rows being displayed either side of the selected time.
This error is returned when running on the real device:
[UIPickerView setFrame:]: invalid height value 196.0 pinned to 180.0
This error, and other similar questions lead me to believe I shouldn't be able to change the height of the UIDatePicker.
My question is, is it possible to produce a UIDatePicker like the one being displayed in the simulator on real devices and if so, how?
Thanks,
Liam

Related

Unexpected number of splitViewControllers when targeting an iPhone

I'm learning to use the split view in an app. I am asking the table to reload the data every time I add new things. My code and settings are seem fine. But not work on iPhone. After I ask someone and he told me to try on an iPad device, it works.
Finally, I find out where the problem is, but I don't know how to fix it. I added a line that prints the size of splitView.viewControllers. The iPad simulator returns 2, which is what I am expecting. But it returns 1 without any changes in the iPhone device. So, what's wrong with it, and how may I solve it? Thank you very much.
enter image description here
enter image description here

How to dismiss the UIActivityViewController during a UI test with Xcode 11 & iOS 13

Apple has re-designed the share sheet that appears, which has now broken my UI tests.
I have attempted to record a new UI test through Xcode, but as soon as I tap on the dismiss button, the test terminates so I have not been able to capture the event.
Ultimately, I just want to know how I can access the gray 'X' shown with the arrow below:
I have just tested this with Xcode 13 and have found that the original answer no longer works. However, I am keeping it for posterity, or those using previous versions of Xcode.
Xcode 13
I have tested this with Xcode 13.0 and verified it works for iPhone and iPad:
let activityListView = app.otherElements.element(matching: .other,
identifier: "ActivityListView")
XCTAssertTrue(activityListView.waitForExistence(timeout: 2.0))
activityListView.buttons["Close"].tap()
Previous versions
After some trial and error, I was able to locate where my specific elements were with the following:
app.otherElements.element(boundBy: 1).buttons.element(boundBy: 0).tap()
Using app.otherElements.element(boundBy: 1) would identify the share sheet for me. I had attempted to locate it through accessibility identifiers, but I could not find one that worked, including previously valid ones used in iOS 12 and below.
Please note that based on the layout of your screen, the index value
may differ from what I am seeing.
Next, .buttons.element(boundBy: 0).tap() was used to locate the Close button. I again attempted to use identifiers, but could not find anything that represented the button.
When I attempted to discern additional information through the console while testing, I would always wind up crashing the test. This result was surprising, as I was able to query these elements with Xcode 10.
Ultimately, I would like to find working identifier values so that I can have something that works reliably across products, without the trial and error to find the share sheet's index value.
For iPad
The following will dismiss the popover for an iPad:
app.otherElements["PopoverDismissRegion"].tap()

When will gestures to select specific values from DatePickers and ValuePickers become possible with the new UI Testing framework in iOS 9?

Right now, I am able to set accessibility labels and identifiers for different picker wheels in my application so that the recorder can pick up when I tap these picker wheels, and I am able to swipe up and down to modify the values, but I am unsure if there is a way for me to specify an exact value to select in these pickers. I am currently running XCode 7 Beta 5 and here is the following code I currently have:
//Expands the cell with the DatePicker
XCUIApplication().tables.staticTexts["Due Date"].tap()
//Modifies the Month, Day, and Year picker wheels.
XCUIApplication().tables.cells["dueDate"].pickerWheels["August"].swipeUp()
XCUIApplication().tables.cells["dueDate"].pickerWheels["19"].swipeUp()
XCUIApplication().tables.cells["dueDate"].pickerWheels["2015"].swipeUp()
As I mentioned, this code works fine, but I kind of have to guess at what the end result would be based upon the current start date (which is the current date, in our app) instead of being able to set the date to a known value.
Has anybody else been running into this same issue? If so, are there any known work arounds? It seems like the set of gestures that the API can mimic are still fairly limited.
Per this post starting in Beta 6 you should be able to do something like this...
app.datePickers.pickerWheels["2015"].adjustToPickerWheelValue("2005")

why storyboard ui elements not showing on UIViewController in xcode 6?

I am new to IOS development. I am developing an app for IOS 8 devices. I used storyboard for my design yesterday my storyboard showing all UI design but today morning it show blank UIViewController no UI element vision please see in screen shot and very strange thing is that when i run my app all ui element visible in my device. I google but dont find any solution please help me out. Thank you in advance.
It looks to me like you are using size class and you went into a particular size class and added these views. Now you are back in Any size class, so the views are not there (that is why they are greyed out in the document outline at the left). They are available only for that particular size class. If you switch back to it again, whatever it was, you will see them again. Basically, you have created conditional views - the condition being that they are present only when that particular size class situation is the case.
In other words, if you want your layout to apply in the general case, you want to start by creating and editing it under Any size classes. Only then do you switch to a particular size class and modify the layout for that particular size class.
when i run my app all ui element visible in my device
Yes, because on your device the particular size class situation matches the size class you were editing when you added those views. So there they are. That seems to me to prove my guess is right.
I have the same issue while copy a ViewController to another storyboard.
Fixed by following steps:
1: Select the viewController
2: Click on 5th Tab
3: Set the simulated size to Fixed.
Select install:
Since all components [like label,textfield,buttons] are in disable mode, one select Installed check mark its will be enable again adjust constrain accordingly.
The size must be the same, in all xcode storyboard
In my case, it was due to me setting alpha to 0.0 and forgetting it.

iOS5: UIScrollView dispaying and scrolling differently from iOS4

This is a curious one.
I have an IBOutlet UIScrollView playScrollView whose height is exactly 1/3 of it's contentSize's height. The app is in landscape. I call this code...
[playScrollView scrollRectToVisible:CGRectMake(0.0f, page * PLAY_VIEW_PAGE_HEIGHT,
480.0, PLAY_VIEW_PAGE_HEIGHT)
animated:animated];
... (the int page ranges from 0 to 2) to start on page 1 (displaying the middle third) then go up or down as needed when the user presses buttons.
This works fine for iOS4 both device and simulator, and has been live on the app store for months with no problems. Even iOS5 devices are fine with existing builds, it was only when the app was recompiled for iOS5 that it stopped working correctly on iOS5 devices.
Since updating to XCode 4.2, This doesn't work for iOS5. It goes one page too low, showing the bottom page when it should show the middle. I can get the code to work for iOS5 (device and simulator) by changing page to (page-1)...
[playScrollView scrollRectToVisible:CGRectMake(0.0f, (page-1) * PLAY_VIEW_PAGE_HEIGHT,
480.0, PLAY_VIEW_PAGE_HEIGHT)
animated:animated];
...but of course this breaks iOS4, which works fine with the old code, but gets stuck one page too high with this new code. iOS4 and iOS5 are exactly PLAY_VIEW_PAGE_HEIGHT out-of-step (288 pixels, a third of the height of playScrollView). The same thing happens if I use setContentOffset: instead.
One other curious thing, probably the key to this. If I don't do the scrollRectToVisible at all, then iOS4 sits at the top of playScrollView, wheras iOS5 shows the middle third, (ie PLAY_VIEW_PAGE_HEIGHT pixels down).
I could detect the iOS and use different code for each, but that's a horrible kludge. If it's an iOS5 bug and they fix it in a future release, that would break the live app.
Has anyone any ideas, or noticed anything similar? Thanks.

Resources