小编hpi*_*que的帖子

在Android中的FrameLayout中放置视图

我想以编程方式在FrameLayout中添加一个视图,并将其放置在布局中具有特定宽度和高度的特定点.FrameLayout支持这个吗?如果没有,我应该使用中间ViewGroup来实现这一目标吗?

int x; // Can be negative?
int y; // Can be negative?
int width;
int height;
View v = new View(context);
// v.setLayoutParams(?); // What do I put here?
frameLayout.addView(v);
Run Code Online (Sandbox Code Playgroud)

我最初的想法是向FrameLayout添加一个AbsoluteLayout并将视图放在AbsoluteLayout中.不幸的是,我刚刚发现AbsoluteLayout已被弃用.

任何指针都将非常感激.谢谢.

android android-layout android-framelayout

9
推荐指数
2
解决办法
6万
查看次数

白色不是白色

在处理Android中的一些位图时,我注意到视图中使用的白色并不总是与位图上呈现的白色相同.考虑这个截图.

在此输入图像描述

背景白色是从与白色背景颜色的一个看法.

前景"白色"来自从SD卡解码的白色位图,显示在ImageView中.使用RGB_565以下方法解码此位图:

BitmapFactory.Options resample = new BitmapFactory.Options();
resample.inPreferredConfig = Config.RGB_565;
resample.inSampleSize = sampleSize;
return BitmapFactory.decodeFile(filePath, resample);
Run Code Online (Sandbox Code Playgroud)

作为参考,是位图.

为什么这个以及如何解决?

android bitmap

9
推荐指数
1
解决办法
2017
查看次数

iBooks JavaScript资源

iBooks 最近 开始 在epub中支持 JavaScript.这记录在哪里?

是否有任何代码示例可供使用?

javascript epub ibooks ios

9
推荐指数
1
解决办法
3419
查看次数

用户何时向应用内购买付费?

当用户带电或为iOS应用程序内购买?

是在addPaymentpaymentQueue之间:updatedTransactions:接收SKPaymentTransactionStatePurchased,还是在调用finishTransaction之后?或者别的地方?

这是在文档中明确提到的吗?

iphone in-app-purchase ios

9
推荐指数
1
解决办法
435
查看次数

iPhone上的可达性问题:networkStatusForFlags

我正在做一些服务器调用并返回一些json.代码非常简单,它会调用您的身份,然后再进行一次调用以获取更多信息.当我尝试进行第二次调用时,我一直收到Reachability错误.

Reachability Flag Status: -R ------- networkStatusForFlags
Run Code Online (Sandbox Code Playgroud)

不知道为什么会那样做.我在模拟器中运行这个,我在Wifi上,第一个电话通过就好了.

iphone reachability ios

9
推荐指数
2
解决办法
4757
查看次数

在NSDocument中使用NSFileWrapper制作各种文件

我正在制作一个基于文档的Cocoa应用程序,其中文档是动态的文件集合(用户可以添加或删除文件).特别是,保存和打开操作应该尽可能快.

如果我正确理解文档,我应该使用NSFileWrapper并实现fileWrapperOfType:errorreadFromFileWrapper:ofType:error:.但是,我找不到完整的代码示例.我该如何实现以下方法?

#pragma mark - NSDocument

