I have custom search bar and custom circle image in toolbar, when I click the circle image, I want to navigate new SwiftUI. Any idea will be appreciated.
ImageView:
VStack(alignment: .leading, spacing:0){
HStack(spacing: 0){
TextField("Search", text: $search)
.padding(.vertical,5)
.padding(.horizontal)
.background(Color.gray.opacity(0.090))
.cornerRadius(30)
.frame(width: 330, height: 32)
Image("imgage")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 32, height: 32)
.clipShape(Circle())
.overlay(Circle().stroke(Color("fig"), lineWidth: 1))
}
}
ContentView:
var body: some View {
//I have tabview here//
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have sidebar menu, I want to integrate with my app. In app, I have tabbar, sidebar menu not work correctly with tab bar. Any idea will be appreciated?
var body: some View {
SideMenuView()
TabView(selection: $selection){
PeopleView()
.tabItem {
selection == 0 ? Image("people-selected") : Image("people")
}
.tag(0)
AnimalView()
.tabItem {
selection == 1 ? Image("animal-selected") : Image("animal")
}
.tag(1)
PlantsView()
.tabItem {
selection == 2 ? Image("plants-selected") : Image("plants")
}
.tag(2)
}
I have a SwiftUI project, since long time I try to customize my project toolbar in SwiftUI, but SwiftUI 2.0 not support it. When new version of SwiftUI will release? Any idea?
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 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 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 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)
}
}
I have bottom navigation bar and in fist view I have list item, when I click the list item, it is open detail view, but bottom navigation bar still stay in detail view, I want to hide navigation bar when I click open the detail view. Is it possible?
ContentView:
struct TabView : View {
@State private var selection = 0
@State var index = 0
var body: some View{
VStack(spacing: 0){
ZStack{
ListView()
.opacity(self.index == 0 ? 1 : 0)
}
HStack{
Button(action: {
self.index = 0
}) {
HStack(spacing: 6){
Image("List")
.foregroundColor(self.index == 0 ? Color("blue") : .black)
if self.index == 0{
Text("List")
.foregroundColor(Color("blue"))
}
}
.padding(.vertical,10)
.padding(.horizontal)
.background(self.index == 0 ? Color("tabbar-background") : Color.clear)
.clipShape(Capsule())
}
Spacer(minLength: 0)
Button(action: {
self.index = 1
}) {
HStack(spacing: 6){
Image("SecondList")
.foregroundColor(self.index == 1 ? Color("blue") : .black)
if self.index == 1{
Text("SecondList")
.foregroundColor(Color("blue"))
}
}
.padding(.vertical,10)
.padding(.horizontal)
.background(self.index == 1 ? Color("tabbar-background"): Color.clear)
.clipShape(Capsule())
}}}
.edgesIgnoringSafeArea(.bottom)
}
}
ListView:
struct ListView: View {
var body: some View {
VStack{
ScrollView(.vertical, showsIndicators: false, content: {
VStack(spacing: 15){
RowView(docs: docs)
}
}
}
}
}
}
struct RowView: View {
@State var docs: Datas
var body: some View {
HStack(spacing: 15){
NavigationLink(destination: ListDetailView(docs: docs)) {
HStack{
Image(docs.image)
.resizable()
.frame(width: 64, height: 48)
}
}
}
.padding(.horizontal)
}
}
ListDetailView:
import SwiftUI
struct ListDetailView: View {
@State var docs: Datas
var body: some View {
ZStack{
Image(docs.image)
.resizable()
.aspectRatio(contentMode: .fit)
}
}
}
struct ListDetailView_Previews: PreviewProvider {
static var previews: some View {
ListDetailView(docs: datas[0])
}
}
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()
})
I have simple chat app, and I want to use simple emoji in this chat app, my emoji is located in
EmojiView
an when I click the emoji button, I want to add in live chat, but I do not know how I will forward for it, I was look at many resources but I did not find any example on internet, is it possible to do it?
import SwiftUI
struct MessageDetailsView: View {
var body: some View {
HomeMessageDetails()}}
struct MessageDetailsView_Previews: PreviewProvider {
static var previews: some View {
MessageDetailsView()
}}
struct HomeMessageDetails : View {
@State var message = ""
@StateObject var allMessages = Messages()
@State private var emojiData = false
var body: some View{
ZStack {
VStack{
ScrollView(.vertical, showsIndicators: false, content: {
ScrollViewReader{reader in
VStack{
ForEach(allMessages.messages){message in
ChatBubble(message: message)
}
.onChange(of: allMessages.messages) { (value) in
if value.last!.chatMessages{
reader.scrollTo(value.last?.id)}}}
.padding([.horizontal,.bottom])}})
HStack {
HStack{
TextField("Message", text: self.$message)
Button(action: {
emojiData = true
}, label: {
Image("emoji")
}) .sheet(isPresented: $emojiData) {
EmojiView()
} }
.padding(.vertical, 10)
.padding(.horizontal)
Button(action: {
allMessages.messages.append(Message(id: Date(), message: message, chatMessages: true))
message = ""
}, label: {
Image("reply")
}) }
.padding(.horizontal)
}} }}
struct ChatBubble : View {
var message : Message
var body: some View{
HStack(alignment: .top,spacing: 10){
if message.chatMessages{
Text(message.message)
.foregroundColor(Color("black))
}
else{
Text(message.message)
.foregroundColor(.white) }}
.id(message.id)}}
struct Message : Identifiable,Equatable{
var id : Date
var message : String
var chatMessages : Bool
}
class Messages : ObservableObject{
@Published var messages : [Message] = []
init() {
let strings = ["Hii","Hello !!!!"]
for i in 0..<strings.count{
messages.append(Message(id: Date(), message: strings[i], chatMessages: i % 2 == 0 ? true : false))}}
func writeMessage(id: Date,message: String,chatMessages: Bool){
messages.append(Message(id: id, message: message, chatMessages: chatMessages))}}
struct EmojiView: View {
var body: some View {
Button(action: {
}, label: {
Image("smile_emoji")
}) }}
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)
}
}
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?
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 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 searchbar for name, but it is throw an arror like " Value of type 'Text' has no member 'searchable'" any idea?
@State private var searchText = ""
Text(data.name)
.font(.custom("Helvetica Neue", size: 14))
.searchable(text: $searchText)