我有一个HomeView
NavigationView {
ZStack {
VStack {
NavigationLink(destination: ProfileView()) {
if session.userInSession?.activated != 1 {
completionText(message: "Complete Your Profile")
} else {
completionText(message: "Edit Your Profile")
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的ProfileView没有包含在导航视图中,也没有栏标题:
VStack {
ScrollView(showsIndicators: false) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
但我的ProfileView也可以从我的访问SettingView
NavigationView {
VStack(alignment: .leading) {
List {
NavigationLink(destination: ProfileView()) {
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我ProfileView从设置屏幕访问我的时,它显示正常。但是当我从我的访问它时,HomeView它会在顶部创建空白:
当我通过“设置”时,效果很好:
如何删除上面的空白?
我不确定为什么会收到此错误:
Unable to resolve module `@expo/vector-icons` from `...(directory path here)...` : Module does not exist in the module pack
Run Code Online (Sandbox Code Playgroud)
我尝试了其他论坛/网站上建议的以下内容:
包.json
{
"name": "app name",
"version": "0.0.0",
"description": "Hello Expo!",
"author": null,
"private": true,
"main": "node_modules/expo/AppEntry.js",
"dependencies": {
"babel-plugin-module-resolver": "^2.5.0",
"babel-preset-expo": "^4.0.0",
"expo": "^21.0.0",
"firebase": "^4.5.1",
"geofire": "^4.1.2",
"moment": "^2.19.1",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz",
"react-navigation": "^1.0.0-beta.13"
}
}
Run Code Online (Sandbox Code Playgroud)
但仍然没有,仍然收到此错误
我有这样的Postgres LIKE声明:
@favorites.find_each do |profiles|
@related_profiles = Profile.where('name LIKE ?', '%' + profiles.name + '%')
end
Run Code Online (Sandbox Code Playgroud)
我正在尝试做的是遍历favourites变量,并找到带有contain某些名称字符的所有配置文件。
例如,"jasson jackson"如果名称包含"jackson"或"jasson"
ruby postgresql ruby-on-rails ruby-on-rails-4 rails-activerecord
所以我有这样的布局:
家用/ index.html.erb:
<div class="optionscontainer btn-group btn-group-justified">
<%= link_to posts_path, class:"options btn btn-primary", remote: true do %>
<i class="fa fa-book optionseach" aria-hidden="true"></i>All posts
<% end %>
<%= link_to stories_path, class:"options btn btn-primary", remote: true do %>
<i class="fa fa-book optionseach" aria-hidden="true"></i>All stories
<% end %>
</div>
<div id="content" class="">
</div>
Run Code Online (Sandbox Code Playgroud)
在posts_controller.rb中
我有:
def index
@posts = Post.all
respond_to do |format|
format.html #looks for views/books/index.html.erb
format.js #looks for views/books/index.js.erb
end
end
Run Code Online (Sandbox Code Playgroud)
在stories_controller.rb中
我有:
def index
@stories = Story.all
respond_to do |format| …Run Code Online (Sandbox Code Playgroud) 我是 Rails 的新手,并且很难由设计用户创建配置文件
这是 ProfileController:
class ProfilesController < ApplicationController
before_action :set_profile, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
def index
@profiles = Profile.all
end
def new
@profile = current_user.build_profile
end
def create
@profile = current_user.build_profiles(profile_params)
redirect_to profiles_path
end
def show
end
def edit
end
def update
@profile.update(profile_params)
redirect_to(profiles_path(@profile))
end
def destroy
@profile.destroy
redirect_to profiles_path
end
private
def profile_params
params.require(:profile).permit(:university, :degree)
end
def set_profile
@profile = Profile.find(params[:id])
end
end
Run Code Online (Sandbox Code Playgroud)
当我运行 Rails 服务器时,我可以提交表单,但没有任何内容存储在模型“配置文件”中
这是数据应该出现的 index.html.erb:
<h2>profiles</h2>
<% @profiles.each do |profile| %>
<%= …Run Code Online (Sandbox Code Playgroud) 我已经在stackoverflow上尝试了多个答案,而且似乎没有工作,但无论如何这里是个问题.
我试着active-admin用我的Rails 5应用程序.
在我的宝石文件中,我有:
gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin'
gem 'inherited_resources', git: 'https://github.com/activeadmin/inherited_resources'
gem 'jquery-ui-rails'
Run Code Online (Sandbox Code Playgroud)
在我的application.js中,我有:
//= require jquery
//= require bootstrap-sprockets
//= require ckeditor/init
//= require jquery-ui
//= require jquery-ui/datepicker
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
在我的application.scss中我有:
@import "jquery-ui";
@import "jquery-ui/datepicker";
Run Code Online (Sandbox Code Playgroud)
尽管遵循了所述的所有说明,但我收到了一个错误:
couldn't find file 'jquery-ui/datepicker' with type 'application/javascript
Run Code Online (Sandbox Code Playgroud)
并且错误似乎发生在这里:
//= require jquery-ui/datepicker
Run Code Online (Sandbox Code Playgroud)
编辑
我有一个重定向 action_controller.rb
def after_sign_in_path_for(user)
home_mypath_path
end
Run Code Online (Sandbox Code Playgroud)
我认为这会干扰登录.
我有一个ScrollView:
ScrollView {
VStack (alignment: .leading) {
Text("\(userData.username), \(userData.age)")
.fontWeight(.semibold)
.font(Font.system(size:30))
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
我尝试翻转堆栈并在其中包含滚动视图,但得到了相同的结果。
我的工作是将它放在一个 HStack 中并添加一个 Spacer()
HStack {
Text("\(userData.username), \(userData.age)")
.fontWeight(.semibold)
.font(Font.system(size:30))
.padding([.leading])
Spacer()
}
Run Code Online (Sandbox Code Playgroud)
这可以解决问题,但我认为这不是理想的方式。这是唯一的方法吗?或者是否有更好的解决方案在滚动视图中垂直对齐文本?
我有一个快速RoundedRectangle:
ScrollView(.horizontal, showsIndicators: false) {
Group {
HStack {
if let height = height {
if height != "" {
aboutMeItem(info: height, image: "ruler").frame(minWidth: 20)
}
}
}
.frame(minHeight: 70, maxHeight: 70)
.overlay(RoundedRectangle(cornerRadius: 15).stroke(Color("darkGrey"), lineWidth: 3))
.padding([.leading,.top,.trailing])
}
}
Run Code Online (Sandbox Code Playgroud)
我的输出是:
由于某种原因,底线被稍微切掉,您看不到完整的线宽。
Iv 尝试删除其下方的视图,以防有东西覆盖它,但事实并非如此。我尝试过弄乱 和frame min,maxHeight但无论如何,那仍然是一样的。
我试着去link_to的show一个行动post.
在我的controller身上:
@post = Post.all
Run Code Online (Sandbox Code Playgroud)
在我看来,我试图将它链接到最后一个帖子,如下所示:
<%= link_to @post.last do %>
<%= @post.last.title %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
但它没有带我到那篇文章的节目页面?
我有一个哈希
h = Hash.new{|hsh,key| hsh[key] = [] }
Run Code Online (Sandbox Code Playgroud)
它的值存储为数组
Iv添加到键的值数组,如下所示:
h[@name] << @age
h[@name] << @grade
Run Code Online (Sandbox Code Playgroud)
我试图访问这样的年龄
puts h[:@name][0]
Run Code Online (Sandbox Code Playgroud)
但它不起作用?
有没有更好的方法呢?
什么即时试图做的是创建一个哈希那里是具有价值负荷的关键:比如key=>name和值相等age,address,gender等
我有以下几点:
var body: some View {
NavigationView {
VStack {
Text("Hello")
}.navigationBarTitle("Edit Profile", displayMode: .inline)
.background(NavigationConfiguration { nc in
nc.navigationBar.barTintColor = .red
nc.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.black]
})
}.navigationViewStyle(StackNavigationViewStyle())
}
Run Code Online (Sandbox Code Playgroud)
对于导航栏的配置,我有:
struct NavigationConfiguration: UIViewControllerRepresentable {
var configuration: (UINavigationController) -> Void = { _ in }
func makeUIViewController(context: UIViewControllerRepresentableContext<NavigationConfiguration>) -> UIViewController {
UIViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext<NavigationConfiguration>) {
if let nc = uiViewController.navigationController {
self.configuration(nc)
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是由于某种原因,顶部状态栏被排除在外,并且没有对其应用颜色:
如何将红色也应用于导航栏上方的状态栏,我希望它是相同的颜色。
我试过下面的,但这失败了:
init() {
UINavigationBar.appearance().backgroundColor = .red
}
Run Code Online (Sandbox Code Playgroud) uinavigationbar uinavigationcontroller swift swiftui swiftui-navigationlink
我的文件LazyVGrid中有类似的内容SearchView.swift
let layout = [
GridItem(.flexible()),
GridItem(.flexible())
]
NavigationView {
ZStack {
VStack {
....Some other stuff here
ScrollView (showsIndicators: false) {
LazyVGrid(columns: layout) {
ForEach(searchViewModel.allUsers, id: \.uid) { user in
NavigationLink(destination: ProfileDetailedView(userData: user)) {
profileCard(profileURL: user.profileURL, username: user.username, age: user.age, country: user.city)
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的 profileCard.swift 看起来像:
var body: some View {
ZStack {
Image.image(urlString: profileURL,
content: {
$0.image
.resizable()
.aspectRatio(contentMode: .fill)
}
)
.frame(width: 185, height: 250)
.overlay(
LinearGradient(gradient: Gradient(colors: …Run Code Online (Sandbox Code Playgroud) splitDescription = work.workdescription.downcase.split(' ')
keywords = ['teamwork', 'developed', 'enhanced', 'transformed', 'achieved','grew', 'introduced', 'project', 'awarded',
'planned','supervised','created','designed','discovered','evaluated','promoted','represented','completed',
'devised','liaised','controlled','researched','organised','achieved','managed','analysed','assessed','conducted',
'solved','responsible for','responsibilities']
splitDescription.select {|word| word.include?(keywords)}.each do |word|
new_score += 0.5
end
Run Code Online (Sandbox Code Playgroud)
我有一个splitDescription拆分并存储描述.
我想看看是否有任何关键字都在splitDescription和每个keyword在splitDescription的new_score0.5上升.
我正在尝试此代码,但它无法正常工作.
ruby ×5
swiftui ×5
swift ×4
datepicker ×1
devise ×1
expo ×1
npm ×1
postgresql ×1
react-native ×1
uiscrollview ×1