swift

How to refresh multiple timers in widget iOS14?

自古美人都是妖i 提交于 2021-02-19 04:19:31
问题 I'm currently developing an application using SwiftUI and trying to make a widget iOS 14 users can check a list of timers. This Widget has multiple Text(Data(),style: .timer) to show some date data as timer. and when the rest of the value for the timer is over, I want to show it like this 00:00 . So I implemented some way in getTimeline function referring to this article SwiftUI iOS 14 Widget CountDown But I don't know how can I do it the same way for multiple timers... In the case of my code

How to modify a cell of UITableView from another ViewController

烈酒焚心 提交于 2021-02-19 04:19:23
问题 In VC#1, I have a UITableView. When I tap on a cell, I am brought to VC#2 where information about that cell is displayed. I want to be able to press a button in VC#2 which changes the title of the cell it corresponds with in VC#1, but I am confused on how to do this? Should I create a variable in VC#2 to save the indexPath for the cell that was tapped, and then call a function in VC#1 from VC#2 that uses that indexPath to update the cell? If I did this, wouldn't VC#1 need to be static so I

How to modify a cell of UITableView from another ViewController

和自甴很熟 提交于 2021-02-19 04:19:15
问题 In VC#1, I have a UITableView. When I tap on a cell, I am brought to VC#2 where information about that cell is displayed. I want to be able to press a button in VC#2 which changes the title of the cell it corresponds with in VC#1, but I am confused on how to do this? Should I create a variable in VC#2 to save the indexPath for the cell that was tapped, and then call a function in VC#1 from VC#2 that uses that indexPath to update the cell? If I did this, wouldn't VC#1 need to be static so I

How to refresh multiple timers in widget iOS14?

我是研究僧i 提交于 2021-02-19 04:18:40
问题 I'm currently developing an application using SwiftUI and trying to make a widget iOS 14 users can check a list of timers. This Widget has multiple Text(Data(),style: .timer) to show some date data as timer. and when the rest of the value for the timer is over, I want to show it like this 00:00 . So I implemented some way in getTimeline function referring to this article SwiftUI iOS 14 Widget CountDown But I don't know how can I do it the same way for multiple timers... In the case of my code

didSelectRowAtIndexPath indexpath after filter UISearchController - Swift

只谈情不闲聊 提交于 2021-02-19 04:18:02
问题 I’m implementing a search bar with an UISearchController within a sectioned table. So far so good. The main issue is that when the the filtered results come along, it’s a whole new table with no sections and fewer rows. When selecting the row, I perform a segue to that position in the array, but the detailed view is expecting that exact row or index from the main array, which I can’t get from the filtered array of objects, which may be [0] [1] [2] in 300 elements. I guess I can compare the

didSelectRowAtIndexPath indexpath after filter UISearchController - Swift

会有一股神秘感。 提交于 2021-02-19 04:17:33
问题 I’m implementing a search bar with an UISearchController within a sectioned table. So far so good. The main issue is that when the the filtered results come along, it’s a whole new table with no sections and fewer rows. When selecting the row, I perform a segue to that position in the array, but the detailed view is expecting that exact row or index from the main array, which I can’t get from the filtered array of objects, which may be [0] [1] [2] in 300 elements. I guess I can compare the

SwiftUI View does not updated when ObservedObject changed

眉间皱痕 提交于 2021-02-19 04:01:51
问题 I have a content view where i'm showing a list of items using ForEach @ObservedObject var homeVM : HomeViewModel var body: some View { ScrollView (.horizontal, showsIndicators: false) { HStack(spacing: 10) { Spacer().frame(width:8) ForEach(homeVM.favoriteStores , id: \._id){ item in StoreRowOneView(storeVM: item) } Spacer().frame(width:8) } }.frame(height: 100) } And my ObservableObject contains @Published var favoriteStores = [StoreViewModel]() And StoreViewModel is defined as below class

How to download files in wkwebview

萝らか妹 提交于 2021-02-19 03:49:31
问题 Anybody please tell me how to download files in iOS wkwebview. I have created an iOS webview app. In the page I have loaded It has several download options but when I click download nothing happened. Note: I dont want to create extra buttons to download 回答1: You can also use JavaScript to download your file, as Sayooj's link implys. Of cource, you will handle the file downloaded code yourself. With func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction,

How to add programmatic constraints to a UITableView?

我怕爱的太早我们不能终老 提交于 2021-02-19 03:38:24
问题 I have a class set up as follows: class SettingsController: UITableViewController { I would like to be able to add constraints to the UITableView so that there is equal spacing either side of the table (it is currently a full width table, so a little ugly on iPad). I have read that I can't add constraints to a UITableViewController , and instead I must add a UIViewController to my class, add a UITableView to that, and then I should be able to add the constraints to the TableView. I've amended

Dynamically call a function in Swift

℡╲_俬逩灬. 提交于 2021-02-19 03:37:05
问题 I’m trying to implement a router pattern in Swift and can’t figure out how to dynamically call a method. For example, there’s an array of arguments: let arguments: [Any] = [100, 0.5, "Test"] And a handler which needs to be called: public class MyClass { public func handler(value1: Int, value2: Double, text: String) { print("int=\(value1), double=\(value2), string=\(text)") } } let myClass = MyClass() The router has an untyped function reference which it will use as a callback: let callback: