小编djr*_*ero的帖子

Swift tableView委托方法没有被调用

我已经创建了一个tableview控制器,但它的委托方法没有被调用.我推荐了几个网站,并没有在我的代码中遇到任何错误.请帮我.

class FriutsTableViewController: UITableViewController {
var fruitsList : [AnyObject] = ["We", "love", "swift"];

override func viewDidLoad() {
    super.viewDidLoad()

    let myCatalog = Catalog()
    fruitsList = myCatalog.fruits;
    //let view = ViewController()

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

override func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
    return 0
}

override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
    return fruitsList.count
}

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
    var cell  = tableView.dequeueReusableCellWithIdentifier("fruitIdentifier") as? UITableViewCell

    if !cell {
        cell = …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

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

如何创建自定义UICollectionViewCell并从URL添加图像?

我想把我从flickr获得的图像加载到uicollectionsview我跟随分配指南但是当我必须这样做时它们都会分崩离析

    cell.imageView.image
Run Code Online (Sandbox Code Playgroud)

它基本上说它无法在uicollectionsviewcell的对象中找到imageView

我也试过这样的方法,但它没有用

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"flickerCell";

UICollectionViewCell *flickerCell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
flickerCell.backgroundColor = [UIColor whiteColor];
UIImageView *recipeImageView = (UIImageView *)[flickerCell viewWithTag:100];
recipeImageView.image = [UIImage imageNamed:[photoURLs objectAtIndex:indexPath.row]];
[flickerCell addSubview:recipeImageView];
return flickerCell;
}
Run Code Online (Sandbox Code Playgroud)

recipieImageView是我得到一些教程的东西.我的单元格在故事板中被命名为flickerCell,而且photURLs有33个我可以在代码中查看的对象.所以它就在那里.还有photoURLs是一个NSMutablearray.在这个方法中我的recipeImageView返回nill ??? 我有一个cell.h,它有imageView

#import <UIKit/UIKit.h>

@interface Cell : UICollectionViewCell
@property (strong, nonatomic) IBOutlet UIImageView *imageView;

@end
Run Code Online (Sandbox Code Playgroud)

所以,如果有人知道一种方式,我可以在uicollectionview中显示photoURLs所有的图像,这将是非常有帮助的

更新 我现在尝试了一种新方法,但仍然无法正常工作.imageView返回nil

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"flickerCell";

Cell *flickerCell = (Cell*) [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

flickerCell.backgroundColor = …
Run Code Online (Sandbox Code Playgroud)

objective-c uiimage ios uicollectionview uicollectionviewcell

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

Xcode 6.1 替换为灰色/不可用

我正在尝试使用 Xcode 中的查找/替换来替换一些已弃用的函数,但由于某种原因它似乎呈灰色。我仍在寻找 Xcode 的方法,所以它可能是为了一些简单的事情,但我找不到它不可用的东西?谢谢

xcode ios

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

将文档目录中的文件复制到文档目录中的目录时出错

我正在尝试将文档目录中的文件复制到文档目录中的目录,但出现错误无法将\xe2\x80\x99t 复制到\xe2\x80\x9cDocuments\xe2\x80\x9d,因为带有同名已经存在。

\n\n

任何帮助,将不胜感激。

\n\n

这是我的代码:

\n\n
let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0])\n        let logsPath = documentsPath.URLByAppendingPathComponent("Logs")\n\n\n        let fileURL = documentsPath.URLByAppendingPathComponent("Database.db")\n\n        do {\n            try       NSFileManager.defaultManager().copyItemAtURL(fileURL, toURL: logsPath)\n        } catch  let error1 as NSError{\n            RZLog.Error ("Error:  \\(error1.localizedDescription)")\n        }\n
Run Code Online (Sandbox Code Playgroud)\n

nsfilemanager ios

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

iOS:确定相册中的照片是否来自相机

我正在尝试让我的应用程序确定photoalbum中的照片是否来自相机.我试图实现的一般流程是

  1. 应用负载,
  2. 应用程序枚举相册
  3. 如果照片的来源是相机,则处理该照片并缓存其信息,以便将来可以忽略.

