是否可以在Gradle中声明一个可用于Java的变量?基本上我想在build.gradle中声明一些变量,然后在构建时获取它(显然).就像C/C++中的预处理器宏一样......
宣言的一个例子就是那样......:
android {
debug {
A_VAR_RETRIEVABLE_IN_JAVA = 42
}
release {
A_VAR_RETRIEVABLE_IN_JAVA = 42+52
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法做那样的事情?
我一直在尝试获取资产文件的URI路径.
uri = Uri.fromFile(new File("//assets/mydemo.txt"));
Run Code Online (Sandbox Code Playgroud)
当我检查文件是否存在时,我看到该文件不存在
File f = new File(filepath);
if (f.exists() == true) {
Log.e(TAG, "Valid :" + filepath);
} else {
Log.e(TAG, "InValid :" + filepath);
}
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何提及资产文件夹中存在的文件的绝对路径
我正在处理推送通知.我编写了以下代码来获取设备令牌.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
NSLog(@"Registering for push notifications...");
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
return YES;
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(@"This is device token%@", deviceToken);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"Error %@",err);
}
Run Code Online (Sandbox Code Playgroud)
我能够在设备上成功运行应用程序,但无法在控制台上获取设备ID.
我对认证和配置文件没有任何问题.
iphone push-notification apple-push-notifications ios appdelegate
我有一个ManagedObject class
,而且班上的一个成员是一个NSDate
.我想显示未设置日期的类的所有对象.我尝试使用这样的谓词:
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"(date = NIL)"];
Run Code Online (Sandbox Code Playgroud)
但我仍然得到date
设置的对象.为此设置谓词的正确方法是什么?
标题说明了一切.如果我想在Android Studio的代码文件中添加版权注释?当然,我在偏好/版权中找到版权设置,但我无法使其正常工作......当我创建新的Java文件时,版权就不会出现.
这是Android Studio的错误还是我错过了什么?
这是我如何将纹理放在我的对象上:
_obj = (CC3MeshNode *)[_world getNodeNamed:@"s0"];
_obj.material.texture = [CC3Texture textureFromFile:@"objTextureLayout.png"];
Run Code Online (Sandbox Code Playgroud)
我的对象是从3DMAX加载的,我不明白为什么我的纹理坐标(来自3DMax)丢失了...
另一个问题,我不明白为什么我的法线被翻转在一个简单的多边形上.我有什么可以忘记的?
有什么建议吗?我可以发布一些屏幕截图甚至是带有纹理的模型,以便最好地理解任何可以帮助我的人.
我是码头工人的新手.我已经扩展了PostgreSQL映像,并且能够在运行映像时创建新的数据库实例.我需要在shell脚本中创建表,该脚本将执行.sql文件.在运行PostgreSQL映像时,它说服务器没有启动?我们如何只在PostgreSQL服务器在docker容器中启动后才能执行脚本?
Dockerfile:
FROM postgres:9.3
ENV POSTGRES_USER docker
ENV POSTGRES_PASSWORD docker
ENV POSTGRES_DB docker
RUN apt-get update && apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
ADD initialize.sh /home/MM0312/docker-entrypoint-initdb.d/initialize.sh
CMD ["/home/MM0312/docker-entrypoint-initdb.d/initialize.sh"]
Run Code Online (Sandbox Code Playgroud)
initialize.sh
#!/bin/bash
set -e
set -x
echo "******PostgreSQL initialisation******"
gosu docker psql -h localhost -p 5432 -U docker -d $docker -a -f createDatabase.sql
Run Code Online (Sandbox Code Playgroud)
createDatabase.sql文件
CREATE TABLE web_origins (
client_id character varying(36) NOT NULL,
value character varying(255)
);
Run Code Online (Sandbox Code Playgroud) 我会知道如何检索NSArray
使用a 的索引NSPredicate
?
NSArray *array = [NSArray arrayWithObjects:
@"New-York City",
@"Washington DC",
@"Los Angeles",
@"Detroit",
nil];
Run Code Online (Sandbox Code Playgroud)
我应该使用哪种方法来获得"Los Angles"的索引,只给出一个NSString
NB:@"Los An"
或者@"geles"
应该返回相同的索引.
我知道存储全局常量的最佳实践是什么,这些常量可以在编译时随环境(debug,preprod,prod,release等)而改变.
在iOS中,我曾经将所有全局常量保留在头文件中并使用预处理器宏进行更改,请参阅以下答案:
在iOS应用程序中存储全局常量的位置?
我应该为Android使用什么解决方案?
我一直在尝试新的iOS 7自定义转换API,并查看了我能找到的所有教程/文档,但我似乎无法根据我的具体情况来计算这些内容.
基本上我正在尝试实现的是一个视图上的UIPanGestureRecognizer,我将向上滑动并转换到VC,其视图将从底部向上滑动,而当我将手指向上移动时当前视图将向上滑动.
没有交互转换我没有遇到任何问题,但是一旦我实现了交互(平移手势),我似乎无法完成转换.
这是来自VC的相关代码,它符合出售动画控制器所需的UIViewControllerTransitionDelegate:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"Swipe"]) {
NSLog(@"PREPARE FOR SEGUE METHOD CALLED");
UIViewController *toVC = segue.destinationViewController;
[interactionController wireToViewController:toVC];
toVC.transitioningDelegate = self;
toVC.modalPresentationStyle = UIModalPresentationCustom;
}
}
#pragma mark UIViewControllerTransition Delegate Methods
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController: (UIViewController *)presented presentingController: (UIViewController *)presenting sourceController:(UIViewController *)source {
NSLog(@"PRESENTING ANIMATION CONTROLLER CALLED");
SwipeDownPresentationAnimationController *transitionController = [SwipeDownPresentationAnimationController new];
return transitionController;
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
NSLog(@"DISMISS ANIMATION CONTROLLER CALLED");
DismissAnimatorViewController *transitionController = [DismissAnimatorViewController new];
return transitionController;
}
- (id …
Run Code Online (Sandbox Code Playgroud) iphone objective-c uiviewcontroller ios uipangesturerecognizer
iphone ×4
objective-c ×4
android ×3
ios ×3
java ×2
appdelegate ×1
assets ×1
cocos3d ×1
constants ×1
dockerfile ×1
filepath ×1
gradle ×1
ipad ×1
licensing ×1
nsarray ×1
nspredicate ×1
postgresql ×1
textures ×1
uri ×1