如何在Android Studio IDE中找到项目中所有未使用的方法和变量?
我在我的swift项目中使用RealmSwift作为数据库。今天,在Xcode-beta版本11中打开我的项目后,我的应用因以下错误而崩溃:
由于未捕获的异常“ RLMException”而终止应用程序,原因:对象“ RealmSwiftPermissionRole”上不存在“主键属性”名称”
我的应用程序可以在以前版本的Xcode(10.2.1)上正常运行。 RealmSwiftPermissionRole是Realm中的一个类,我无权访问。也许在他们的功能更新中,他们修复了此错误,但就目前而言,我进行了很多搜索,但未找到任何解决方案。(我清理了项目,从模拟器中删除了该应用,然后再次运行了该项目,但没有任何改变。)有什么建议吗?
我想创建一个如下图所示的布局:
CoordinatorLayout包含:
我想以这种方式回应滚动事件:
我在使用CollapsingToolbarLayout和TabLayout之间的RecyclerView时遇到问题.我可以在不使用RecyclerView的情况下实现这种布局(我将CollapsingToolbarLayout和TabLayout放在AppBarLayout中,将ViewPager放在它外面,在CoordinatorLayout内).
我的问题:
layout_scrollFlags
和哪个layout_behavior
?似乎AppBarLayout的高度有限.当我将RecyclerView放在AppBarLayout中时,只有RecyclerView的一部分可见,并且TabLayout也会消失.
android android-toolbar android-recyclerview android-coordinatorlayout android-collapsingtoolbarlayout
我试图使用Swift更改自定义选定的TableViewCell的外观.
我需要通过设计师还是以编程方式完成?
我尝试了以下方法:
这是我的代码:
@IBOutlet var tableView: UITableView!
var tableData: [String] = ["One", "Two", "Three", "Four"]
override func viewDidLoad() {
super.viewDidLoad()
// Register custom cell
var nib = UINib(nibName: "vwTblCell", bundle: nil)
tableView.registerNib(nib, forCellReuseIdentifier: "cell")
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.tableData.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as TblCell
cell.lblCarName.text = tableData[indexPath.row]
cell.imgCarName.image = UIImage(named: tableData[indexPath.row])
return cell
}
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { …
Run Code Online (Sandbox Code Playgroud) 我想在Android中将二进制文件上传到服务器.我通过邮递员测试Api方法:
没关系,你可以看到还有另一个选项可以上传文件作为表单数据(键,值):
每个教程(如本教程)都描述了如何上传文件multipart/form-data
:
// create RequestBody instance from file
RequestBody requestFile =
RequestBody.create(MediaType.parse("multipart/form-data"), file);
// MultipartBody.Part is used to send also the actual file name
MultipartBody.Part body =
MultipartBody.Part.createFormData("picture", file.getName(), requestFile);
Run Code Online (Sandbox Code Playgroud)
我搜索了很多,但找不到任何方法上传文件作为二进制与retrofit2.
改造存储库中只有一个问题,询问我如何在改装2.0测试版中发布图像二进制文件?.我用它的解决方案:
API服务:
@POST("trip/{tripId}/media/photos")
Call<MediaPost> postEventPhoto(
@Path("eventId") int tripId,
@Header("Authorization") String accessToken,
@Query("direction") String direction,
@Body RequestBody photo);
Run Code Online (Sandbox Code Playgroud)
呼叫者:
InputStream in = new FileInputStream(new File(media.getPath()));
byte[] buf;
buf = new byte[in.available()];
while (in.read(buf) != -1);
RequestBody requestBody = RequestBody
.create(MediaType.parse("application/octet-stream"), buf);
Call<MediaPost> …
Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用了Design Support Library,想要将CollapsingToolbarLayout的标题从ltr更改为rtl(如下所示).我可以这样做吗?
我检查了这个链接,但找不到任何有用的东西.这个设计的布局尚未准备好,但这是一个类似的xml:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="24dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Info"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cheese_ipsum" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud) 如何禁用我的应用说明的自动翻译?我真的不想用> 70种语言翻译我的应用程序......我的客户只使用英语.
我有 2 个本地 Swift 软件包:LibA
和LibB
. LibA 和 LibB 都依赖于相同的框架(AmazonIVSPlayer
)。我想将两者添加到我的项目中,但出现以下错误:
LibA
和中名为“AmazonIVSPlayer”的多个目标LibB
两个库的 Package.swift 如下所示:
import PackageDescription
let package = Package(
name: "LibA",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "LibA",
targets: ["LibA","AmazonIVSPlayern"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are …
Run Code Online (Sandbox Code Playgroud) 我不知道为什么我不能使用机架攻击宝石这里我做了什么
的Gemfile
gem 'rack-attack'
Run Code Online (Sandbox Code Playgroud)
我安装了宝石
配置/ application.rb中
config.middleware.use Rack::Attack
Run Code Online (Sandbox Code Playgroud)
初始化/机架attack.rb
class Rack::Attack
throttle('logins/ip', :limit => 5, :period => 60.seconds) do |req|
if req.path == '/login' && req.post?
Rails.logger.error("Rack::Attack Too many login attempts from IP: #{req.ip}")
req.ip
end
end
end
Run Code Online (Sandbox Code Playgroud)
的routes.rb
post 'login' => 'index#create'
root 'index#new'
get 'login' => 'index#new'
Run Code Online (Sandbox Code Playgroud)
我正在使用Rails 4.2.3和机架攻击宝石4.3.0
我想知道我想念的是什么
我想在滚动时更改工具栏的alpha,如下所示:
首先,工具栏是透明的,通过滚动到底部,它将越来越可见,最后它将是完全不透明(可见).
我的布局结构是:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax">
....
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
....
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
嵌套的scrollview的内容将从服务器动态更改,所以我不知道它的高度.
我刚刚发现了两种检测scrollY的方法:
addOnScrollChangedListener:
scroll.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
// use scroll.getScrollY()
}
});
Run Code Online (Sandbox Code Playgroud)setOnScrollChangeListener:
scroller.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
}
});
Run Code Online (Sandbox Code Playgroud)但这些方式都不顺利.例如,如果您检查scrollY
(通过使用log.d()
)的值,您将看到如下内容:
scrollY: 58 …
Run Code Online (Sandbox Code Playgroud) android ×6
java ×2
swift ×2
android-collapsingtoolbarlayout ×1
google-play ×1
ios ×1
rackattack ×1
realm ×1
retrofit2 ×1
scroll ×1
scrollview ×1
selected ×1
translation ×1
uitableview ×1
xcode ×1