Post

Replies

Boosts

Views

Activity

Reply to Swift + OS X + Xcode : Change NavigationLink destination and text programtically
import SwiftUI struct ContentView: View { var body: some View { NavigationView { NavigationLink(destination: NextContentView()){ Text("Next View") } } } } Declare a state var and have a test: import SwiftUI struct ContentView: View {     @State var firstPass: Bool = true   var body: some View { NavigationView {             if firstPass  { NavigationLink(destination: NextContentView()){ Text("Next View") } } else { NavigationLink(destination: CurrentView()){ Text("Other View") } } } } }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to How to find physical size of UI element?
You have to do some computation. Here is a table which gives all devices size information. h t t p s : / / w w w.ios-resolution.com Let's consider an example: From screen physical Diagonal (phD), you can compute physical width (phW) and height (phH): we have equation : phW*phW + phH * phH = phD * phD. // Pythagore physical dimensions are proportional to logical dimensions phW = logW * x phH = logH * x Hence we get : x = phD / sqrt(logW*logW + logH * logH) phW = phD / sqrt() physWidth = x * logicalWidth Now that you have physical height and width of screen, as well as logical dimensions, it is easy to compute physical size of UI element: if it is h and w (in points) itemPhyWidth = w * physWidth / logicalWidth, or with previous formulae itemPhyWidth = w * x itemPhyHeight h * x Hope that helps.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Usable screen space in a Mac
Try the following let usableHight = NSMenu.menuBarVisible() ? totalHight - 23 : totalHight Here is a simple test that works: let totalHeight = 400 var usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) NSMenu.setMenuBarVisible(false) usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight)
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Usable screen space in a Mac
Try the following let usableHight = NSMenu.menuBarVisible() ? totalHight - 23 : totalHight Here is a simple test that works: let totalHeight = 400 var usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) NSMenu.setMenuBarVisible(false) usableHeight = NSMenu.menuBarVisible() ? totalHeight - 23 : totalHeight print(usableHeight) yields: 377 hides menu bar 400
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Perform action once UIActivityViewController has completed item action
In fact, in case of AirDrop, the print in         activityVC.completionWithItemsHandler = { (activity, success, items, error) in             print("Completed")         } is executed, but only after closing the UIActivityView. And not after the airdrop has completed, as I expect. But if I email or message, it is executed as soon as sent. And UIActivityViewController closes automatically. So, I'm missing something here when using AirDrop…
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’21
Reply to iOS 15 (Beta) PDFKit 'insertPage:atIndex:' issue
Index of PDFDocument or CGPDFDocument are a bit confusing. I understand that atIndex in insert for PDFDocument is the new index value. first page is index 0 in a pdf last page is pageCount-1 to insert at the end, need to insert atIndex pageCount So it seems you do not insert anything at page 0 (jj starts at 1) of newPdfDocument ? I don't understand your comment: // Insert page at zero-based pageAtIndex kk [newPdfDocument insertPage:[currentPdfDocument pageAtIndex:kk]atIndex:jj]; In fact, you insert atIndex jj of newPdf, not kk. kk is the index of page to be inserted from currentPdfDocument Did you swap jj and kk in the above line ?
Aug ’21
Reply to What is the empty field in the new Date Picker?
What do we see on screen ? A cell (a row of the table) ? Is there a single row in your table ? Looks like we see the cell background, but it is hard to say with such limited view. You could try different solutions : reduce the width of the tableView (date Picker has a fixed width) make tableView background transparent (and may be the cell background as well).
Aug ’21