- (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError {
    return nil;
}

- (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)typeName error:(NSError **)outError {
    return YES;
}

#pragma mark - My methods

- (void) addFileToDocumentFromURL:(NSURL*)fileURL {
    // Add a file to the document given the file URL
}

- (void) removeFileFromDocumentWithName:(NSString*)name {
    // Remove a file from the document given the file name
}
Run Code Online (Sandbox Code Playgroud)

cocoa nsdocument nsfilewrapper

9
推荐指数
1
解决办法
2893
查看次数

NSFileWrapper有时会返回nil

我正在使用NSFileWrapper我的包文件.有时,当我请求包中的文件数据时,我得到了nil.

这是我查询包内文件数据的方法:

- (NSData*) dataOfFile(NSString*)filename {
    NSFileWrapper *fileWrapper = [self.documentFileWrapper.fileWrappers objectForKey:filename];
    return fileWrapper.regularFileContents; // This returns nil sometimes. Why?
}
Run Code Online (Sandbox Code Playgroud)

对于某些文件(并非所有文件),此方法最终开始返回nil.可悲的是,我没有设法一致地重现这个问题.

如果它有帮助,这就是我打开包的方式:

- (BOOL) readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)typeName error:(NSError *__autoreleasing *)outError {
    self.documentFileWrapper = fileWrapper;
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

这是我更新包内文件数据的方法:

- (void) updateFile:(NSString*)filename withData:(NSData*)data {
    SBFileWrapper *fileWrapper = [self.documentFileWrapper.fileWrappers objectForKey:filename];
    if (fileWrapper) {
        [self.documentFileWrapper removeFileWrapper:fileWrapper];
    }
    NSFileWrapper *fileWrapper = [[SBFileWrapper alloc] initRegularFileWithContents:data ];
    fileWrapper.preferredFilename = filename;
    [self.documentFileWrapper addFileWrapper:fileWrapper];
}
Run Code Online (Sandbox Code Playgroud)

这是我保存包的方式:

- (NSFileWrapper*) fileWrapperOfType:(NSString *)typeName error:(NSError *__autoreleasing *)outError …
Run Code Online (Sandbox Code Playgroud)

macos cocoa nsdocument nsfilewrapper

9
推荐指数
1
解决办法
1082
查看次数

transitionFromViewController只是iOS中的一种便捷方法吗?

我不确定我明白究竟transitionFromViewController:toViewController:duration:options:animation:completion:是什么.这只是一种方便的方法吗?

例如,这样做有什么区别......

[self transitionFromViewController:fromViewController
                  toViewController:toViewController
                          duration:0.25
                           options:UIViewAnimationOptionCurveEaseInOut
                        animations:^{
                            fromViewController.view.alpha = 0;
                            toViewController.view.alpha = 1;
                        } completion:^(BOOL finished) {
                            [fromViewController removeFromParentViewController];
                            [toViewController didMoveToParentViewController:self];
                        }];
Run Code Online (Sandbox Code Playgroud)

...还有这个?

[self.view addSubview:toViewController.view];
[UIView animateWithDuration:0.25
                      delay:0
                    options:UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     fromViewController.view.alpha = 0;
                     toViewController.view.alpha = 1;
                 } completion:^(BOOL finished){
                     [fromViewController.view removeFromSuperview];
                     [fromViewController removeFromParentViewController];
                     [toViewController didMoveToParentViewController:self];
                 }];
Run Code Online (Sandbox Code Playgroud)

我问的原因是在某些情况下我需要将子控制器视图添加到容器控制器视图的特定子视图中.使用transitionFromViewController:toViewController:duration:options:animation:completion:不给我这个选项.

iphone uiviewcontroller ios ios5

9
推荐指数
1
解决办法
7671
查看次数

Page count of UICollectionView with paging in iOS

Consider a UICollectionView with flow layout and paging enabled (by setting pagingEnabled to YES).

What would be the simplest way of obtaining the total number of pages?

And where would be the most appropriate place to update the total number of pages (given that it might change if items are added/deleted, the size of the collection view changes or the layout changes)?

iphone uipagecontrol ios ios6 uicollectionview

9
推荐指数
2
解决办法
6316
查看次数

开源移动应用程序

我正在考虑将现有的移动应用程序变成一个开源项目.它有Android和iPhone版本.

虽然我使用了开源项目并提交了功能请求和错误报告,但我从未创建过一个开源项目,也没有为现有项目提供补丁.

在打开项目源之前,我应该考虑哪些最重要的事情?您建议采用哪些具体步骤来开源移动应用?

iphone mobile android open-source

8
推荐指数
1
解决办法
300
查看次数