我喜欢通过子类化 UNNotificationTrigger 为我的 Swiftui 应用程序创建高度通知触发器。当我爬山并达到 2000 米的高度时,我的苹果设备上会收到通知。请告诉我如何做。
我阅读了苹果文档并没有找到任何线索。
我初始化了一个仅由不超过 2 的数字组成的变量 g,然后初始化了一个由三个元素组成的 bool 数组,然后f[g[0]]
我得到一个异常:“索引超出了数组的范围。” 既然f[3]
为什么g[0] = f.length
总是不管 的长度g
和值g[0]
?
string g = "022";
bool[] f = { true, true, true };
Console.WriteLine(f[(int)g[0]]);
Console.ReadLine();
我希望背景图像和绿色 UI 元素位于屏幕顶部,但代码位于绿色 UI 元素下方的中间。
代码:
struct AppointmentStep1: View {
@Environment(\.dismiss) var dismiss
var body: some View {
ZStack {
// Background image
Image("home_bg")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
VStack {
HStack {
Button {
dismiss()
} label: {
Image(systemName: "arrow.left")
.font(.system(size: 25))
.tint(.white)
.padding(.trailing, 6)
}
Text("Appointment")
.font(.calibriRegular(with: 20))
.foregroundStyle(.white)
Spacer()
}
.padding(16)
}
.background(
Color.appGreen2
.ignoresSafeArea()
)
Spacer()
}
}
}
o/p:如何将绿色视图移至顶部
[![在此处输入图像描述][1]][1]
编辑:
这是我的背景图片:请尝试使用这个背景..我总是得到相同的o/p
当我输入“12345”和“0”的用户输入时,我看到在第一个循环中 arrOne 正在按照我期望的方式填充 1, 2, 3, 4, 5。但是在第二个循环之后(填充 arrTwo )当我去打印 arrOne 的值(使用第三个循环)时,我看到这些值现在是 0, 2, 3, 4, 5。
我对在初始循环后如何修改 arrOne 的初始值感到摸不着头脑。感谢任何指导!
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
// Write your main here
string inputOne = "";
string inputTwo = "";
cout << "Please enter two positive integers up to 20 digits long" << endl;
cin >> inputOne;
cin >> inputTwo;
int arrOne[inputOne.length() - 1];
int arrTwo[inputTwo.length() - 1];
for(int i = 0; i< inputOne.length(); i++){
arrOne[i] = inputOne[i] - '0';
cout<< "arrOne[i] = " << arrOne[i] << endl;
}
for(int i = 0; i< inputTwo.length(); i++){
arrTwo[i] = inputTwo[i] - '0';
cout<< "arrTwo[i] = " << arrTwo[i] << endl;
}
for(int i = 0; i< inputOne.length(); i++){
cout<< "arrOne[i] = " << arrOne[i] << endl;
}
return 0;
}
我期望在填充 arrTwo 数组后,arrOne 数组将继续存储 1、2、3、4、5。
package main
import (
"fmt"
"strings"
"time"
)
func main() {
const col = 30
// Clear the screen by printing \x0c.
bar := fmt.Sprintf("\x0c[%%-%vs]", col)
for i := 0; i < col; i++ {
fmt.Printf(bar, strings.Repeat("=", i)+">")
time.Sleep(100 * time.Millisecond)
}
fmt.Printf(bar+" Done!", strings.Repeat("=", col))
}
第 12 行使用此格式动词语法“[%%-%vs]”。谁能解释一下它是如何解析的?双“%%”和“%vs”对我来说没有意义。谢谢。
尝试将其分成几部分并使用文字替换(例如 col 值)运行,但无法产生与运行示例所产生的结果相同的结果。
我正在尝试将Args
参数从模板传递到容器deque.emplace_back()
调用
例如
class Collection
{
public:
template <typename ...Args>
Collection(const std::string& name, Args... entries)
: m_name(name)
{
m_entries.emplace_back(entries...); // Here!!!! Entry<int>, Entry<double>, Entry<int, int> added to deque
}
private:
std::string m_name;
std::deque<std::any> m_entries;
};
Collection collection1
{
"my collection",
Entry<int>{4},
Entry<double>{5.5},
Entry2<int, int>{1, 2}
};
emplace_back
是带有Args
参数重载的模板
template< class... Args >
reference emplace_back( Args&&... args );
所以我认为它可能需要一个对象列表。但这还没有编译。有错误
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::any; _Args = {Entry<int>&, Entry<double>&, Entry2<int, int>&}; _Tp = std::any]':
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/alloc_traits.h:537:17: required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::any; _Args = {Entry<int>&, Entry<double>&, Entry2<int, int>&}; _Tp = std::any; allocator_type = std::allocator<std::any>]'
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/deque.tcc:170:30: required from 'std::deque<_Tp, _Alloc>::reference std::deque<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {Entry<int>&, Entry<double>&, Entry2<int, int>&}; _Tp = std::any; _Alloc = std::allocator<std::any>; reference = std::any&]'
<source>:44:31: required from 'Collection::Collection(const std::string&, Args ...) [with Args = {Entry<int>, Entry<double>, Entry2<int, int>}; std::string = std::__cxx11::basic_string<char>]'
<source>:58:1: required from here
/opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/bits/new_allocator.h:187:11: error: no matching function for call to 'std::any::any(Entry<int>&, Entry<double>&, Entry2<int, int>&)'
187 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
该项目有点混乱,所以我会尝试尽可能简单,但就上下文而言,这是使用 Angular、Spring 和 Maven。不过,我相当确定唯一相关的部分是有角度的。
我正在尝试进行调用以显示资源包中的信息,并且它可以很好地处理几个显示字符串完整的控制台打印,但在加载时它仍然在页面上显示为数组(例如:显示为 S,t, r,i,n,g 而不是字符串)
这是java中的MessageController(多线程是作业的一部分,我不认为它是相关的,但将其包含在上下文中):
public class MessageController {
static ExecutorService messageExecutor = newFixedThreadPool(2);
public static String myMessage = "";
public static String myMessage1 = "";
@RequestMapping(path = "/welcome")
public String welcome(){
Properties properties=new Properties();
messageExecutor.execute(()->{
try{
InputStream stream = new ClassPathResource("welcome_en.properties").getInputStream();
properties.load(stream);
System.out.println(properties.getProperty("welcome"));
myMessage = properties.getProperty("welcome");
} catch (Exception e) {
e.printStackTrace();
}
});
messageExecutor.execute(()->{
try{
InputStream stream = new ClassPathResource("welcome_fr.properties").getInputStream();
properties.load(stream);
System.out.println(properties.getProperty("welcome"));
myMessage1 = properties.getProperty("welcome");
} catch (Exception e) {
e.printStackTrace();
}
});
String arrayMessage = myMessage+ ", " +myMessage1;
System.out.println(arrayMessage);
return arrayMessage;
}
}
此时,一切都正确打印到控制台,一切看起来都很好。
接下来,在 app.component.ts 中我们有:
ngOnInit(){
this.getWelcome().subscribe(
welcome=>{
this.welcome= <any>Object.values(welcome);
}}
和 getWelcome():
getWelcome(): Observable<any>{
return this.httpClient.get(this.baseURL + '/welcome', {responseType: "text"});
}
这只是设置:
welcome!:string;
并在 html 中调用为:
{{welcome}}
使用此,网页显示:W,e,l,c,o,m,e,,, ,B,i,e,n,v,e,n,u,e
即使 http://localhost:8080/welcome 正确显示:Welcome, Bienvenue
如何才能正确显示此消息?
在提供的示例中,较小的形状比较大的形状动画快得多,因为它的笔划长度要短得多。
我的理解是,将stroke-dasharray
100% 设置为 100% 而不是像素量应该可以实现此目的,但这样做会产生意想不到的结果,即笔划不会完全扩展形状的 100%。
.page-wrapper {
display: flex;
justify-content: center;
align-items: center;
grid-column-gap: 2em;
grid-row-gap: 2em;
}
.radar-wrapper {
width: 300px;
height: 300px;
}
.shape {
fill: #ff4040;
fill-opacity: .4;
stroke: #ff4040;
stroke-width: 2;
stroke-dasharray: 2000;
stroke-dashoffset: 0;
animation: draw 5s infinite linear;
}
@keyframes draw {
from {
stroke-dashoffset: 2000;
}
to {
stroke-dashoffset: 0;
}
}
<div class="page-wrapper">
<div class="radar-wrapper">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
<polygon class="shape" points="116.67 3.97 155.96 123.88 243.39 32.89 174.14 138.38 299.79 150 174.14 161.62 243.39 267.11 155.96 176.12 116.67 296.03 133.3 170.95 15.05 214.99 123.21 150 15.05 85.01 133.3 129.05 116.67 3.975"></polygon>
</svg>
</div>
<div class="radar-wrapper">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
<polygon class="shape" points="144.04 176.12 133.3 170.95 125.86 161.62 123.21 150 125.86 138.38 133.3 129.05 144.04 123.88 155.96 123.88 166.7 129.05 174.14 138.38 176.79 150 174.14 161.62 166.7 170.95 155.96 176.12 144.04 176.12"></polygon>
</svg>
</div>
</div>
我有一个 Spring Boot 应用程序,当服务器字段值放入 application.properties 并读取时,该应用程序工作正常。但是,我的应用程序可以具有动态服务器值。因此,在运行java -jar your-app.jar server nam
应用程序时,将获取 nam 服务器的所有属性,java -jar your-app.jar server euro
并将获取 Euro 服务器的所有属性。我怎样才能做到这一点。我正在考虑两个文件 application.nam.properties 和 application.euro.properties 并通过它java -jar your-app.jar --spring-config-location=file:///application.euro.properties
我在主应用程序中遇到这个问题,但正在处理另一个项目。当我单独运行 app.js 中的相关部分时,它会给出相同的错误(就像在其他项目中一样)。我用世博会。还有我的 package.json:
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"@expo/metro-runtime": "~3.1.3",
"@firebase/app": "^0.9.29",
"@firebase/auth": "^1.6.2",
"@firebase/database": "^1.0.3",
"@react-native-async-storage/async-storage": "^1.23.1",
"@react-native-community/masked-view": "^0.1.0",
"@react-native-firebase/app": "^18.7.3",
"@react-native-firebase/auth": "^18.7.3",
"@react-navigation/bottom-tabs": "*",
"@react-navigation/native": "6.0.0",
"@react-navigation/native-stack": "^6.9.12",
"@react-navigation/stack": "^6.3.16",
"@types/react": "~18.2.14",
"expo": "~50.0.14",
"expo-constants": "~14.4.2",
"expo-status-bar": "~1.11.1",
"firebase": "^10.11.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.6",
"react-native-dropdown-picker": "^5.4.6",
"react-native-firebase": "^5.6.0",
"react-native-gesture-handler": "~2.12.0",
"react-native-paper": "*",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-vector-icons": "^10.0.3",
"react-native-web": "~0.19.6",
"react-navigation": "*",
"react-navigation-stack": "*"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"react-native-modal": "^13.0.1"
},
"private": true
}
当我单独运行 app.js 中的相关部分时,它会给出相同的错误(就像在其他项目中一样)。