小编moo*_*ots的帖子

UIGestureRecognizer和UITableViewCell问题

我在这样的方法中附加一个UISwipeGestureRecognizera :UITableViewCellcellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
        gesture.direction = UISwipeGestureRecognizerDirectionRight;
        [cell.contentView addGestureRecognizer:gesture];
        [gesture release];
    }
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

但是,该didSwipe方法在成功滑动时始终被调用两次.我最初认为这是因为手势开始和结束,但如果我注销gestureRecognizer本身,它们都处于"结束"状态:

-(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer {

    NSLog(@"did swipe called %@", gestureRecognizer);
}
Run Code Online (Sandbox Code Playgroud)

安慰:

2011-01-05 12:57:43.478 App[20752:207] did swipe called <UISwipeGestureRecognizer: 0x5982fa0; state = Ended; view = <UITableViewCellContentView …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview ipad uigesturerecognizer ios

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

NSTextField - 黑色背景上的白色文本,但黑色光标

我设置了一个NSTextField文本颜色为白色,背景颜色为(黑色尽管没有渲染背景颜色,所以它是透明的).全部在Interface Builder中.

我遇到的问题是光标是黑色的,几乎看不到.光标不代表文字颜色吗?我有什么想法可以解决这个问题?

否则,NSTextField看起来无法编辑.

macos customization cocoa objective-c nstextfield

25
推荐指数
5
解决办法
9951
查看次数

UIView和子视图 - 不透明度

是否有可能将UIView(以及其中的任何其他子视图)设置为不透明度为0.5或者其他什么?不确定这是否可行,但想问一下.

iphone opacity uiview

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

UINavigationBar Touch

当用户点击我的一个视图的导航栏标题时,我想触摸一个事件.

我是否可以访问UINavigationBar标题的视图,以便将触摸事件连接到它,我有点不知所措.

这甚至可能吗?

iphone cocoa-touch uinavigationbar uikit ios

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

UISearchDisplayController和UITableView原型单元崩溃

UIViewController在故事板中设置了一个tableviewUISearchDisplayController.

我正在尝试使用self.tableview中的自定义原型单元格(它连接到故事板中的主表视图).如果self.tableview在我加载视图时返回至少1个单元格,它工作正常,但如果self.tableview没有加载单元格(因为没有数据),并且我加载UISearchBar并搜索,则cellForRowAtIndexPath:方法崩溃:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CustomSearchCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"CustomSearchCell" forIndexPath:indexPath];

    [self configureCell:cell atIndexPath:indexPath];
    return cell;
}

-(void)configureCell:(CustomSearchCell *)cell atIndexPath:(NSIndexPath *)indexPath {
    User *user = [self.fetchedResultsController objectAtIndexPath:indexPath];

    cell.nameLabel.text = user.username;
}
Run Code Online (Sandbox Code Playgroud)

错误:

*** Assertion failure in -[UITableViewRowData rectForRow:inSection:heightCanBeGuessed:]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for rect at invalid index path (<NSIndexPath: 0x9ef3d00> {length = 2, path = 0 …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview uisearchdisplaycontroller ios

20
推荐指数
3
解决办法
6968
查看次数

PHP中的html_entity_decode问题?

我试图将HTML实体从源字符串转换为它们的文字字符等价物.

例如:

<?php

$string = "Hello &#8211; World";
$converted = html_entity_decode($string);

?>
Run Code Online (Sandbox Code Playgroud)

虽然这正确地在屏幕上转换实体,但当我查看HTML代码时,它仍然显示显式实体.我需要更改它,以便它实际上转换实体,因为我没有在HTML页面中使用字符串.

关于我做错了什么的任何想法?

仅供参考我将转换后的字符串发送到Apple的推送通知服务:

$payload['aps'] = array('alert' => $converted, 'badge' => 1, 'sound' => 'default');
$payload = json_encode($payload);
Run Code Online (Sandbox Code Playgroud)

php html-encode html-entities

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

更新推送通知的实时App ID

我在App Store中有一个应用程序,它有一个通配符App ID.我想向它添加推送通知,但不能,因为我们有一个通配符应用程序ID.这是我得到的错误:

只有显式的App ID可用于访问Apple Push Notification服务.请使用具有特定Bundle Identifier的现有App ID或创建一个新ID.

我可以为商店中的实时应用创建新的应用ID吗?这不会导致问题吗?我对如何在这个阶段添加推送感到困惑?

[编辑]我可以使用相同的应用程序ID设置新的,但使用新的包标识符?

干杯

iphone app-store

12
推荐指数
2
解决办法
7492
查看次数

NSDictionary的字节大小

这可能听起来像一个完全愚蠢的问题,但我怎样才能获得NSDictionary的字节大小?我可以将它转换为NSData,然后得到它的长度?

救命!

memory iphone cocoa nsdictionary

11
推荐指数
1
解决办法
5156
查看次数

NSView子视图中断拖动操作

我有一个注册拖动操作的NSView.

在该视图中,我有一个子类NSScrollView,它本身有一个NSImageView.

当拖动到原始的NSView上时,一切都很好,除了当我拖动前面提到的NSImageView时,它似乎插入了拖动并且我不能掉到它上面(或者实际上是它下面的视图.

NSScrollView似乎忽略了拖动并允许它进入底层NSView,但是我如何为NSImageView执行此操作以便拖放注册自身,它的superview(NSScrollView)和底层NSView.

cocoa drag-and-drop objective-c nsview

10
推荐指数
1
解决办法
2308
查看次数

应用程序标识符权利格式不正确 - iOS Xcode 4

我已迁移到Xcode 4,无法再将我的应用程序提交到App Store.每次我通过Xcode或Application Loader提交时,都会收到同样的错误:

"应用程序标识符权利格式不正确......"

用Google搜索指向Entitlements.plist文件,其中application-identifier键应与我的应用程序包ID匹配:例如J1234567885.com.domain.appName

事情就是这样.我的app.plist和Entitlements.plist中的包标识符是相同的!我究竟做错了什么?这是我的Entitlements.plist文件(从未改变过回头看):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>application-identifier</key>
    <string>J1234567885.com.domain.appName</string>
    <key>get-task-allow</key>
    <true/>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

我已经更改了上面的标识符,但只是为了给你一个想法......

iphone entitlements ios

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