我有一个非常简单的UIScrollView
例子,根本不做它应该做的事情.不确定它是API的错误还是我的代码中的错误.
基本上,我有一个UIViewController
与UIScrollView
它的观点.当我将它添加到UIWindow
并更改iPad的方向时,我会注销UIScrollView
s尺寸,这是错误的(?)报告.
这是我的UIViewController
实现:
@implementation CustomViewController
- (void)loadView {
scrollView = [[[UIScrollView alloc] init] autorelease];
scrollView.delegate = self;
scrollView.backgroundColor = [UIColor redColor];
self.view = scrollView;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CGSize rect = scrollView.frame.size;
NSLog(@"will rotate w%f h%f", rect.width, rect.height);
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CGSize rect = scrollView.frame.size;
NSLog(@"will animate rotation w%f h%f", rect.width, rect.height);
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
CGSize rect = scrollView.frame.size;
NSLog(@"did rotate w%f h%f", rect.width, …
Run Code Online (Sandbox Code Playgroud) 我在IB中有一个绑定到控制器的标签(NSTextField).控制器在awakeFromNIB上,将标签的attributedStringValue设置为包含一些彩色文本和一个或两个链接.
当您看到标签时,它包含正确的字符串值,但某些格式会丢失 - 直到您单击标签,并且它会更新为包含正确的格式.
我正在使用此代码来设置值:
[self.testTextField setAllowsEditingTextAttributes:YES];
[self.testTextField setSelectable:YES];
NSMutableAttributedString *linkString = [[NSMutableAttributedString alloc] initWithString:@"hit this "];
[linkString beginEditing];
NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:@"link"];
NSRange range = NSMakeRange(0, [attrString length]);
[attrString addAttribute:NSLinkAttributeName value:[[NSURL URLWithString:@"http://google.com"] absoluteString] range:range];
[attrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlinePatternDot] range:range];
[attrString addAttribute:NSForegroundColorAttributeName value:[NSColor blackColor] range:range];
[linkString appendAttributedString:attrString];
[linkString appendAttributedString:[[NSAttributedString alloc] initWithString:@" to search"]];
[linkString addAttribute:NSForegroundColorAttributeName value:[NSColor redColor] range:NSMakeRange(0, [linkString length])];
[linkString endEditing];
[self.testTextField setAttributedStringValue:linkString];
Run Code Online (Sandbox Code Playgroud)
基于此示例,您将看到红色字符串和默认Label字体.然后,当您单击标签时,字体会更改大小和面部,并且链接会神奇地呈现.
关于如何在第一次正确渲染字符串的任何想法?
是否可以在Handlebars中以值为准的方式访问属性?
我有一个CollectionView,它使用一个充满模型的ArrayController.CollectionView有一个名为"columns"的属性,用于定义用于呈现的表列配置.
理想情况下,我可以循环遍历每一列(请参见下面的示例),确保只渲染我们想要渲染的列(稍后,应用格式和其他属性)
<tr>
{{#each column in view.controller.columns}}
<td>
{{ view.content.[column.name] }}
</td>
{{/each}}
</tr>
Run Code Online (Sandbox Code Playgroud)
这不起作用,它只返回没有内容.
我也尝试过这些其他款式,看看它们是否有效:
<tr>
{{#each column in view.controller.columns}}
<td>
{{ view.content.name }}
{{ view.content.[column.name] }}
{{valForKey view.content column.name }}
</td>
{{/each}}
</tr>
Run Code Online (Sandbox Code Playgroud)
该valForKey
助手是一个我写的(源在这里),这确实显示正确的值,但不结合,所以价值不更新的属性发生变化时.
在Ember中处理这个用例的最佳方法是什么?
谢谢
我遇到了一个关于flickr API的令人困惑的问题.
当我进行照片搜索(flickr.photos.search)并请求高页码时,我经常会为不同的页码返回重复的照片.这里有三个网址,每个网址应该返回三组不同的图片,然而,它们 - 奇怪 - 返回相同的图片:
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ca3035f67faa0fcc72b74cf6e396e6a7&tags=gizmo&tag_mode=all&per_page=3&page=6820
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ca3035f67faa0fcc72b74cf6e396e6a7&tags=gizmo&tag_mode=all&per_page=3&page=6821
http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ca3035f67faa0fcc72b74cf6e396e6a7&tags=gizmo&tag_mode=all&per_page=3&page=6822
Run Code Online (Sandbox Code Playgroud)
还有其他人遇到过这个吗?我似乎能够在任何标签搜索上重新创建它.
干杯.
当我在我的用户控制器中点击这个destroy方法时,我一直收到以下错误.
AbstractController :: DoubleRenderError(在此操作中多次调用渲染和/或重定向.请注意,您可能只调用渲染或重定向,每次操作最多一次.另请注意,重定向和渲染都不会终止执行操作,因此如果要在重定向后退出操作,则需要执行类似"redirect_to(...)并返回"的操作.):
这是一个奇怪的,因为我老实说只响应一次电话.
这是我的行动:
def destroy
user = User.find(params[:id])
if user.has_role_for? current_client
# then we remove the role
user.has_no_roles_for! current_client
# was that the users only role?
if user.roles.count == 0
user.destroy
end
respond_with head :ok
else
respond_with({:error=>'unauthorised'}, :status => :forbidden)
end
end
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
ruby-on-rails respond-to internal-server-error ruby-on-rails-3
在Cocoa和Lion,我一直在为这个问题自杀,并且想知道是否有人遇到过这个问题并且(希望)找到了解决方案.
我有一个非常简单的项目(代码可以在这里下载:http://cl.ly/2T0N2C1A3K1r2h1q0R1e),其中NSWindowController使用NSWindow上的setFrameOrigin:方法分配窗口的位置.
在第一次运行时,这可以正常工作,但是一旦用户移动窗口,退出并重新启动应用程序,窗口将恢复其先前的位置,而不是使用setFrameOrigin:命令.
NSWindowController已经禁用了级联和自动保存,因此不应该发生这种情况.
此外,我已经在Snow Leopard上进行了测试,代码可以100%运行 - 这是Lion唯一的问题.
有任何想法吗?
我有一个应用程序,它根据用户指定的文件更改用户的桌面背景.
它在10.4和10.5中运行良好,但Apple似乎已经改变了一些系统通知,这意味着我编写的代码不再有效.
我想知道是否有人见过任何例子,或者已经找到了如何改变图像的方法?它们似乎仍然使用com.apple.desktop属性列表,但文件更改的通知似乎不再起作用.
我曾经使用这个命令通知操作系统新的背景:
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.apple.desktop" object:@"BackgroundChanged"];
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
cocoa ×3
ember.js ×1
flickr ×1
ios ×1
ipad ×1
nstextfield ×1
nswindow ×1
objective-c ×1
orientation ×1
osx-lion ×1
respond-to ×1
uiscrollview ×1