UISearchController自从学习UISearchDisplayController被弃用之后我就习惯了.但是现在有一个问题,在GitHub中与Chenyuan的SPGooglePlacesAutocomplete分叉库集成.
当我开始输入时,我得到了搜索栏,没有显示任何结果.我还想知道如果UISearchDisplayController如何被弃用,那么Chenyuan Demo会在没有警告或发布弃用方法的情况下运行.
这是我的代码片段,我试图将他的演示转换为UISearchController,请告诉我我哪里出错了.
MainViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
@class SPGooglePlacesAutocompleteQuery;
@interface MainViewController : UIViewController <MKMapViewDelegate, CLLocationManagerDelegate,
UISearchBarDelegate,
UISearchControllerDelegate,
UITableViewDataSource,
UITableViewDelegate>{
NSArray *searchResultPlaces;
SPGooglePlacesAutocompleteQuery *searchQuery;
MKPointAnnotation *selectedPlaceAnnotation;
BOOL shouldBeginEditing;
@private
CGRect _searchTableViewRect;
}
// Search
@property (strong, nonatomic) UISearchDisplayController *searchController;
@property (strong, nonatomic) MKLocalSearch *localSearch;
@property (strong, nonatomic) MKLocalSearchResponse *results;
@end
Run Code Online (Sandbox Code Playgroud)
MainViewController.m片段
// setup Search Controller
-(void) setupSearchController {
// The TableViewController used to display the results …Run Code Online (Sandbox Code Playgroud) objective-c uisearchbar uisearchdisplaycontroller ios uisearchcontroller
使用appcompat库的第21版时,?android:attr/actionBarSize返回48 dips,就好像它是Holo主题而不是Material.事实上,它有点大 - 56逢低.
有没有人找到解决这个问题的方法?
为了不重复自己,我想Subscriber在两个observable之间重用一个变量.你是如何做到这一点的?我下面的当前代码不起作用,因为在订阅者使用一次后,它被取消订阅并且不再有效.如果我new一个Subscriber,而不是重复使用一个变量,我的订阅工作.如果可能的话,我不想两次写相同的代码.
public class HomePresenter extends BasePresenter<HomeView> {
ArticleRepo articleRepo;
@Inject
public HomePresenter(ArticleRepo articleRepo) {
this.articleRepo = articleRepo;
}
@Override
public void onCreate(@Nullable PresenterBundle bundle) {
super.onCreate(bundle);
}
public void onEvent(ArticleCategoryClickedEvent event) {
Timber.v("Adapter position clicked at position: '%d'", event.getAdapterPosition());
view.launchArticleActivity(event.getArticleCategory());
}
public void onEvent(SeabeeOnlineExternalLinkClickedEvent event) {
view.launchExternalLink(event.getSeabeeOnlineExternalLink());
}
public void loadArticleImages() {
articleRepo.getArticleBuckets()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(subscriber);
}
public void refreshData() {
articleRepo.refreshAndSaveArticles()
.flatMap(new Func1<List<ArticleEntity>, Observable<List<ImageArticleCategoryEntity>>>() {
@Override
public Observable<List<ImageArticleCategoryEntity>> call(List<ArticleEntity> articleEntityList) {
return articleRepo.getArticleBuckets(); …Run Code Online (Sandbox Code Playgroud) 我有一个Activity作为Butterknife的目标,我想使用相同Activity的目标作为另一个View我在运行时膨胀.有办法吗?
这是我尝试过的,它不起作用:
@InjectView(R.id.main)
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ButterKnife.inject(this);
createDialog();
}
void createDialog() {
View v = View.inflate(...); // v has a view inside with id R.id.tv
ButterKnife.inject(this, v);
new Dialog(this).setView(v)....show();
}
@OnClick(R.id.tv)
void click() {
// ...
}
Run Code Online (Sandbox Code Playgroud) 因此,只需执行以下操作即可轻松舍入十分之一:
int y;
double x = 2.5;
y = (int) (x+.5);
Run Code Online (Sandbox Code Playgroud)
但是在不使用 的情况下如何四舍五入到百分之几甚至千位呢Math.round()?
我有我的风格
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MYTheme" parent="...">
<item name="android:navigationBarColor">@color/navigationBarColor</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
我知道我可以改变导航栏的颜色
getWindow().setNavigationBarColor(...);
Run Code Online (Sandbox Code Playgroud)
我想用动画改变颜色,当前颜色和新颜色之间的过渡
我一直在包装一个同步库,所以每个执行 IO 的方法都会返回一个Observable. 然而,其中一些方法返回,Observable<Void>因为我只关心它的完成情况。
如何在Observable不发出任何内容之后链接调用?
accountManager.doAuth()
.flatMap(x -> paginator.next())
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(... subscriber stuff ...)
Run Code Online (Sandbox Code Playgroud)
我必须doAuth为每个请求调用它并返回Observable<Void>. 由于它不发出项目,onNext因此永远不会被调用,只有onCompleted.
关于doAuth我只关心它是否完成或给出错误。如果它完成,我希望它paginator.next()被调用,以便我可以在onCompleted/onError/onNext.
到目前为止,我一直在使用flatMap链式调用,当我真正关心以前的 Observables 返回的东西时,它工作得很好。
我有一个与new关键字相关的查询.
1.有什么区别
new Demo().abc();
Run Code Online (Sandbox Code Playgroud)
和
Demo demo=new Demo();
demo.abc();
demo=null;
Run Code Online (Sandbox Code Playgroud)
2.如果我使用第一个然后自动垃圾收集器删除内存?
我的问题是:
如何删除以下对象的内存:
new Demo().abc();
Run Code Online (Sandbox Code Playgroud) android ×4
java ×4
rx-java ×2
butterknife ×1
ios ×1
material ×1
math ×1
new-operator ×1
objective-c ×1
observable ×1
uisearchbar ×1