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 {
}
}
}
}
}
}
}
}
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 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)
}
When I pod install in terminal it say "[!] Error installing MaterialControls", Cloning into '/var/folders/w_/46rzmwwn0k73x1dtmmqk4m_r0000gn/T/d20210618-4079-1b04w72'...
remote: Repository not found.
fatal: repository 'https://github.com/fpt-software/Material-Controls-For-iOS.git/' not found. Any idea?
Code below throw error as cannot convert value of type 'EventsTrigger' to expected argument type 'String?, where I miss?
EventsTrigger class:
public class EventsTrigger: NSObject {
static let instance: EventsTrigger = EventsTrigger()
}
and
self.service = NewService("node4", EventsTrigger.instance, err)
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
}`
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 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?
Hi every one, if you build a mobile project with SwiftUI, is it possible to use the app for sub version of IOS like iPhone 6s devices ?
I want to use NavigationLink for open the chat detail view when I click the rows items. Here example of code I mentioned. Any idea will be appreciated.
RecentRowView:
import SwiftUI
struct RecentRowView: View {
var recent: Profile
var animation: Namespace.ID
// Environment Object...
@EnvironmentObject var profileData: ProfileDetailModel
var body: some View {
HStack(spacing: 15){
// Making it as clickable Button....
Button(action: {
withAnimation{
profileData.selectedProfile = recent
profileData.showProfile.toggle()
}
}, label: {
ZStack{
// Without matched geometry effect simply showing image...
Image(recent.profile)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 60, height: 60)
.clipShape(Circle())
if !profileData.showProfile{
Image(recent.profile)
.resizable()
.aspectRatio(contentMode: .fill)
// Matched Geometry Effect...
// Giving unique ID that is from UUID from profile Model....
.matchedGeometryEffect(id: recent.id, in: animation)
.frame(width: 60, height: 60)
.clipShape(Circle())
}
}
})
// it decreased the highlight color....
.buttonStyle(PlainButtonStyle())
VStack{
NavigationLink(destination: ChatDetailView(), isActive: $profileData.show) {
HStack{
VStack(alignment: .leading, spacing: 8, content: {
Text(recent.userName)
.fontWeight(.bold)
Text(recent.lastMsg)
.font(.caption)
.foregroundColor(.gray)
})
Spacer(minLength: 10)
Text(recent.time)
.font(.caption2)
.foregroundColor(.gray)
}
Divider()
}
}
}
.padding(.horizontal)
}
}
struct RecentRowView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
ContentView:
struct ContentView: View {
// ANimation Namespace...
@Namespace var animation
// StateObject...
@StateObject var profileData = ProfileDetailModel()
var body: some View {
Home(animation: animation)
// setting Environment Object...
.environmentObject(profileData)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
NavigationView{
ContentView()
}
}
}
ChatDetailView:
import SwiftUI
struct ChatDetailView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
struct ChatDetailView_Previews: PreviewProvider {
static var previews: some View {
ChatDetailView()
}
}
I have simple project in swiftUI, everythings is work, but
HStack for Rectangle() as I mention below, do not alignment the Rectangle and text at the same line, and idea will be appreciated.
struct App: View {
var body: some View {
GeometryReader{g in
ZStack {
ForEach(0..data.count) { i in
DrawShape(center: CGPoint(x:g.frame(in: .global).width/2, y: g.frame(in: .global).height/2), index: i)
}
}
}
.frame(height: 200)
.clipShape(Circle())
.shadow(radius: 10)
VStack{
ForEach(data) { i in
HStack {
Text(i.name)
.frame(width:100)
.padding()
GeometryReader { g in
HStack{
Spacer(minLength: 0)
Rectangle()
.fill(i.color)
.frame(width: self.getWidth(width: g.frame(in: .global).width, value: i.percent) ,height: 10)
Text(String(format: "\(i.percent)", "%.0f"))
.fontWeight(.bold)
.padding(.leading,10)
.frame(width:80)
Spacer()
}.frame(width: 240, height: 30)
}
}
}
.padding()
Spacer()
}
}
func getWidth(width: CGFloat, value: CGFloat) - CGFloat {
let temp = value / 100
return temp * width
}
}
I have list item menu project in SwiftUI, my project work, but I have list icons, they are not shown in list view, even I was try to use system image, there is not any change on screen, any idea?
struct MasterView: View {
let view1 = Menu(name:"Home", image:"image_home", destination:.home)
let view2 = Menu(name:"View 1", image:"image_view1", destination:.view1)
let view3 = Menu(name:"View 3", image:"image_view2", destination:.view2)
var body: some View {
let menus: [Menu] = [view1, view2, view3]
return List {
ForEach(menus) { menu in
self.destinationView(menu: menu)
}}}
func destinationView(menu: Menu) - some View {
switch menu.destination {
case .view1:
return NavigationLink(
destination: AnyView(View1(menu: menu))
)
{
Text("\(menu.name)")
}
case .view2:
return NavigationLink(
destination: AnyView(View2(menu: menu))
)
{
Text("\(menu.name)")
}
default:
return NavigationLink(
destination: AnyView(HomeView(menu: menu))
)
{
Text("\(menu.name)")
}}}}
Model.swift:
/// Main menu item for the list
struct Menu: Identifiable {
var id = UUID()
var name: String
var image: String
var destination: ViewType
}
enum ViewType {
case home
case view1
case view2
}
I have list item, and all item destination view routed to EndView, how can I add multiple destination view for every item, for example: when I click the first item it will open EndView, when I click the second item it will open NewView...., any idea will be appreciated.
Option:
struct InnerOptionValues: Codable {
var title: String
var image: String
var isAddSection: Bool
var isUseToggle: Bool
var headerTitle: String
}
extension Option {
static let listValues: [InnerOptionValues] = [
.init(title: "title1", image: "image1", isAddSection: true, isUseToggle: false, headerTitle: ""),
.init(title: "title2",image: "image2", isAddSection: false, isUseToggle: false, headerTitle: ""),
.init(title: "title3", image: "image3", isAddSection: false, isUseToggle: false, headerTitle: ""),
.init(title: "4", image: "image4", isAddSection: false, isUseToggle: false, headerTitle: ""),
.init(title: "5", image: "image5", isAddSection: false, isUseToggle: false, headerTitle: ""),
]
InnerView:
struct InnerView: View {
let value: InnerOptionValues
var body: some View {
return NavigationLink(destination: EndView(value: value)) {
HStack {
Image(value.image)
.resizable()
.frame(width: 16, height: 16)
.aspectRatio(contentMode: .fill)
Text(value.title)
.foregroundColor(.blue)
.font(.system(size: 18))
}
}
}
}
struct EndView: View {
let value: InnerOptionValues
var body: some View {
return NavigationLink(destination: EndView(value: value)) {
Text("Coming Soon!!!")
.font(.system(size: 25))
.foregroundColor(.blue)
} .navigationBarTitle(Text(value.title), displayMode: .inline)
}
}
I have a simple SwiftUI project, when I click the any list items, I want to route different SwiftUI. Below, I used arrays, and for every SwiftUI, I want to use [0], [1],..., but it throw error, I do not know why? Any idea?
ContentView:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List(contacts) { contact in
NavigationLink(destination: NumberOneView(contact: contact)) {
ContactRow(contact: contact)
}
}
.navigationBarTitle("Contacts")
}
.environment(\.colorScheme, .light)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct ContactRow: View {
let contact: Settings
var body: some View {
HStack {
Image(contact.imageName)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 20, height: 20)
VStack(alignment: .leading) {
Text(contact.name)
.font(.system(size: 21, weight: .medium, design: .default))
}
}
}
}
Settings.swift:
import Foundation
import SwiftUI
struct Settings: Identifiable {
let imageName: String
let name: String
let id = UUID()
}
let contacts = [
Settings(imageName: "image1", name: "NumberOne"),
Settings(imageName: "image2", name: "NumberTwo"),
Settings(imageName: "image3", name: "NumberThree"),
Settings(imageName: "image4", name: "NumberFour"),
]
NumberOneView:
import SwiftUI
struct NumberOneView: View {
let contact: Settings
var body: some View {
Text("hey")
}
}
struct NumberOneView_Previews: PreviewProvider {
static var previews: some View {
NumberOneView(contact: contacts[0])
}
}
NumberTwoView:
import SwiftUI
struct NumberTwoView: View {
let contact: Settings
var body: some View {
Text("hey")
}
}
struct NumberTwoView_Previews: PreviewProvider {
static var previews: some View {
NumberTwoView(contact: contacts[1])
}
}
It throw fatal error for data in " self.data.selectedData = i", even I try to calling @State for solve, but nothing change.
Main:
struct Main : View {
@EnvironmentObject var data : msgDatas
@State var show: Bool = false
var body : some View{
List(msgs){i in
cellView(pic: i.pic, name: i.name, msg: i.msg, time: i.time, msgs: i.msgs).onTapGesture {
self.data.selectedData = i
self.show.toggle()
}
}
}
}
cellView:
struct cellView : View {
var pic : String
var name : String
var msg : String
var time : String
var msgs : String
var body : some View{
HStack(spacing: 15){
Image(pic).resizable().frame(width: 50, height: 50).clipShape(Circle())
VStack(alignment:.leading,spacing: 5){
Text(name)
Text(msg).lineLimit(2)
}
Spacer()
VStack(spacing: 10){
Text(time)
if msgs != ""{
Text(msgs).padding(8).background(Color("bg")).foregroundColor(.white).clipShape(Circle())
}
else{
Spacer()
}
}
}.padding(9)
}
}