由于"相机胶卷"可以用其他应用程序中的照片编写,我想检测那些使用相机专门拍摄的照片.

提前致谢

cocoa-touch ios alassetslibrary

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

如何以一对多关系清除/重置所有CoreData

我正在使用coreData,具有一对多的实现,我有一个文件夹实体和一个文件实体.文件夹可以包含许多文件,依此类推.

所以,我有两个ViewControllers,FolderViewController和FileViewController,它们分别包含文件夹和文件.现在我有一个modalView,可以从文件夹和文件viewcontroller访问.在这个VC中,我有一个重置所有数据的按钮.所以,当我点击这个时,我想要重置所有数据.

我使用了这段代码,这个函数是用appdelegate.m编写的,并从我的VC中调用.

- (void)resetToDefault
{
    NSError * error;
    // retrieve the store URL
    NSURL * storeURL = [[__managedObjectContext persistentStoreCoordinator] URLForPersistentStore:[[[__managedObjectContext persistentStoreCoordinator] persistentStores] lastObject]];
    // lock the current context
    [__managedObjectContext lock];
    [__managedObjectContext reset];//to drop pending changes
    //delete the store from the current managedObjectContext
    if ([[__managedObjectContext persistentStoreCoordinator] removePersistentStore:[[[__managedObjectContext persistentStoreCoordinator] persistentStores] lastObject] error:&error])
    {
        // remove the file containing the data
        [[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error];
        //recreate the store like in the  appDelegate method
        [[__managedObjectContext persistentStoreCoordinator] addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error];//recreates the persistent …
Run Code Online (Sandbox Code Playgroud)

core-data persistent-storage ios ios5 ios6

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

Xcode警告符号 - 带有白色CIRCLE的黄色三角形?

所以我习惯看到带有感叹号的红色圆圈和带有感叹号的黄色三角形......但带圆圈的黄色三角形是什么意思?

在此输入图像描述

xcode ios

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

Xcode自定义segue动画

我有两个故事板控制器之间的过渡动​​画的问题.我在storyboard中有一个带有两个视图控制器的singleView项目.

现在我想制作一个自定义过渡动画:

  • 我当前的视图控制器应该消失在左边
  • 新视图控制器应该来自右侧

我已经UIStoryboardSegue上课了.

但是我应该在-(void)perform{}方法中写什么?

非常感谢,

乔纳斯.

xcode animation storyboard segue uistoryboardsegue

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

仍然被Objective C变量范围搞糊涂了

我试图从JSON服务获取一些员工数据.我能够获取数据并将其加载到NSMutableArray中,但我无法在获取数据的方法范围之外访问该数组.

TableViewController已提交

#import <UIKit/UIKit.h>
#import "employee.h"

@interface ViewController : UITableViewController

{
    //NSString *test;
    //NSMutableArray *employees;
}

@end
Run Code Online (Sandbox Code Playgroud)

这是我的m文件:

#define kBgQueue dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define scoularDirectoryURL [NSURL URLWithString: @"https://xxxx"]

#import "ViewController.h"

@interface ViewController()

@end

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    dispatch_async(kBgQueue, ^{

        NSData* data = [NSData dataWithContentsOfURL:
                        scoularDirectoryURL];

        [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
    });
}


- (void)fetchedData:(NSData *)responseData {

    NSError* error;
    NSMutableArray *jsonArray = [NSJSONSerialization JSONObjectWithData: responseData options: NSJSONReadingMutableContainers error: &error];
    id jsonObject = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];

    NSMutableArray *employees = …
Run Code Online (Sandbox Code Playgroud)

objective-c

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

RESTKit 0.20操作队列

我正在尝试实现RESTKit 0.20操作队列,我已经阅读了NSOperationQueue可能也用于创建操作队列的博客.我想使用RestKit操作队列的本机方法.

任何人都可以发布以下代码/示例:

  • 如何在RestKit中使用Operations队列.
  • 设置队列以一次执行一个操作.
  • 如果第一个操作没有完成,那么我需要取消此队列中的待处理操作.

期待听到你的形象.

谢谢.

restkit-0.20

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