小编Wil*_*ith的帖子

什么触发仪器中的"彩色复制图像"和"颜色命中绿色和错过红色"?

" 仪器用户指南"有这样的说法:

  • 彩色复印图像.将青色叠加层放在Core Animation复制的图像上.

但这并不能解释为什么要复制图像.从一个复制的图像到另一个复制图像似乎没有明显的模式,尽管它是规则的和可重复的.

该文档目前甚至没有提到颜色点击绿色和红色小姐,但我想它可能有一些做CALayershouldRasterize财产.

有任何想法吗?

core-animation instruments ios

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

本地通知"didReceiveLocalNotification"调用两次

我使用以下方式处理本地通知:

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif
Run Code Online (Sandbox Code Playgroud)

并安排本地通知:

- (void)scheduleNotificationWithInterval:(int)minutesBefore {
    UILocalNotification *localNotif = [[UILocalNotification alloc] init];

    if (localNotif == nil)
        return;

    NSDate *fireDate = [NSDate date];
    localNotif.fireDate = [fireDate dateByAddingTimeInterval:minutesBefore*60];
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    localNotif.repeatInterval = kCFCalendarUnitMinute;
    localNotif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"LocalEvent notification in %i minutes.", nil),minutesBefore];
    localNotif.alertAction = NSLocalizedString(@"View Details", nil);
    localNotif.applicationIconBadgeNumber = 1;

    NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"This is dict, you can pass info for your notification",@"info",nil];
    localNotif.userInfo = infoDict;

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

    [localNotif release];
    NSLog(@"Event scheduled");
}
Run Code Online (Sandbox Code Playgroud)

当我收到通知时, …

iphone notifications ios uilocalnotification

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

支持iOS 6.0中针对不同视图控制器的不同方向

我在我的应用程序中使用自定义拆分视图控制器,带有主控制器和详细控制器.

- (id)initWithMasterController:(UIViewController*)aMasterController
            detailedController:(UIViewController*)aDetailedController;
Run Code Online (Sandbox Code Playgroud)

为主控制器和细节控制器提供的控制器是UINavigationController.

作为我的应用程序的一部分,有两种可能的方向处理案例:

  1. 当在主控制器和细节控制器中使用六个控制器组合时,应用程序支持所有方向.
  2. 仅在详细信息控制器上有StudentDetailsViewController时,只能支持两种可能的方向.(景观)

当设备的方向发生变化时,iOS 6.0以下的版本会发生以下情况

  1. -shouldAutorotateToInterfaceOrientation:方法被调用.该方法的实现如下:在运行时,我将请求转发给主控制器并使用相同的调用详细说明控制器.

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {   
        BOOL res = [masterController shouldAutorotateToInterfaceOrientation:interfaceOrientation]
                   && [detailedController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
        return res;
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. masterController -shouldAutorotateToInterfaceOrientation将返回TRUE.StudentViewController中方法的实现如下.

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (IS_IPAD) ? UIInterfaceOrientationIsLandscape(interfaceOrientation)
                         : UIInterfaceOrientationIsPortrait(interfaceOrientation);
    }
    
    Run Code Online (Sandbox Code Playgroud)

获取有关要更改的新方向的信息的能力有助于我决定是否应启用旋转.

使用iOS 6.0:

当设备的方向发生变化时,iOS 6.0版本会发生以下情况

  1. -shouldAutorotate调用拆分视图控制器的方法.它的实现如下

    - (BOOL)shouldAutorotate {
        BOOL res = [masterController shouldAutorotate]
                   && [detailedController shouldAutorotate];
        return res;
     }
    
    Run Code Online (Sandbox Code Playgroud)
  2. detailedController的shouldAutorotate调用navigationController.在StudentsController中实现autorotate功能:

    - (BOOL)shouldAutorotate {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
        return (UIInterfaceOrientationMaskLandscapeLeft
                | UIInterfaceOrientationMaskLandscapeRight);
    }
    
    Run Code Online (Sandbox Code Playgroud)

但是对于iOS 6.0,我无法控制方向.即使supportedInterfaceOrientations方法被调用,当StudentsDetailsController的shouldAutorotate方法被调用,从detailsController的shouldAutorotatemethod,该shouldAutorotateMethod不服从在supportedInterfaceOrientations方法中所提到的选项.

更新:

我阅读文档和中提供了以下注释 …

objective-c uiinterfaceorientation ios6

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

dyld:未加载库:/System/Library/Frameworks/Accounts.framework/Accounts

我在iOS模拟器4.2/4.3上运行应用程序时收到以下错误.它适用于iOS 5.

dyld: Library not loaded: /System/Library/Frameworks/Accounts.framework/Accounts
  Referenced from: /Users/User/Library/Application Support/iPhone Simulator/4.3/Applications/FBFD053F-E816-4114-AFEB-D90A6A67259B/SampleApp.app/SampleApp
  Reason: image not found
Run Code Online (Sandbox Code Playgroud)

我在我的应用程序中使用AssetsLibrary和OpenCV框架.我没有得到错误的原因.

iphone xcode linker ios

5
推荐指数
2
解决办法
2101
查看次数

iOS 6自动旋转混乱

我将整个界面放在一个故事板中.如何让大多数ViewControllers仅支持纵向方向,而只有一对支持所有方向.我无法理解苹果新的自动旋转系统.另外,我怎样才能使这个向后兼容iOS 5?

iphone rotation auto-rotation ios6

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

为什么这个Objective-C代码会引发malloc错误?

我用这个方法在object-c中编码base64字符串,但是应用程序有时会崩溃:

- (NSString *) base64Encode
{
    //Point to start of the data and set buffer sizes
    int inLength = [self length];
    int outLength = ((((inLength * 4)/3)/4)*4) + (((inLength * 4)/3)%4 ? 4 : 0);
    const char *inputBuffer = [self bytes];
    char *outputBuffer = malloc(outLength);
    outputBuffer[outLength] = 0;

    //64 digit code
    static char Encode[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    //start the count
    int cycle = 0;
    int inpos = 0;
    int outpos = 0;
    char temp;

    //Pad the last to bytes, the outbuffer …
Run Code Online (Sandbox Code Playgroud)

c iphone objective-c ios

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

你可以在iPhone上使用C open(const char*name,int flag)函数吗?

我试图移植一个库在iPhone上运行,它使用内存映射和一堆其他东西.我注意到还有一些#defines缺失(O_RDONLY),应该在其中定义<fcntl.h>.

unix iphone gnu objective-c ios

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

如果我引用它,C++ map元素就不会被删除

使用C++标准库的std :: map类,并注意如果我擦除一个元素,然后尝试引用它(下面代码中注释掉的行),该元素将返回值为0.这是预期的?您是否真的必须使用find函数来访问元素而不会在不存在的情况下意外创建元素?

编译器设置:我正在使用g ++编译osx 10.8.3 i686-apple-darwin11-llvm-g ++ - 4.2(GCC)4.2.1(基于Apple Inc. build 5658)(LLVM build 2336.11.00)

using namespace std;

map<int,int> myMap;
map<int,int>::iterator it;

myMap[1] = 5;

for (it=myMap.begin(); it!=myMap.end(); ++it)
    std::cout << it->first << " => " << it->second << '\n';

printf("map test result: %d\n", myMap[1]);

it = myMap.find(1);
myMap.erase( it );

// If I uncomment this it will cause a 0 value to occur at key 1.
//printf("map test result: %d\n", myMap[1]);

if (myMap.find(1) == myMap.end())
    puts("element key 1 is …
Run Code Online (Sandbox Code Playgroud)

c++ std map

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