我有一个类似这样的方法:
before_filter :authenticate_rights, :only => [:show]
def authenticate_rights
project = Project.find(params[:id])
redirect_to signin_path unless project.hidden
end
Run Code Online (Sandbox Code Playgroud)
我还想在其他一些控制器中使用此方法,因此我将该方法复制到application_controller中包含的帮助器中.
问题是,在某些控制器中,项目的id不是:id
符号,而是fe :project_id
(也:id
存在a(对于另一个模型)
你会如何解决这个问题?是否可以选择向before_filter操作添加参数(传递右侧参数)?
我正在寻找一种方法来打开单击XCode中导航栏时显示的方法弹出窗口.
有没有办法通过使用快捷方式来做到这一点?
如果用户具有扩展权限(例如"stream.publish"),有没有办法检查我的应用程序(画布)?
我只能找到旧sdk的解决方案.
谢谢!
是否有任何图书馆或课程在那里展示360度全景iPhone
?
我在这里找到了这个:http://code.google.com/p/panoramagl/ 但它不是最新的,只适用于旧版本的ios.
我很感谢任何帮助我在ios上创建360度全景视图的链接.
我有多个操作(它们是AFNetworking请求),其中包含需要一些时间才能执行的完成块,以及需要在所有请求结束时保存的Core Data对象.
MyCoreDataObject *coreDataObject;
AFHTTPRequestOperation *operation1 = [[AFHTTPRequestOperation alloc] initWithRequest:request1];
[operation1 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
coreDataObject.attribute1 = responseObject;
sleep(5);
}];
[operation1 start];
AFHTTPRequestOperation *operation2 = [[AFHTTPRequestOperation alloc] initWithRequest:request1];
[operation2 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
coreDataObject.attribute2 = responseObject;
sleep(10);
}];
[operation1 operation2];
[context save:nil];
Run Code Online (Sandbox Code Playgroud)
当然,这不是我想要的,因为请求是异步的.我尝试添加NSOperationQueue,如下所示:
NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init];
[operationQueue setMaxConcurrentOperationCount:2];
AFHTTPRequestOperation *operation1 = [[AFHTTPRequestOperation alloc] initWithRequest:request1];
[operation1 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
coreDataObject.attribute1 = responseObject;
sleep(5);
}];
[operationQueue addOperation:operation1];
AFHTTPRequestOperation *operation2 = [[AFHTTPRequestOperation alloc] initWithRequest:request1];
[operation2 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation …
Run Code Online (Sandbox Code Playgroud) 有没有办法将TinyMCE添加到我自己的WordPress插件中?
我的后端脚本中有一个textarea,并希望将此区域变为TinyMCE WYSIWYG可编辑字段.有没有办法做到这一点?
此代码对我不起作用:
<?php
wp_tiny_mce(false,array("editor_selector" => "test"));
?>
<textarea class="test" id="test" name="test"></textarea>
Run Code Online (Sandbox Code Playgroud)
它显示了javascript错误
f is undefined
Run Code Online (Sandbox Code Playgroud)
Firebug截图:
这也不起作用:
<textarea class="theEditor" id="videogalerie-add_description" name="videogalerie-add_description"></textarea>
Run Code Online (Sandbox Code Playgroud) 以下简单代码:
<li><a href="{{ path('_list') }}">List</a></li>
Run Code Online (Sandbox Code Playgroud)
class="active"
如果当前页面与_list
路线匹配,是否有一种简单的方法来添加?
使用symfony2和twig的最新PR-Release作为模板引擎
我需要与uilabel做一些特殊的调整.
我希望它有1到3行,无论它有什么内容.目前我正在做这样的事情
label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:14.0f];
label.backgroundColor = [UIColor clearColor];
label.numberOfLines = 0;
label.lineBreakMode = UILineBreakModeWordWrap;
label.frame = CGRectMake(114.0f, 88.0f, 187.0f, 0.0f);
[label sizeToFit];
Run Code Online (Sandbox Code Playgroud)
如果文字不太长,那么效果很好.如果字符串类似于@"Hello World"
UILabel只有14点高,如果它有点长,它会扩展.
现在我希望文本应该添加它的默认...
三点,如果文本对于三行太长,但设置在顶部它扩展到第四行.
有人知道如何实现这一目标吗?
如果不清楚,请发表评论.
我得到以下代码:
- (id)init {
if (self = [super init]) {
self.title = @"please wait";
UIBarButtonItem *favorite = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"star.png"] style:UIBarButtonItemStylePlain target:self action:@selector(buttonFavoriteClicked:)];
self.navigationItem.rightBarButtonItem = favorite;
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
但我的按钮看起来仍像一个带有UIBarButtonItemStyleBordered替换文字的按钮 http://img693.imageshack.us/img693/1632/bildschirmfoto20100227ui.png
有没有办法在这个位置设置一个朴素的按钮?
是否有可能创建这样一个内部和外部阴影的UILabel?
alt text http://dl.getdropbox.com/u/80699/Bildschirmfoto%202010-07-12%20um%2021.28.57.png
我只知道shadowColor
和shadowOffset
缩放:
alt text http://dl.getdropbox.com/u/80699/Bildschirmfoto%202010-07-12%20um%2021.39.56.png
谢谢!
iphone ×4
objective-c ×4
cocoa-touch ×3
ios ×2
javascript ×2
php ×2
asynchronous ×1
facebook ×1
httprequest ×1
image ×1
ios4 ×1
macos ×1
panoramas ×1
plugins ×1
ruby ×1
symfony ×1
tinymce ×1
twig ×1
uilabel ×1
url ×1
wordpress ×1
xcode ×1