小编Rya*_*anR的帖子

在iOS 7中更改后退按钮会禁用滑动以返回导航

我有一个iOS 7应用程序,我在这里设置一个自定义后退按钮,如下所示:

    UIImage *backButtonImage = [UIImage imageNamed:@"back-button"];
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];

    [backButton setImage:backButtonImage forState:UIControlStateNormal];
    backButton.frame = CGRectMake(0, 0, 20, 20);

    [backButton addTarget:self
                   action:@selector(popViewController)
         forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    viewController.navigationItem.leftBarButtonItem = backBarButtonItem;
Run Code Online (Sandbox Code Playgroud)

但是这会禁用iOS 7"从左向右滑动"手势以导航到之前的控制器.有谁知道如何设置自定义按钮并仍然启用此手势?

编辑:我试图设置viewController.navigationItem.backBarButtonItem,但这似乎并没有显示我的自定义图像.

uinavigationcontroller uibarbuttonitem uiviewanimation ios ios7

79
推荐指数
7
解决办法
5万
查看次数

iphone开发:验证来自https网址的证书信息

当用户使用网络浏览器(Safari,Chrome,...)连接到"https网址",例如:"https://encrypted.google.com"时,用户就可以获得有关相关证书的信息这样的"https url"; 也就是说,在连接到网址"https://encrypted.google.com"的情况下,可以验证以下证书信息:

  1. Equifax安全证书颁发机构
  2. *.google.com发布者:Google Internet Authority.证书的到期日期.证书是有效还是无效
  3. 有关证书的更多详细信息,如签名算法,公钥信息,指纹等.

因此,问题是:"为了获得上述信息(或者至少知道证书是否有效),有什么正确的Objective C函数调用?"

提前致谢,

security iphone objective-c ios

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

UICollectionView-如何删除第一个单元格上方的间距?

UICollectionView-如何删除第一个单元格上方的间距?

我有顶部inset = 0,行= 10

在此输入图像描述

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{


if (indexPath.row == 0) {
    return CGSizeMake(collectionView.width, 44);
}
return CGSizeMake(300, 150);
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(0, 10, 10, 10);
}
Run Code Online (Sandbox Code Playgroud)

似乎这与将第一个单元格设置为不同大小有关

如果我在sizeForItemAtIndexPath中删除对行== 0的检查并为所有单元格返回相同的内容,则它与顶部齐平.

有任何想法吗?

ios uicollectionview

4
推荐指数
3
解决办法
7636
查看次数

是否有一种经典或好的方法将不同的指令应用于循环的第一个或最后一个元素?

考虑一个循环.我也对快速枚举感兴趣.所以,它可能是

  • 要么a for(id obj in objects)
  • 或者a [objects enumerate... ]

我想知道是否有一种经典或好的方法(in Objective-C)来区分循环的第一个元素和其他元素.当然,如果只有一种很好的方法来区分最后的元素和其他元素,我也很感兴趣.

是否有一种经典或好的方法将不同的指令应用于循环的第一个或最后一个元素?

cocoa loops enumeration objective-c ios

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

如何查找坐标所在的海洋

我有一些坐标,它总是在海洋中的某个地方.我需要一种方法将坐标转换为一个字符串,告诉坐标落在哪个海洋/海洋.有没有方便的方法呢?

谢谢

cocoa-touch google-maps mapkit ios

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

应用程序崩溃,发送到实例的无法识别的选择器

这是错误Xcode shoy my:

2013-10-25 11:43:35.059 ChineseCheckers [7220:c07] - [HomeViewController播放:]:无法识别的选择器发送到实例0x8a2de20 2013-10-25 11:43:35.062 ChineseCheckers [7220:c07] *终止应用程序未捕获的异常'NSInvalidArgumentException',原因:' - [HomeViewController播放:]:无法识别的选择器发送到实例0x8a2de20'

*第一次抛出调用堆栈:

(0x1af7012 0x14a4e7e 0x1b824bd 0x1ae6bbc 0x1ae694e 0xeed2c0 0x1ab6376 0x1ab5e06 0x1a9da82 0x1a9cf44 0x1a9ce1b 0x278b7e3 0x278b668 0x3e8ffc 0x28fd 0x2def725 0x1)libc ++ abi.dylib:terminate调用抛出异常(lldb)0x8a2de20

我正在设法将背景声音添加到我的应用程序中,我将源代码放入其中

-(IBAction)play
{
    NSString *soundFilePath =[[NSBundle mainBundle] pathForResource: @"larga"ofType: @"mp3"];
    NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
    AVAudioPlayer *newPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: Nil];

    self.player = newPlayer;

    [self.player prepareToPlay];
    [self.player setDelegate: self];
    [self.player play];
    [NSTimer scheduledTimerWithTimeInterval: 30 target: self
                                   selector: @selector(play:) …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios

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