我正在开发一个有两个设置Dev和Live的应用程序.有没有办法根据应用程序是实时的还是仍处于开发状态来区分应该使用哪些设置,或者我必须在它们上线之前更改整个设置文件.
如果你不确定的地方问我,我不确定如何把它放进去.
是否可以为UITableView添加边框样式?
不仅仅是bordercolor和borderwidth.
例如带凹槽的边框样式?
我正在尝试将NSColor转换为RGB,但它似乎给出了一个完全不正确的结果:
NSColor *testColor = [NSColor colorWithCalibratedWhite:0.65 alpha:1.0];
const CGFloat* components = CGColorGetComponents(testColor.CGColor);
NSLog(@"Red: %f", components[0]);
NSLog(@"Green: %f", components[1]);
NSLog(@"Blue: %f", components[2]);
NSLog(@"Alpha: %f", CGColorGetAlpha(testColor.CGColor));
Run Code Online (Sandbox Code Playgroud)
我回来了:红色= 0.65 - 绿色= 1.0 - 蓝色= 0.0而alpha是1.0 - 这导致了完全不同的颜色.(它应该是灰色的,现在它是绿色的).
难道我做错了什么?
我只想知道如何将数字1,2或3转换为第一,第二或第三?任何帮助,将不胜感激.
我想将导航栏的背景颜色更改为纯绿色.
规则:我不能乱用AppDelegate :)
我试过了:
//It's green but it's translucent
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]];
//It's white, first line has no effect
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]];
[self.navigationController.navigationBar setTranslucent:NO];
//Same result as case 1
[self.navigationController.navigationBar setAlpha:0.0f];
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]];
//Too dark
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]];
//Only affects the back button's color:
[self.navigationController.navigationBar setTintColor:[UIColor greenColor]];
Run Code Online (Sandbox Code Playgroud)
那么任何想法?
谢谢,没看到有barTintColor和TintColor.接受最早的答案.
在 iOS 8 中,他们添加了设备方向检测UIInterfaceOrientationUnknown(在此处查看预发布文档)
UIInterfaceOrientationUnknown
无法确定设备的方向。
在 iOS 8.0 及更高版本中可用。
typedef enum : NSInteger {
UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown,
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
} UIInterfaceOrientation;
Run Code Online (Sandbox Code Playgroud)
我看到它的方式,只有4种方式的装置可能可能去过Portrait,UpsideDown,LandscapeRight和LandscapeLeft。那么在什么情况下你会遇到未知的设备方向?
我不想使用,NSUserDefaults因为我被告知它不是保存用户名和密码的好方法.
所以我打算使用钥匙扣,但我以前从未使用过钥匙扣.有人可以只是给一个快速的例子,或指出我的例子方向?谢谢.
在Xcode 4.5中编译旧项目时,会出现警告:
不使用ARC时,'__ bridge'强制转换无效
什么是摆脱这种警告的正确方法,这样代码在ARC和非ARC项目中都能很好地运行?
我UILocalNotification用来提醒用户,如果应用程序没有运行,MPMusicPlayerController播放iPod音乐和MPMoviePlayerController播放无线电流网址.
根据Apple文档:如果iPhone被锁定而设备接收到本地通知,那么它将播放30秒的声音,当用户滑动滑块时,它将占用应用程序前景并发生两种情况
如果App没有运行则调用方法
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
如果App已经运行,则调用方法 -
(void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notify
我可以用这些方法完成我的任务.
问题:当iPhone被锁定并收到本地通知且应用程序在前台运行时,我需要我的应用程序能够播放我的声音(可能是iPod音乐或流媒体网址,但不是本地通知声音,持续30秒).
参考应用程序:"闹钟高清"和应用程序商店中也可用的其他应用程序正常工作,但这些应用程序在后台运行时无法播放警报(我无法理解为什么???)
我还尝试了 如何防止iphone从深度睡眠:
通过定期播放无声音乐来防止iPhone深度睡眠,但如何通知应用通知已收到,所以开始播放"实际音乐"?以及如何开始播放新音乐?
这真让我抓狂.
我在foo.h文件中有一个C++类声明.
class foo // error marks are here
{
};
Run Code Online (Sandbox Code Playgroud)
当我#include/#import在我的fooUser.mm文件中的这个标题时,它编译.当我#include/#import在我的fooUser.h文件中执行它时,它没有,并且编译器错误是.
Unknown type name 'class'; did you mean 'Class'?
Excpected ';' after top level declarator.
Run Code Online (Sandbox Code Playgroud)
我正在使用XCode 4.2,LLVM编译器3.0,......这应该是重要的.