小编Ani*_*ese的帖子

swift,为ios 7和8编写代码

我有一个测试应用程序我正在用Swift编写,我想要针对iOS 7.但是启用我需要添加的本地通知

application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound 
    | UIUserNotificationType.Alert 
    | UIUserNotificationType.Badge, 
    categories: nil))
Run Code Online (Sandbox Code Playgroud)

但是这个调用在iOS 7中不可用,所以我补充道

var version:NSString = UIDevice.currentDevice().systemVersion as NSString;
if  version.doubleValue >= 8 {
    // ios 8 code
}
Run Code Online (Sandbox Code Playgroud)

ios 8代码块仅在iOS 8(经测试)下运行,但在iOS 7中运行应用程序时我仍然可以使用

dyld:未找到符号:_OBJC_CLASS _ $ _ UIUserNotificationSettings引自:/var/mobile/Applications/AC73969D-1A4C-45AC-99CA-0B3982C1EE36/Timely.app/Timely期望:/System/Library/Frameworks/UIKit.framework/UIKit in /var/mobile/Applications/AC73969D-1A4C-45AC-99CA-0B3982C1EE36/Timely.app/Timely

我认为这是因为二进制文件包含iOS 7中不存在的api符号,但我该如何解决这个问题呢?

ios swift

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

UIButton不是在iOS7中的UIPageViewController中的ViewController中突出显示

我有一个UIButton嵌入在一个视图控制器内UIPageViewController.页面视图控制器处于滚动模式(所以没有手势).当我触摸按钮时,将调用操作方法,但按钮不会发生可见的状态更改(突出显示状态).这意味着按钮看起来没有动过.仅在iOS7中观察到.有什么解决方法吗?

案例1:在普通ViewController中使用和不使用Tap的Button的行为

在点击之前 点击后

案例2:在其中一个PageViewController的viewController中,使用和不使用Tap的Button的行为

在点击之前 在此输入图像描述

ios uipageviewcontroller ios7

16
推荐指数
2
解决办法
2318
查看次数

在swift中使用bridgeToObjectiveC()

什么bridgeToObjectiveC()将迅速做.它似乎将Swift 对象转换为ObjectiveC对象.这与铸造相同吗?

例如,我可以将swift String转换为NSStringlike

var swingString:String = "test string"
var correspondingNSString = swingString.bridgeToObjectiveC()  // Using bridge

var correspondingNSString = swingString as NSString      // type casting
Run Code Online (Sandbox Code Playgroud)

我想知道两者是否相同?

ios swift

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

UICollectionView和自定义UICollectionReusableView不起作用

我正在尝试UICollectionReusableViewUICollectionView标题中使用自定义(具有自己的类和XIB).但是在获取标题后的数据后,我什么都没有.

我的步骤:

  1. viewDidLoad中注册类:

     [self.collectionView registerClass:[CollectionViewHeader class] 
      forSupplementaryViewOfKind: UICollectionElementKindSectionHeader 
      withReuseIdentifier:@"HeaderView"];
    
    Run Code Online (Sandbox Code Playgroud)
  2. 试图显示:

    - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
    {
    UICollectionReusableView *reusableView = nil;
    
    if (kind == UICollectionElementKindSectionHeader) {
        CollectionViewHeader *collectionHeader = [self.collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
    
        NSInteger section = [indexPath section];
        id <NSFetchedResultsSectionInfo> sectionInfo = [fetchRecipes sections][section];
        collectionHeader.headerLabel.text = @"bla-bla-bla";
    
        reusableView = collectionHeader;
    }
    
    return reusableView;
    }
    
    Run Code Online (Sandbox Code Playgroud)

谁能告诉我什么是错的?)感谢您的任何建议

xib ios uicollectionview uicollectionreusableview

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

与Xcode Bots持续集成

我想使用Xcode机器人进行持续集成.我已经安装了OSX Mavericks和Server(版本3).我可以使用Xcode 5.0.1创建机器人.虽然集成它成功地执行分析测试但总是最终的集成结果是失败.

集成失败.意外的内部服务器错误.有关更多详细信息,请参阅集成日志

我没有理解服务器错误日志中的任何内容.由于一些与wiki服务相关的错误,它失败了.

谁能帮我?

Oct 29 10:18:41 AnilV-InetliMac.local xcsbuildd[11285] <Debug>: [CSRemoteServiceClient.m:233 7e026310 +0ms] didReceiveData
Oct 29 10:18:41 AnilV-InetliMac.local xcsbuildd[11285] <Debug>: [CSRemoteServiceClient.m:246 7e026310 +2ms] connectionDidFinishLoading
Oct 29 10:18:41 AnilV-InetliMac.local xcsbuildd[11285] <Debug>: [CSRemoteServiceClient.m:172 7e026310 +0ms] Out of runloop; request completed
Oct 29 10:18:41 AnilV-InetliMac.local xcsbuildd[11285] <Debug>: [CSRemoteServiceProxy.m:79 7e026310 +0ms] Received successful response.
Oct 29 10:18:41 AnilV-InetliMac.local xcsbuildd[11285] <Info>: [CSConfig.m:55 7e026310 +0ms] Reading plist at /Library/Server/Wiki/Config/collabd.plist
Oct 29 10:18:41 AnilV-InetliMac.local xcsbuildd[11285] <Debug>: [XCSBuildHelper.m:97 7e026310 +0ms] Updating bot run with GUID fc16d3af-093e-44aa-8a40-ebfef45bbbd9 …
Run Code Online (Sandbox Code Playgroud)

xcode ios xcode-bots

10
推荐指数
2
解决办法
5029
查看次数

推出Swift应用程序序列

