我正在[ 50%] Building CXX object CMakeFiles/test13.dir/main.cpp.o
In file included from /usr/include/c++/5/set:60:0,
from /home/roaddb/Desktop/ReviewCPPBook/Video/test13/main.cpp:2:
/usr/include/c++/5/bits/stl_tree.h: In instantiation of ‘std::pair<std::_Rb_tree_const_iterator<_Val>, std::_Rb_tree_const_iterator<_Val> > std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::equal_range(const _Key&) const [with _Key = A; _Val = A; _KeyOfValue = std::_Identity<A>; _Compare = MyLess; _Alloc = std::allocator<A>]’:
/usr/include/c++/5/bits/stl_tree.h:2320:61: required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::count(const _Key&) const [with _Key = A; _Val = A; _KeyOfValue = std::_Identity<A>; _Compare = MyLess; _Alloc = std::allocator<A>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type = long unsigned int]’
/usr/include/c++/5/bits/stl_multiset.h:650:30: required from ‘std::multiset<_Key, _Compare, _Alloc>::size_type std::multiset<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = A; _Compare = MyLess; _Alloc = std::allocator<A>; std::multiset<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::multiset<_Key, _Compare, _Alloc>::key_type = A]’
/home/roaddb/Desktop/ReviewCPPBook/Video/test13/main.cpp:78:45: required from here
/usr/include/c++/5/bits/stl_tree.h:1727:4: error: no match for call to ‘(const MyLess) (const A&, const A&)’
if (_M_impl._M_key_compare(_S_key(__x), __k))
^
/home/roaddb/Desktop/ReviewCPPBook/Video/test13/main.cpp:38:10: note: candidate: bool MyLess::operator()(const A&, const A&) <near match>
bool operator()(const A& a1, const A&a2)
^
/home/roaddb/Desktop/ReviewCPPBook/Video/test13/main.cpp:38:10: note: passing ‘const MyLess*’ as ‘this’ argument discards qualifiers
In file included from /usr/include/c++/5/set:60:0,
from /home/roaddb/Desktop/ReviewCPPBook/Video/test13/main.cpp:2:
/usr/include/c++/5/bits/stl_tree.h:1729:9: error: no match for call to ‘(const MyLess) (const A&, const A&)’
else if (_M_impl._M_key_compare(__k, _S_key(__x)))
^
/home/roaddb/Desktop/ReviewCPPBook/Video/test13/main.cpp:38:10: note: candidate: bool MyLess::operator()(const A&, const A&) <near match>
bool operator()(const A& a1, const A&a2)
^
/home/roaddb/Desktop/ReviewCPPBook/Video/test13/main.cpp:38:10: note: passing ‘const MyLess*’ as ‘this’ argument discards qualifiers
上工作,但是我想显示一个以正常方式占据整个屏幕和其余内容的图像。
在垂直模式下,它可以正常工作,但在水平模式下,部分内容会咬住缺口。
我该如何纠正?
我的代码如下:
TabView
ContentView.swift
struct ContentView: View {
@State private var selection = 0
var body: some View {
TabView(selection: $selection){
Home()
.tabItem {
VStack {
Image("first")
Text("First")
}
}
.tag(0)
Text("Second View")
.font(.title)
.tabItem {
VStack {
Image("second")
Text("Second")
}
}
.tag(1)
} .edgesIgnoringSafeArea(.top)
}
}
Home.swift