How to reorder a pdf document?
move page p after page n, or at a given m position.
add new page at certain position
rotate a page 90° or 180°.
I've seen libraries, but I would prefer to redevelop those simple functions directly in an iOS app (Swift).
I don't need to edit the document content, just rearrange.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
UISegmented controls seem not to work correctly in iPhone 13 Mini simulator. When tapping on a segment, control does not react before 30 to 40 s ; then it shows uncomplete redraw:
I also noted similar lag in updating display when some label text changes.
Configuration:
MacOS 11.6.1
Xcode 13RC
iOS 15.0 simulator.
It works ok on a few other simulators I tested.
I created an extremely simple project to reproduce:
new project in Xcode 13RC
added a segmentedControl at bottom of view, constrained to leading and trailing 0 to the safe area
set selected color to red.
run on iPhone 13 mini simulator
I will test later with Xcode 13.2ß
The following code opens the app settings, including preferred language.
func openSettings() {
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: nil)
}
}
That works well in iOS (14.6 or 15.2), on iPadOS 14.4 ( both device and simulator)
But on iPadOS 15.2 simulator, the preferred language setting for the app does not show.
I noticed this in 2 different apps.
I get this weird behaviour of Xcode.
Version 13.2.1 or 13.2 RC (may be other).
In the storyboard I had a UITableViewController. As it does not give any flexibility to add other views in the VC, I created a new UIViewController, recreated the tableView inside as well as some other objects, added the new views I needed, redid all connections.
Then I removed the UITableViewController.
Everything works perfectly fine.
But sometimes (cannot find any pattern for the cases), when opening the project, the old UITableViewController appears in Storyboard. The new UIViewController doesn't even seem to be here. When I select different VC in SB, no information in Identity inspector or other inspector.
But it compiles and runs OK, using the new UIViewController.
I cleaned build folder, closed Xcode, reboot the Mac, to no avail.
Only way to get it solved was to close the SB and reopen it…
Is there a cache somewhere in SB that is not cleared ?
Is there a difference in the distribution of results between those 2 forms ?
let x = (1...9).randomElement()!
let y = Int.random(in: 1...9)
In doc, I never see the first form used
I installed Xcode 14.2 (in parallel with other versions of Xcode with different names) on MBP MacOS 12.6.2.
Il works OK except when trying to use WatchOS simulator.
When I select a WatchOS target and then look for simulator, none is installed. I get an item in menu proposing to GET 9.1.
I downloaded.
But at the end of download, installation failed with the message that installation of watchOS 9.1 simulator runtime failed in CoreSimulator.
I tried the solution proposed here, to no avail.
https://stackoverflow.com/questions/74096242/unable-to-select-device-for-watchos-app-in-xcode
Note: installation on an iMac running 12.6.2 and Xcode 14.2 shows a long list of simulators:
How do we switch on/off the display of lines at top of a window.
It should be in Preferences, but I cannot find it.
After more than 2 years of intense use of SwiftUI I appreciate many of its features, particularly the speed at which I can get some code running.
But, there are some major buts …
Screen Position,
I keep struggling with try, test, error and retry to position views relative to each others, withy many iterations to tune the x and y parameters. And preview does not help when view is too complex: I find it more reliable to test in simulator.
At the end, my code is messed with .position, .offset, … that I manually adjusted but may break if I change something elsewhere in the body.
The fact that position is relative to center of view (different from UIKit) makes it even more mind boggling.
For sure, UIKit constraints were not so easy, but you got a very stable code. That's not the case with SwiftUI
z position
In some cases, I want the View to appear on front of all others.
It may be a very simple Rectangle() with overlay, e.g., to mimic an alert.
And I struggle with the Rectangle drawn behind another view, even trying to adjust the zIndex to no avail…
Should I create an explicit View instead of creating the Rectangle directly in the body ?
So am I misusing SwiftUI, or are they points that SwiftUI should improve in the future ?
I know it is not a developer question, but getting the answer may help understand what we can get or not get on Apple Watch after Watch10.
Since WatchOS10.2 when swiping face, time is always displayed first as 10:09:31 before setting the correct time one second later. Just in the same way as a long press. But the interest of swipe is to have immediately a different face displaying the correct time.
Why is it so ? Is it due to (probably) now using SwiftUI ? Or is it a quick fix, reusing most of code for Lon,g press case ?
It did not behave so with WatchOS 9 or before. Is there a setting to change ? It is really inconvenient (and ugly).
I filed a bug report: FB13466486
I have a view in storyboard, with a tableView and a coloured UIView.
The UIView is declared after tableView, so it appears on top of tableView.
However, it appears semi transparent over the tableView.
In addition, I cannot set its alpha channel to values other than 1 or 0 (e.g., 0.9)
But if I create the view programmatically, the view if fully opaque as expected.
What am I missing ?
This is an often asked question, but I just have a partial answer so far.
There are some views (not all) that I need to present in Portrait only when running on iPhone.
If I come from a TabBar, I just add the following code in the TabBar controller
override open var supportedInterfaceOrientations : UIInterfaceOrientationMask {
if UIDevice.current.userInterfaceIdiom == .phone {
return [.portrait, .portraitUpsideDown]
}
}
But I need to do the same when I get to the destination VC by a segue fired from a plain UIViewController or a Cell in a TableView.
If I put the code in the destination controller, it has no effect.
If I put in the originating VC, it works when segue is triggered from code (case 2 below).
But I cannot make it work when segue is triggered in storyboard from the accessory action in the cell of the TableView.
Where should I declare the supportedInterfaceOrientations ?
Should I do it in the navigation root ? If so, how ?
I tried in an extension UINavigationController, to no avail.
or should I trigger the segue from accessory, not directly in storyboard but through an IBAction in code ?
If that may help, an overview of storyboard setup:
Also tried solution described here to no avail either: https://www.appsdeveloperblog.com/disable-rotation-of-uiviewcontroller-embedded-into-uinavigationcontroller/
I had this code working properly in Xcode 17.0.1, with macOS target as 12.4
struct SyntheseView: View {
@AppStorage("isDarkMode") var isDarkMode = false
// more declarations ………
var body: some View {
VStack {
ZStack {
// code …………………
}
.frame(width: 500, height: 300)
.background(isDarkMode ? Color(red: 0, green: 0, blue: 120/255) : Color(red: 1, green: 1, blue: 186/255))
} // VStack
In Xcode 15.3, I get the error The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
If I comment out the background modifier, no issue.
I converted all parameters in Color to Double without success
If I replace by a fixed color as
.background(.blue)
No error.
Even the simple
.background(Color(red: 0.0, green: 0.0, blue: 0.5))
causes the error.
But:
.background(isDarkMode ? .blue : .red)
does work.
I tried to define the Colors as static color extensions to no avail.
Another bizarre point is that a similar pattern works OK for another View.
Did something change in Xcode 17.3 ?
I prepare an app to migrate from ObservableObject to Observable, from EnvironmentObject to Environment(MyClass.self) and so so forth.
That works OK, very simple.
But, that forces to run on macOS 14 or more recent.
So I would like to have it conditionally, such as:
if macOS 14 available
@Environment(ActiveConfiguration.self) var activeConfiguration: ActiveConfiguration
otherwise
@EnvironmentObject var activeConfiguration: ActiveConfiguration
The same for the class declaration:
if macOS 14 available
@Observable class ActiveConfiguration {
var config = Configuration()
}
otherwise
class ActiveConfiguration : ObservableObject {
@Published var config = Configuration()
}
Is there a way to achieve this (I understand it is not possible through extensions of Macros, as we can do for modifiers) ?
Could I define 2 classes for ActiveConfiguration, but then what about @Environment ?
I've recently seen answers to posts that are apparently automatically generated but signed as App Store Connect Engineer. In several cases the answer is misinterpreting the OP.
Here is an example: https://developer.apple.com/forums/thread/758391
The OP was really a developer question. Not related to a consumer feature.
Is it really an automatic answer (which would be a bad trend for the forums IMHO)?
I create a UIKit PullDown menu (in a positionMenu button), with the following code:
func setupPullDownMenu() {
let menu1 = UIAction(title: "Menu1") { [self] _ in
// some code
}
let menu2 = UIAction(title: "Menu2") { [self] _ in
// some code
}
let menu3 = UIAction(title: "Menu3") { [self] _ in
// some code
}
let menu = UIMenu(title: "Positions", children: [menu1, menu2, menu3])
positionMenu.menu = menu
positionMenu.showsMenuAsPrimaryAction = true
}
In Portrait, options are listed as Menu1, Menu2, Menu3
But in Landscape it is the reverse: Menu3, Menu2, Menu1
I use Xcode 16.1ß and iOS 17.0 simulator
Is it the expected behaviour ?