任何人都知道快速应用程序的启动顺序?正如我所看到的,main在快速应用程序中没有任何功能.那么谁负责这样做

// Entry point of a normal iOS app
int main(int argc, char * argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
Run Code Online (Sandbox Code Playgroud)

您的应用程序对象和AppDelegate将在此处创建.但对于快速的应用程序,我想知道谁在创建这些.

如果有人知道,请分享您的想法.

ios swift

10
推荐指数
2
解决办法
3382
查看次数

不支持的NSSortDescriptor(不支持比较器块)

fetchedResultsController设置NSSortDescriptoriam时,获得此错误的NSSortDescriptor不受支持(不支持比较器块).

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
                               entityForName:@"Alarm" inManagedObjectContext: managedObjectContext];
[fetchRequest setEntity:entity];

//Below code is not working and causing error. sorting use the hours&seconds part of the time attribute  

NSSortDescriptor *sort = [[NSSortDescriptor alloc]
                          initWithKey:@"time" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) {

                                  NSCalendar *calendar = [NSCalendar currentCalendar];
                                  NSDateComponents *components1 = [calendar components:(NSHourCalendarUnit|NSMinuteCalendarUnit) fromDate:obj1];
                                  NSDateComponents *components2 = [calendar components:(NSHourCalendarUnit|NSMinuteCalendarUnit) fromDate:obj2];
                                  NSDate *date1 = [calendar dateFromComponents:components1];
                                  NSDate *date2 = [calendar dateFromComponents:components2];


                                  return [date1 …
Run Code Online (Sandbox Code Playgroud)

nssortdescriptor nsfetchedresultscontroller ios

9
推荐指数
2
解决办法
5630
查看次数

如何在NSMutableArray中实现"按值分组"?

我正在使用NSMutableArray.我想像在SQL中那样按日期获取值group by "log_date".

logMuArray (
        {
        "log_currenttime" = "4:30pm";
        "log_date" = "11.12.2011";
        "log_duration" = "1:30";
    },
        {
        "log_currenttime" = "4:33pm";
        "log_date" = "11.12.2011";
        "log_duration" = "2:21";
    },
        {
        "log_currenttime" = "4:40pm";
        "log_date" = "11.12.2011";
        "log_duration" = "5:30";
    },
        {
        "log_currenttime" = "7:30pm";
        "log_date" = "12.12.2011";
        "log_duration" = "1:30";
    },
        {
        "log_currenttime" = "7:33pm";
        "log_date" = "12.12.2011";
        "log_duration" = "2:21";
    },
        {
        "log_currenttime" = "7:40pm";
        "log_date" = "12.12.2011";
        "log_duration" = "5:30";
    },
        {
        "log_currenttime" = "07:16pm";
        "log_date" = "19.12.2011"; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c nsmutablearray

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

Swift vs ObjC初始化过程?

在ObjectiveC中,我们创建了像

 -(instancetype)init()
{
  return [super init]; // Here it returns initialised value
}  

Class *obj =   [[Class alloc]init] 
Run Code Online (Sandbox Code Playgroud)

但迅速的初始化者不会返回任何价值.

来自Swift文档

与Objective-C初始值设定项不同,Swift初始值设定项不返回值.它们的主要作用是确保在第一次使用之前正确初始化类型的新实例.

init()
{
  super.init()
}  

let obj = Class()
Run Code Online (Sandbox Code Playgroud)

现在swift初始化器如何将实例返回到变量obj

如何在swift中进行分配和初始化

ios swift

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

在集合视图中删除整行后,装饰视图未被删除

我已经UICollectionView通过子分类添加了装饰视图UICollectionViewFlowLayout.我m placing decoration view under each row in collection view. It工作得很好.装饰视图出现.但问题是在删除整行项目后,装饰视图不会从集合视图中删除.但页眉和页脚视图正确地重新定位它不是我处理的.删除后我不知道删除装饰视图的位置.帮我.我对装饰视图的计算prepareLayout是很好的装饰视图和框架的数量是正确的

在此输入图像描述 在此输入图像描述

(图1)删除前(图2)删除后

ios uicollectionview

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

此类不是键映射视图的键值编码兼容

我在iOS应用程序中创建了MKMapView应用程序,以便在我的iPhone中显示地图.跑步的时候我得到了这个

错误:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x9847150> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mapview.'
***
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决这个问题吗?提前致谢.

ios

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

将NSDictionary转换为NSMutableArray

我有这个代码:

NSDictionary *jsonGuardado = [self dictionaryFromJson:JSON];
NSLog(@"HOLA %@",jsonGuardado);
NSMutableArray *arrayCodigos = [jsonGuardado objectForKey:@"code"];
codigos = arrayCodigos;
Run Code Online (Sandbox Code Playgroud)

(Codigos是一个NSMutableArray)

NSLOG归还:

HOLA (
        {
        code = 22051310;
    },
        {
        code = 22051311;
    },
        {
        code = 22051312;
    },
        {
        code = 22051313;
    }
)
Run Code Online (Sandbox Code Playgroud)

但就在此之后,消息错误说:

-[JKArray objectForKey:]: unrecognized selector sent to instance

我在谷歌和这里搜索这个错误,我发现的所有问题都没有帮助我.

我正在使用JSONKitfor make使用dictionaryFromJson方法.

json nsdictionary nsmutablearray nsarray ios

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

在Xcode 6中选择不同的模拟器

如何在Xcode 6中选择不同的模拟器(iOS 8除外)?我已经从Xcode-> Preference-> Downloads成功安装了iOS 7模拟器

在此输入图像描述

但它没有在可用的运行模拟器中列出

在此输入图像描述

任何人都知道如何在Xcode 6中安装iOS7模拟器?

xcode ios xcode6

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