小编Par*_*att的帖子

将数据存储在plist或Sqlite数据库中更好吗?

在我的iPhone应用程序中,我有大量数据,即大约1000页的文本.

我应该在哪里存放它们?

我应该使用plist或Sqlite数据库表吗?

哪个会被证明更有效率?

请帮助和建议.

提前致谢.

sqlite iphone plist ios4

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

如何检测主机设备是iPhone还是iPad?

可能重复:
以编程方式检测iPad/iPhone硬件的最佳方式

我正在准备一个应用程序,我想在iPhone和iPad上使用它.

如何检测当前主机设备是iPhone还是iPad?

基于此,我想对用户界面进行更改

iphone cocoa-touch device ios4

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

集成到搜索栏中的活动指示器不会显示在iPhone SDK中

在我的iPhone应用程序中,我想在搜索栏上添加活动指示器.

在搜索时,它应显示活动指示器.

我在XIB中添加了活动指示器并创建了它的插座.

我在搜索结束时隐藏它.

但不显示活动指示器.

问题

我发现搜索功能(比如A)(我为活动指示器设置动画)依次调用另一个函数(比如B),因此主线程用于执行函数B.但是对于动画的活动指示器我们需要主线.

所以我尝试使用performSelectorInBackGround:withObject方法调用函数B. 现在,当我单击搜索时,会显示活动指示器,但功能B的功能不会执行.

有什么可以解决这个问题?

请帮助和建议

谢谢

iphone cocoa-touch objective-c uiactivityindicatorview ios4

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

如何为Nslocal通知设置自定义重复间隔.....?

我是iphone开发的新手.我正在尝试在我的项目中使用NslocalNotification我需要每2小时或每两天或每两个月给予记忆等等.目前我正在使用NslocalNotification重复间隔.但它仅用于工作每小时使用Nscalender的每分钟....

        NSString *InterVal=[freQuencyArr objectAtIndex:index-2];
        NSString *InterValType=[freQuencyArr objectAtIndex:index-1];
        if(![InterVal isEqualToString:@"Every"])
        {  
         result=[InterVal intValue];
        }else
          result=1;
        if([InterValType isEqualToString:@"Day"]){
             notification.repeatInterval= NSDayCalendarUnit;    
        }else if([InterValType isEqualToString:@"Week"]){
            notification.repeatInterval= NSWeekCalendarUnit;    
         }
        else if([InterValType isEqualToString:@"Month"]){
            notification.repeatInterval= NSMonthCalendarUnit;   
        }else if([InterValType isEqualToString:@"days"]){
             notification.repeatInterval=result*24*60*60;
        }
Run Code Online (Sandbox Code Playgroud)

这里如果结果是2取决于IntervalType我需要通知它不能和我一起工作

         if([InterValType isEqualToString:@"days"]){
             notification.repeatInterval=result*24*60*60;
        }
Run Code Online (Sandbox Code Playgroud)

iphone objective-c nsnotifications nsnotificationcenter

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

iPad:[UIScreen mainScreen] .bounds返回错误的坐标

[UIScreen mainScreen].bounds 即使iPad处于横向模式,也会返回(0,0,768,1024).

它应返回(0,0,1024,768)但返回(0,0,768,1024).

可能有什么不对?

objective-c bounds ipad uiscreen

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

这是从NSArray中删除空字符串的正确且最有效的方法吗?

这是从NSArray中删除空字符串的正确且最有效的方法吗?

int main(int argc, char *argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSMutableArray *myStrings = [NSMutableArray arrayWithObjects:(id[]){@"Test 1",@"",@"Test 2",@"Test 3",@""} count:5];
    NSArray *myFilteredArray = [myStrings filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"length > 0"]]; //Non-destructive, myStrings is still intact

    NSLog(@"The original array is: %@",myStrings);
    NSLog(@"The filtered array is: %@",myFilteredArray);

    [myStrings removeObject:@""]; //Destructive. myStrings will never be the same again
    NSLog(@"The altered is: %@",myStrings);
    [pool drain];
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c nsstring nsarray

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

用于混合ARC和非ARC代码的编译器标志将被忽略

我猜这是一个简单的但我无法弄清楚:

我的项目中有三个文件与-fno-obj-arcBuild Phases中设置的链接器标志不兼容ARC .

但是据我所知,这些标志被忽略了.编译器仍抱怨向对象发送保留和释放.

我正在使用Xcode 4.2为项目启用ARC.这些类来自MGSplitView.

有任何想法吗?

谢谢你的帮助

iphone xcode ipad automatic-ref-counting

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

不调用带缓冲区的PreviewCallback和PreviewCallback

我对Android 4.0.x的预览回调有疑问.我设置了一个摄像头,创建一个表面来显示摄像头图像 - on previewCallback事件.一切正常.

但是对于Android 4.0.x,既没有onPreviewCallback调用也没有调用onPreviewCallbackWithBuffer.这个问题有解决方法吗?

我想拍摄一个屏幕截图并且不想使用takePicture()-way,因为它会在短时间内冻结实时图像.

camera android callback

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

如何更改日期选择器中的日期格式

在我的iPhone应用程序中,我需要以yyyy/MM/ddbeloow图像中显示的格式显示日期

在此输入图像描述

但在iPhone日期选择器中,它的格式为MM/dd/yyyy,对于我的应用程序来说,它不是统一的

我尝试更改日期选择器的本地值(使用不同的国家/地区)但不使用默认格式.

如何根据我的要求更改日期选择器上的日期格式?

任何帮助表示赞赏.

iphone objective-c datepicker uidatepicker nsdateformatter

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

当应用程序进入后台状态时,NSCache 删除其所有数据

我正在使用NSCache,我NSCache用来存储图像。我在 上显示图像UITableView。每当我首先添加图像时,它们都会调整大小,然后添加到表格中,然后添加到NSCache. 一切正常。

但是每当我关闭应用程序并再次打开时应用程序进入后台时,我的缓存将是空的,我的应用程序再次调整图像大小然后显示它,因此一开始我会看到一个空表。

我不明白为什么会这样。这是预期的行为NSCache吗?.如果是,那么我们如何改善用户体验,以便使用不会看到滞后。

这是@ipmcc 向我建议的代码

这里的类别是我的实体名称(我使用的是 coreData)

// A shared (i.e. global, but scoped to this function) cache
    static NSCache* imageCache = nil;
    // The following initializes the cache once, and only once
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        imageCache = [[NSCache alloc] init];
    });

    // Generate a cache key sufficient to uniquely identify the image we're looking for
    NSString* cacheKey = [NSString stringWithFormat: @"%@", category.name];
    // Try fetching …
Run Code Online (Sandbox Code Playgroud)

ios nscache appdelegate ios7

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