I have searchBarTextDidEndEditing func , but when I want to call searchBar in other func like that
`search.searchBar.showLoading()`
it throw error like that "Value of type 'UISearchBar' has no member 'showLoading'"
searchBarTextDidEndEditing func:
`
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
self.search.animationController(forDismissed: self)
self.search.automaticallyShowsSearchResultsController = false
}`
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I want to use segue when I click the forget password icon , Iit may open "ForgotPasswordEmailCheckController" view, my code is running but it throw error like "Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MyApp.LoginViewController 0x7fa962b13730> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key forgotPassword.'" I don't know why?
ForgotPasswordEmailCheckController:
class ForgotPasswordEmailCheckController: UIViewController, UITextFieldDelegate {
var storyboardId: String {
return (value(forKey: "ForgotPasswordEmailCheckController") as? String)!
}
LoginViewController:
@IBAction func forgotPassword(_ sender: Any) {
let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
guard let forgotPasswordEmailCheckCotroller = mainStoryboard.instantiateViewController(identifier: "ForgotPasswordEmailCheckController") as?
ForgotPasswordEmailCheckController else {
print("Not correct password")
return
}
navigationController?.pushViewController(forgotPasswordEmailCheckCotroller, animated: true)
}
I have project in SwiftUI 2.0 and I want to update it for Swift 3.0, is it possible to do that?
I have searchable properties in my project, everythings work, but it is looking bad when I search any items, it show "cancel" title inside of the search bar, how can I hide it?
.searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always))
I want to use onboarding screen in my project, and it is work but I want to use it just once time for app, I do not know how I will do it, is there any way?
struct ContentView: View {
@State private var onboardinDone = false
var data = OnboardingData.data
var body: some View {
Group {
if !onboardinDone {
OnboardingView(data: data, doneFunction: {
print("done onboarding")
})
} else {
MainScreen()
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
I have a simple app in SwiftUI, and I try to delete all list items with context menu , when I click context menu button, I want to remove all items, is it possible?
struct MyView: View {
@State private var selectedUsers: MyModel?
var body: some View {
ScrollView(.vertical, showsIndicators: false, content: {
VStack(content: {
ForEach(datas){ data in
MyRowView(data: data)
.contextMenu {
Button(action: {
self.delete(item: data)
}) {
Text("delete")
}
}
.onTapGesture {
selectedUsers = data
}
} .onDelete { (indexSet) in
selectedUsers.remove(atOffsets: indexSet)
}})
})}
private func delete(item data: MyModel) {
if let index = datas.firstIndex(where: { $0.id == data.id }) {
datas.remove(at: index)
}
}}
model:
struct MyModel: Identifiable, Hashable, Codable {
var id = UUID().uuidString
var name: String
}
var datas = [
MyModel(name: "david"),
MyModel(name: "marry"),
]
I have list items in SwiftUI, and when I delete list items I want to delete after alert menu, like
"do want to delete your list items, ""yes" or "no"
is it possible?
struct MyView: View {
@State private var selectedUsers: MyModel?
var body: some View {
ScrollView(.vertical, showsIndicators: false, content: {
VStack(content: {
ForEach(datas){ data in
MyRowView(data: data)
.contextMenu {
Button(action: {
self.delete(item: data)
}) {
Text("delete")
}
}
.onTapGesture {
selectedUsers = data
}
} .onDelete { (indexSet) in
self.datas.remove(atOffsets: indexSet)
}})
})}
private func delete(item data: MyModel) {
if let index = datas.firstIndex(where: { $0.id == data.id }) {
datas.remove(at: index)
}
}}
I have small SwiftUI app, and it throw an error like "Cannot find 'state' in scope" for this line
Register(state: state)
I guess it must be like that, but it is throw an error, I do not know what I missed? Any idea?
struct Register: View {
@ObservedObject private var viewModel: RegisterViewModel
init(state: AppState) {
self.viewModel =RegisterViewModel(authAPI: AuthService(), state: state)
}
var body: some View {
}
}
struct Register_Previews: PreviewProvider {
@ObservedObject private var viewModel:
RegisterViewModel
@State var pushActive = false
init(state: AppState) {
self.viewModel = RegisterViewModel(authAPI: AuthService(), state: state)
}
static var previews: some View {
Register(state: state)
}
}
class RegisterViewModel: ObservableObject {
@Published var state: AppState
init(authAPI: AuthAPI, state: AppState) {
self.authAPI = authAPI
self.state = state
}
}
}
I have simple app in SwiftUI, when I use @Binding var show : Bool for second register screen,
it is throw an error for this line of code
init(state: AppState) {
self.viewModel = RegisterViewModel(authAPI: AuthService(), state: state)
}
as a "Return from initializer without initializing all stored properties" any idea?
first screen:
import SwiftUI
struct RegisterFirstScreen: View {
@Binding var show : Bool
init(state: AppState) {
self.viewModel = RegisterViewModel(authAPI: AuthService(), state: state)
}
var body: some View {
NavigationLink(destination: RegisterSecondScreen(state: viewModel.state, show: $show),
isActive: self.$pushActive) {
Button {
viewModel.signUp()
} label: {
Text("Register Now")
.padding()
}
}
}
second screen:
struct RegisterSecondScreen: View {
@ObservedObject var state: AppState
@Binding var show : Bool
var body: some View {
Text("Next main screen")
}}
When I update my macbook to macOS13 Venture , I have a problem in top right corner, always give alots of notifications , how can I solve it?
I have new project and I added "pod 'AssetsPickerViewController', '~> 2.0' " to pod file and import AssetsPickerViewController to my project file, but still throw this error? Any idea?
I was use pod install for my project and it throw error like below.
"[!] The MyApp [Debug] target overrides the FRAMEWORK_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-MyApp/Pods-MyApp.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the $(inherited)` flag, or
- Remove the build settings from the target."
even I try to fix the xcode with $(inherited) in project target and project, it is still same. I don't know what I miss?
I want to use segue programmaticly , but it throw error for
ForgotPasswordEmailCheckController as "Cannot convert value of type 'ForgotPasswordEmailCheckController.Type' to expected argument type 'UIViewController'" Any idea?
ForgotPasswordEmailCheckController:
class ForgotPasswordEmailCheckController: UIViewController, UITextFieldDelegate {
var storyboardId: String {
return (value(forKey: "ForgotPasswordEmailCheck") as? String)!
}
LoginViewController:
@IBAction func forgotPassword(_ sender: Any) {
let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
guard let forgotPasswordEmailCheck = mainStoryboard.instantiateViewController(identifier: "ForgotPasswordEmailCheck") as?
ForgotPasswordEmailCheckController else {
print("Not correct password")
return
}
navigationController?.pushViewController(ForgotPasswordEmailCheckController, animated: true)
}
The default colour of a list row when tapped is grey.
I try many solution on stackoverflow and apple form, I did not solve problem, any idea?
RecentRowView:
struct RecentRowView: View {
var body: some View {
HStack(spacing: 15){
List{
NavigationLink(destination: SecondView()
){
VStack{
HStack{
VStack(alignment: .leading, spacing: 8, content: {
Text(recent.name)
.font(.custom("Helvetica Neue", size: 14))
})
Spacer(minLength: 10)
ZStack {
}
}
}
}
}
}
}
}
I am use SecondView as programmatically, I am click the button in ViewController and open SecondView controller, but I want to back to ViewController. I do not have storyboard in SecondView and I want to click the closeButton and back to ViewController. My code work but when I click the close button it is not work. Any idea?
import UIKit
class SecondView: UIViewController {
var closeButton = UIButton()
override func viewDidLoad() {
super.viewDidLoad()
closeButton.addTarget(self, action: #selector(dismissActionSheet), for: .touchUpInside)
}
@objc func dismissActionSheet() {
self.navigationController?.popViewController(animated: true)
}
}