Post

Replies

Boosts

Views

Activity

How can I give the permission for WKWebView to access phone library?
I have a small app and I am using WKWebView for my app, so in WebView I have sign in, when I sign to WebView I have to import image, documents etc to WebView, so I have to use permission in my app, is it possible to apply WKWebView in below code? import SwiftUI import WebKit struct ContentView: View { var body: some View { ZStack{ WebView() } } } struct WebView: UIViewRepresentable { func makeUIView(context: Context) -> WKWebView { WKWebView(frame: .zero) } func updateUIView(_ view: WKWebView, context: UIViewRepresentableContext<WebView>) { let request = URLRequest(url: URL(string: "https://codepen.io/login")!) view.load(request) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() .navigationBarHidden(true) } }
0
0
580
Jun ’22
Why after pod install throw that error?
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?
1
0
8.8k
Jun ’21
Cannot convert value of type 'ForgotPasswordEmailCheckController.Type' to expected argument type 'UIViewController'?
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)   }
1
0
1.3k
Jul ’21
SwiftUI: Change List row Highlight colour when tapped
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 {                 }           }  }          }         }        }     }    }
1
0
4.0k
Sep ’21
Why I am not able to click button and back to ViewController?
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)    } }
1
0
399
Jul ’21
Change icons border when click the bottom tab bar in Swift
I have custom bottom navigation bar in IOS application, everythings work very well, and I want to change bottom navigation items tint color when I click the items, and I was use the self.imgView.image!.withRenderingMode(.alwaysTemplate) self.imgView.tintColor = .red in isSelected, and it is change whole icons border tint color. I do not know where I miss, any idea? RootStackTabViewController: class RootStackTabViewController: UIViewController { @IBOutlet weak var bottomStack: UIStackView! var currentIndex = 0 lazy var tabs: [StackItemView] = { var items = [StackItemView]() for _ in 0..<5 { items.append(StackItemView.newInstance) } return items }() lazy var tabModels: [BottomStackItem] = { return [ BottomStackItem(title: "Home", image: "home"), BottomStackItem(title: "Favorites", image: "heart"), BottomStackItem(title: "Search", image: "search"), BottomStackItem(title: "Profile", image: "user"), BottomStackItem(title: "Settings", image: "settings") ] }() override func viewDidLoad() { super.viewDidLoad() self.setupTabs() } func setupTabs() { for (index, model) in self.tabModels.enumerated() { let tabView = self.tabs[index] model.isSelected = index == 0 tabView.item = model tabView.delegate = self self.bottomStack.addArrangedSubview(tabView) } } } StackItemView: protocol StackItemViewDelegate: AnyObject { func handleTap(_ view: StackItemView) } class StackItemView: UIView { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var imgView: UIImageView! @IBOutlet weak var highlightView: UIView! private let higlightBGColor = UIColor(hexString: "1160FB") static var newInstance: StackItemView { return Bundle.main.loadNibNamed( StackItemView.className(), owner: nil, options: nil )?.first as! StackItemView } weak var delegate: StackItemViewDelegate? override func awakeFromNib() { super.awakeFromNib() self.addTapGesture() } var isSelected: Bool = false { willSet { self.updateUI(isSelected: newValue) self.titleLabel.textColor = UIColor.white self.imgView.image!.withRenderingMode(.alwaysTemplate) self.imgView.tintColor = .red } } var item: Any? { didSet { self.configure(self.item) } } private func configure(_ item: Any?) { guard let model = item as? BottomStackItem else { return } self.titleLabel.text = model.title self.imgView.image = UIImage(named: model.image) self.isSelected = model.isSelected } private func updateUI(isSelected: Bool) { guard let model = item as? BottomStackItem else { return } model.isSelected = isSelected let options: UIView.AnimationOptions = isSelected ? [.curveEaseIn] : [.curveEaseOut] UIView.animate(withDuration: 0.4, delay: 0.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.5, options: options, animations: { self.titleLabel.text = isSelected ? model.title : "" let color = isSelected ? self.higlightBGColor : .white self.highlightView.backgroundColor = color (self.superview as? UIStackView)?.layoutIfNeeded() }, completion: nil) } } extension StackItemView { func addTapGesture() { let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleGesture(_:))) self.addGestureRecognizer(tapGesture) } @objc func handleGesture(_ sender: UITapGestureRecognizer) { self.delegate?.handleTap(self) } }
1
0
1.1k
Jul ’21
Why image detail view just show one image from listview?
I have list image and when I click the image list items it show me image details, but it show same image even I click the different image? any idea? Datas:  struct Datas: Identifiable {   var id = UUID().uuidString   var name: String   var detail: String   var image: String } var datas = [   Datas(name: "People1.jpg"),   Datas(name: "People.2jpg"),   Datas(name: "People3.jpg"), ] RowView: struct RowView: View {   var docs: Datas   var body: some View {  NavigationLink(destination:  ListDetailsView(docs: datas[0])) {       Image(docs.image)         .resizable()         .frame(width: 64, height: 48)         } } ListDetailsView: struct ListDetailsView: View {    var docs: Datas       var body: some View {           ZStack{       Image(docs.image)     }         } } struct ListDetailsView_Previews: PreviewProvider {   static var previews: some View {     ListDetailsView(docs: datas[0])   } }
1
0
364
Aug ’21
why it says "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value"?
I have IOS projets, it work but suddenly crash and throw error like "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value" Why? import Foundation import AVFoundation struct Video : Identifiable {   var id = UUID()   var player : AVPlayer   var user: User } struct User: Identifiable {   var id = UUID()   let userName: String   let userImage: String } struct MockData {   let videos: [Video] = [     Video(player: AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "reel_1", ofType: "mp4")!)),        user: User(userName: "cristiano", userImage: "user_9")),     Video(player: AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "reel_2", ofType: "mp4")!)),        user: User(userName: "mann_daar", userImage: "user_3")), ] }
1
0
1.2k
Sep ’21
Cannot convert value of type 'AnyViewModel<BookListState, Never>.Type' to expected argument type 'AnyViewModel<BookListState, Never>'
I want to put BookListView() on the content view but it throw error like "Cannot convert value of type 'AnyViewModel<BookListState, Never>.Type' to expected argument type 'AnyViewModel<BookListState, Never>'" Any idea? BookListView: import SwiftUI struct BookListState {   var service: BookService   var books: [Book] } struct BookListView: View {   @ObservedObject var viewModel: AnyViewModel<BookListState, Never>   var body: some View {     NavigationView {       ScrollView {       VStack(alignment: .leading){       ForEach(viewModel.state.books) { book in         NavigationLink(destination: NavigationLazyView(BookDetailView(service: self.viewModel.state.service, bookId: book.id))) {           BookRow(book: book)         }       }             }       }     }   } } struct BookListView_Previews: PreviewProvider {   static var previews: some View {     let viewModel = AnyViewModel(BookListViewModel(service: MockBookService()))     return BookListView(viewModel: viewModel)   } } ContentView: import SwiftUI struct ContentView: View {   var body: some View {    BookListView(viewModel: viewModel)   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } }
1
0
411
Oct ’21
How can I resize bottom sheet height?
I am using bottom sheet for my app, and it is work correctly, but I want to use the half bottom sheet, is it possible?      Image( "color")               .resizable()               .frame(width:45, height: 45)               .sheet(isPresented: $showSheet, content: {                   ScreenView()                  })
1
0
1.3k
Jul ’22
Why NavigationLink not work for text button in SwiftUI?
I have text button, and I want to use navigation link in this project, but it is not work when I click the button? Any idea?   @State var isLink = false       var body: some View {     GeometryReader { geometry in         ZStack {    NavigationLink(destination: SecondView(), isActive: $isLink) {                 Button() {                   self.isLink = true                 } label: {                                       Text("Button")                     .padding()                     .frame(width: 250, height: 50, alignment: .center)                     .foregroundColor(Color.white)                     .background(Color("color"))                     .clipShape(Capsule())                  }}}}
1
0
491
Feb ’22
why it throw an error as "'animation' was deprecated in iOS 15.0: Use withAnimation or animation(_:value:) instead"in SwiftUI 3.0?
I have a project, after update it to swiftUI 3.0, it is throw an error for    .animation(.spring()) as animation' was deprecated in iOS 15.0: Use withAnimation or animation(_:value:) instead, any idea?  @Binding var display: Bool   private var background: some View {   Color.black    .fillParent()    .opacity(0.6)    .animation(.spring())  }
1
0
690
Feb ’22
Why I am not success to pass data from one view to another view in SwiftUI?
I have a problem when try to pass data from one view to another view, it is throw an error for   ImageDetails() as a "Missing argument for parameter 'data' in call" I do not know what I missed? struct ImageModel: Identifiable, Hashable {   var id = UUID().uuidString   var name: String   } var datas = [       ImageModel(name: "davis"), ] struct ImageRowView: View {   var data: ImageModel   var body: some View {            NavigationLink(destination: ImageDetailsView(data: ImageModel)){                       HStack{} }}} struct ImageDetailsView: View {      var body: some View {           ImageDetails()   } } struct ImageDetailsView_Previews: PreviewProvider {   static var previews: some View {           ImageDetailsView()         } } struct ImageDetails : View {      var data: ImageModel   var body: some View{   VStack{             Text(data.name)                      } }
1
0
434
Feb ’22