我想尝试Android支持库23.2中引入的BottomSheetDialog,但它似乎无法正常工作.以下是该文档所说的内容:
当BottomSheetBehavior捕获持久的底部工作表案例时,此版本还提供了BottomSheetDialog和BottomSheetDialogFragment来填充模态底部工作表用例.只需将AppCompatDialog或AppCompatDialogFragment替换为它们的底部工作表,就可以将对话框设置为底部工作表."
所以我把我AppCompatDialog
改为BottomSheetDialog
:
package my.package.ui.dialog;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.BottomSheetDialog;
import my.package.R;
public class AccountActionsDialog extends BottomSheetDialog {
public AccountActionsDialog(Context context) {
super(context);
if (context instanceof Activity) {
setOwnerActivity((Activity) context);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutInflater().inflate(R.layout.dialog_account_actions, null));
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
android:padding="16dp"
android:text="Delete account"
android:textColor="#ffffff" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
然后我在我的Activity中使用以下代码:
new AccountActionsDialog(this).show();
Run Code Online (Sandbox Code Playgroud)
我的屏幕变暗,但我的对话框内容不可见.有什么可能遗漏的想法?当我使用AppCompatDialog时,它工作正常.
prevent
Google Chrome 是否可以登录XMLHttpRequests
?
我不是指disable
在控制台上的功能,但我的代码是not
让谷歌Chrome显示URL
给用户.
[更新]我正在提供奖励以了解如何抑制消息
XHR Loaded (controllers.js - 200 OK - 12.728999950923026ms - 103.516KB)
Run Code Online (Sandbox Code Playgroud) 我的问题如下:我有一个单例类型的对象(我正在使用ARC),在实现文件中有这个代码
+(id)sharedInstance
{
static DataManager *sharedInstance;
if (sharedInstance == nil) {
sharedInstance = [[DataManager alloc] init];
}
return sharedInstance;
}
+(NSManagedObjectContext *)getManagedContext
{
AppDelegate *applicationDelegate =(AppDelegate *)[[UIApplication sharedApplication] delegate];
return [applicationDelegate managedObjectContext];
}
+(void)saveContext:(NSManagedObjectContext *)context
{
NSError *error;
if (![context save:&error]) {
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
}
}
#pragma mark - Data management methods
+(void)addPersonWithName:(NSString *)name andPicture:(UIImage *)picture
{
NSManagedObjectContext *context = [self getManagedContext]; //no problem here
//some code
[self saveContex:context]; // no known class method for selector …
Run Code Online (Sandbox Code Playgroud) 我经历了许多与内存管理,ARC,内存管理技术相关的帖子,autoreleasepool
并使用仪器工具来检测哪些代码导致了内存警告,但在我的情况下,我无法找出确切的原因.
您必须了解的有关该应用的基本信息:
我们开发了一款iPad应用程序.在某些情况下,我们必须使用超过2000个图像,所以当我的应用程序启动时,我们不想显示它们占位符图像(客户端要求).为了实现这一点,我们使用SDWebImage
,将图像存储在磁盘上,然后我们从那里加载图像.
我有很多核心动画,如"Gennie效果",显示弹出窗口和许多其他核心动画.
我们在项目中使用了ARC,我们发现由于内存警告应用程序随机崩溃.
我们使用了仪器 "分配"来查找脏内存.
以前我们分析日志,我们SDWebImage
在DISK中存储图像,它解决了经常崩溃的应用程序,但仍然由于内存警告应用程序崩溃.
当我们深入研究时,我们发现"匿名虚拟机"在iPad中的任何屏幕切换时都会继续进行内存并且不会释放内存.
以下是我们在设备上分析应用程序的截图.
任何人请建议提示或编码技术或任何我们可以减少内存负载和解决内存警告的想法.
任何帮助将不胜感激.谢谢.
memory-management objective-c ipad ios automatic-ref-counting
这是我第一次在这里发帖.所以请耐心等待.我正在使用Webkit在Webview中显示来自YouTube的一些内容.
正如我之前所说,我使用WebView显示来自YouTube的内容.但是,我遇到了一些我在下面概述的问题
尝试使用YouTube的全屏操作时,会发生以下情况:
观察:
我做错了什么:当我尝试播放视频时,在YouTube网站上使用Flash播放器时一切正常.此外,当我点击YouTube视频的全屏按钮时,窗口确实以全屏显示.但是,它不是完全全屏(菜单栏仍然可见)
我的期望:我期望视频完全进入全屏.在Safari中一切正常.
观察:
我做了什么:当我尝试播放视频时,在YouTube网站上使用HTML5播放器时一切正常.但是,当我点击YouTube视频的全屏按钮时,没有任何反应.
我的期望:我预计视频会全屏进入.我确实注意到在做这个时,Safari一切都按预期工作.
有人可以帮我解决这个问题吗?我到处搜索,一无所获.
以下是我用来说明此问题的测试应用示例:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
NSURL *url = [NSURL URLWithString:@"https://www.youtube.com"];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[[[self webView] mainFrame] loadRequest:urlRequest];
[self.window setContentView:self.webView];
//When YES WebView will use Flash if available, else will use HTML5
BOOL shouldUsePlugin = YES;
if (shouldUsePlugin == YES) {
[[[self webView] preferences] setPlugInsEnabled:YES];
//Test 1: Using Flash …
Run Code Online (Sandbox Code Playgroud) 我的应用程序用于NSURLConnection
与服务器通信.我们使用https进行通信.为了在一个地方处理来自所有请求的身份验证,我使用NSURLProtocol
并处理该类中的委托中的身份验证.现在我决定用NSURLSession
而不是NSURLConnection
.我想做得到NSURLProtocol
的工作与NSURLSession
我创建了一个任务,并使用NSURLProtocol
通过
NSMutableURLRequest *sampleRequest = [[NSMutableURLRequest alloc]initWithURL:someURL];
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.protocolClasses = @[[CustomHTTPSProtocol class]];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
NSURLSessionDataTask *task = [session dataTaskWithRequest:checkInInfoRequest];
[task resume];
Run Code Online (Sandbox Code Playgroud)
CustomHTTPSProtocol
这是我的NSURLProtocol
班级看起来像这样
static NSString * const CustomHTTPSProtocolHandledKey = @"CustomHTTPSProtocolHandledKey";
@interface CustomHTTPSProtocol () <NSURLSessionDataDelegate,NSURLSessionTaskDelegate,NSURLSessionDelegate>
@property (nonatomic, strong) NSURLSessionDataTask *connection;
@property (nonatomic, strong) NSMutableData *mutableData;
@end
@implementation CustomHTTPSProtocol
+ (BOOL)canInitWithRequest:(NSURLRequest *)request {
if ([NSURLProtocol propertyForKey:CustomHTTPSProtocolHandledKey inRequest:request]) { …
Run Code Online (Sandbox Code Playgroud) 使用gradle build
command从命令行构建时,属性字段已正确替换,但是,使用时不是IntelliJ IDEA IDE
。
输入代码 build.gradle
ext {
port = 8086
}
processResources {
filesMatching('application.properties') {
expand(project.properties)
}
}
Run Code Online (Sandbox Code Playgroud)
输入代码 application.properties
server.port = ${port}
Run Code Online (Sandbox Code Playgroud) 我可以做以下任何一项吗?他们会正确锁定/解锁同一个物体吗?为什么或者为什么不?假设有许多相同的线程使用全局变量"obj",它在所有线程启动之前被初始化.
1.
@synchronized(obj) {
[obj release];
obj = nil;
}
Run Code Online (Sandbox Code Playgroud)
2.
@synchronized(obj) {
obj = [[NSObject new] autorelease];
}
Run Code Online (Sandbox Code Playgroud) 当我尝试将一个对象从一个对象拖放NSOutlineView
到另一个对象时,它通常可以工作,但有时它会因某些对象而失败.我收到消息:
*** Canceling drag because exception 'NSInvalidArgumentException' (reason '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]') was raised during a dragging session
Run Code Online (Sandbox Code Playgroud)
我发现当我第一次将项目拖动到同一个表的另一行(不释放它)时会发生这种情况,然后拖动到新表.
这是我在拖动过程中可以检查的最后一个函数中draggedItems的内容:
- (id <NSPasteboardWriting>)outlineView:(NSOutlineView *)outlineView pasteboardWriterForItem:(id)item
{
CBCollectible *collectible = [item representedObject];
return [[collectible UniqueID] stringValue];
}
- (void)outlineView:(NSOutlineView *)outlineView
draggingSession:(NSDraggingSession *)session
endedAtPoint:(NSPoint)screenPoint
operation:(NSDragOperation)operation
{
//CBDebug(@"end draggingLeaderIndex %i", session.draggingLeaderIndex);
}
- (void)outlineView:(NSOutlineView *)outlineView
draggingSession:(NSDraggingSession *)session
willBeginAtPoint:(NSPoint)screenPoint
forItems:(NSArray *)draggedItems
{
FreeAndNil(theDraggedItems);
theDraggedItems = [[NSArray alloc] initWithArray:draggedItems];
[session.draggingPasteboard setData:[NSData data] forType:MAIN_VIEW_PASTEBOARD_TYPE];
}
- (void)outlineView:(NSOutlineView *)outlineView …
Run Code Online (Sandbox Code Playgroud)