小编0x8*_*00d的帖子

从RGB到HSV的UIColor转换,将亮度设置为UIColor

在我的应用程序中,我试图用不同的颜色绘制.我有自己的颜色选择器,但我想添加到此选择器滑块以获得颜色亮度.对于底层测试:我选择一种在视图中作为背景颜色显示的颜色,并且我希望添加滑块,它将从1滑动到0并改变颜色的亮度并在窗口中显示颜色.因此,我想询问是否有任何可能的转换方法.

在我的项目中我用这个:

CGContextSetRGBStrokeColor(current, R, G, B, A);
Run Code Online (Sandbox Code Playgroud)

所以当我滑动滑块时,我需要更改颜色的亮度,因此我需要将我的UIColor- 表示为RGB 转换为HSV而不是返回RGB再次使用它.

是否存在任何RGB到HSV转换算法,或者在iOS 5或Xcode4中是否存在?

uicolor xcode4 ios5

2
推荐指数
1
解决办法
3895
查看次数

iOS多任务处理中的启动画面

iOS应用程序在什么情况下会显示启动画面,即默认图像(App Launch除外)?

我正在强制视图控制器仅支持横向模式

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
}
Run Code Online (Sandbox Code Playgroud)

如果用户在此视图中并将应用程序推送到后台然后将其重新启动,则应用程序会显示启动画面<1秒.

在另一种情况下,如果我打开UIAlertView,将应用程序推送到后台并将其重新启动,应用程序会显示启动画面一秒钟.

我们是否在UIKit文档中对此有任何解释,在iOS中的多任务处理将在短时间内向用户显示启动画面.

谢谢.

通过示例更新了问题:

如果我们转到设置应用程序(第一次) - > iTunes和应用程序商店 - >点击AppleId:行 - >您将看到一个alertView - > Push Home按钮,它将应用程序带到后台 - >将应用程序带回起来.您将看到设置应用程序的Default.png <1秒,然后您将看到之前的屏幕.

cocoa-touch uikit ios4 ios ios5

2
推荐指数
1
解决办法
1037
查看次数

目标C:我正在尝试保存包含基元和对象的NSDictionary,但是一旦我尝试添加自定义对象就会发生错误

所以我把这个自定义对象称为'Box',它正在抛出那个错误.我的NSDictionary里面是......

box = [[Box alloc] initWithHeight:20 height:40];    
wrap.dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:numberInt, kInt, numberShort, kShort, numberLong, kLong, numberFloat, kFloat, numberDouble, kDouble, numberBool, kBool, nsString, kString, nsDate, kDate, box, @"keybox", nil];
Run Code Online (Sandbox Code Playgroud)

请注意我在顶部创建的框对象,并在最后添加到NSDictionary中.在盒子不在那里之前,一切正常,但是当我添加自定义对象'Box'时,它无法再保存.

- (void) saveDataToDisk:(NSMutableDictionary *)dictionaryForDisk 
{
    NSMutableData *data = [NSMutableData data];
    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]initForWritingWithMutableData:data];
    //Encode 
    [archiver setOutputFormat:NSPropertyListBinaryFormat_v1_0];
    [archiver encodeObject:dictionaryForDisk forKey:@"Dictionary_Key"];

    [archiver finishEncoding];
    [data writeToFile:[self pathForDataFile] atomically:YES];
}

- (NSString *) pathForDataFile {
    NSArray*    documentDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
    NSString* path = nil;
    if (documentDir) 
    {
        path = [documentDir objectAtIndex:0];    
    } …
Run Code Online (Sandbox Code Playgroud)

encoding objective-c save nsdictionary nscoding

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

无法识别的选择器发送到实例

我遇到了一个问题,即使在读完几个帖子后我也听不懂

这是我得到的错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0x576f8f0'
Run Code Online (Sandbox Code Playgroud)

这是代码:

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *filePath = [[self documentsPath] stringByAppendingPathComponent:@""];

    NSFileManager *imagesFileManager = [NSFileManager defaultManager];

    imagesArr = [[imagesFileManager contentsOfDirectoryAtPath:filePath error:nil]filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.jpg'"]];

    arryList = [[NSMutableArray alloc] initWithArray:[imagesArr copy]];//display text
    imagesList = [[NSMutableArray alloc]init];//display image

    NSString *docPath = [self documentsPath];

    for (NSString *anImagePath in arryList) {
        anImagePath = [NSString stringWithFormat:@"%@/%@",docPath,anImagePath];
        UIImage *image = [UIImage imageWithContentsOfFile:anImagePath];
        if (image)
            [imagesList addObject:image]; …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c uiimage

0
推荐指数
1
解决办法
2510
查看次数

NSTextField,难以添加吗?我认为

我在Xcode 4.2中制作了小游戏.

在我玩完所有游戏关卡后,将出现高分输入窗口.我想在这里添加NSTextField,因此玩家可以通过键盘输入他的名字.

我添加NSTextField到OpenGlView,但我无法在屏幕上看到它.这有什么关系?我也尝试添加子视图和添加NSTextField,但我得到相同的结果.

Xcode4.2,模拟器是My Mac - 32bit.

    NSView *view = [[NSView alloc] initWithFrame:NSRectFromCGRect(CGRectMake(0, 0, 480, 320))];

    [[[CCDirector sharedDirector] openGLView] addSubview:view];

    [[view layer] setZPosition:1];
//        
    NSTextField *textField = [[NSTextField alloc] initWithFrame:NSRectFromCGRect(CGRectMake(0, 0, 100, 40))];
    [view addSubview:textField];
Run Code Online (Sandbox Code Playgroud)

xcode objective-c nstextfield cocos2d-iphone xcode4.2

0
推荐指数
1
解决办法
482
查看次数

NSURLConnection无法启动

我正在编写基于位置的应用程序,通过使用NSURLConnection获取当前/其他地方的API获取天气信息.我第一次发送请求它的工作成功.但是下次我想将信息引用到同一个地方时它不起作用,而NSURLConnection不会调用任何委托方法.

这是我的代码:

NSString *strs=[@"http://www.earthtools.org/timezone-1.1/" stringByAppendingString:[NSString stringWithFormat:@"%@/%@",place.latitude,place.longitude]];

NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:strs]];

self.reqTimeZone=[NSURLConnection connectionWithRequest:request delegate:self];
[self.reqTimeZone start]; 
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c

0
推荐指数
1
解决办法
998
查看次数

为什么它会回归真实?

我似乎无法找到问题.

// Check that someone from this IP didn't register a user within the last hour (DoS prevention)
$query = mysqli_query($dbc, "SELECT COUNT(id) FROM accounts WHERE registration_ip = '".$_SERVER['REMOTE_ADDR']."'  AND registered > ".(time() - 3600));

if (mysqli_num_rows($query) > 0) {
    $errors[] = 'To prevent registration flooding, at least an hour has to pass between registrations from the same IP. Sorry for the inconvenience.';
}
Run Code Online (Sandbox Code Playgroud)

无论如何,为什么总是这样?即使帐户表是空的.

php

0
推荐指数
1
解决办法
98
查看次数