My widget is supposed to connect to a server and fetch data every five minutes. Instead of being called for a new timeline after five minutes, timeline(with context: Context, completion: @escaping (Timeline<Self.Entry>) -> ()) method is called several times in a second. To figure out what I am doing wrong, I've simplified the method and added just a simple random number generator instead of calling the API.
func timeline(with context: Context, completion: @escaping (Timeline<Self.Entry>) -> ()) {
let currentDate = Date()
let futureDate = Calendar.current.date(byAdding: .minute, value: 5, to: currentDate)!
let timeline = Timeline(entries: [
Entry(date: currentDate, city: "\(Int.random(in: 0...10))"),
], policy: .after(futureDate))
completion(timeline)
}
The method is called several times in a second. I have no idea if I am doing something wrong or this is a bug in iOS 14?
Post
Replies
Boosts
Views
Activity
When I run the code snippet below, WidgetKit is supposed to request a new timeline at the end of each minute according to the Apple's documentation.
let currentDate = Date()
let futureDate = Calendar.current.date(byAdding: .minute, value: 1, to: currentDate)!
let timeline = Timeline(entries: [
Entry(date: currentDate, number: Int.random(in: 0...10))], policy: .after(futureDate))
completion(timeline)
But it just works once and nothing happens afterward. I am trying it on iOS 14 Beta 2.
I am trying to embed the CNContactPickerViewController in a SwiftUI project. I managed to show the controller by using the UIViewControllerRepresentable but I am showing the controller in the presentation mode and animations do not work well.
Button(action: {
	 self.isPresented = true
}) {
	 Text("Present")
}.sheet(isPresented: $isPresented) {
	 TestView()
}
Instead of embedding the CNContactPickerViewController, which is a UIKit component indeed, I tried to present the picker within the root view controller as shown below.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
		var window: UIWindow?
		static func present() {
				
				let root = UIApplication.shared.windows.first?.rootViewController
				let viewController = CNContactPickerViewController()
				root?.present(viewController, animated: true, completion: nil)
		}
		func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
				let contentView = ContentView()
				// Use a UIHostingController as window root view controller.
				if let windowScene = scene as? UIWindowScene {
						let window = UIWindow(windowScene: windowScene)
						window.rootViewController = UIHostingController(rootView: contentView)
						self.window = window
						window.makeKeyAndVisible()
				}
		}
...
I show the CNContactPickerViewController as a piece of the root view controller by calling the SceneDelegate's present method within the SwiftUI component.
Button(action: {
								SceneDelegate.present()
}) {
								Text("Present")
}
I know it isn't a good practice but works perfect and embedding it into the SwiftUI with the UIViewControllerRepresentable does not give me good results because it makes a flash effect, animation hangs while it is showing up.
I wonder the method that I've explained above is okay for Apple? Does it violate terms? Is it allowed to directly manipulate the root view controller? I have never encountered with this kind of method so I have no idea if I am doing something wrong.
I'm trying to implement the drag and drop feature to my LazyHGridview. When I try to drop the view on another view, a "plus" icon within a green circle is displayed at the top right corner of the view.
https ://i.ibb.co/J5cdhN7/Screen-Shot-2020-09-05-at-22-35-34.png
var d: GridData
@Binding var list: [GridData]
@State private var dragOver = false
var body: some View {
VStack {
Text(String(d.id))
.font(.headline)
.foregroundColor(.white)
}
.frame(width: 160, height: 240)
.background(colorPalette[d.id])
.onDrag {
let item = NSItemProvider(object: String(d.id) as NSString)
item.suggestedName = String(d.id)
return item
}
.onDrop(of: [UTType.text], isTargeted: $dragOver) { providers in
return true
}
.border(Color(UIColor.label), width: dragOver ? 8 : 0)
}
}
As shown in the image below, the names of some companies are displayed in the App Store result results with a large banner image. How can I show my company's name and image in results. There is no any section to upload an image or set this kind of information in the iTunes Connect.
https ://ibb.co/qNxWCnc
I'm about to start a new company and planning to create a corporate developer account. I know AppStore automatically displays the company's legal name as the seller name like ABC LLC, XYZ Corportation, etc. What I wonder is if it is possible to display only the company name by omitting the entity type like "ABC" or "XYZ".
Here an example:
https://ibb.co/ZHGb1dp
I don't if it is something that I should do during account creation or requesting a DUNS number.