小编chr*_*o16的帖子

Rails嵌套的content_tag

我正在尝试将内容标记嵌套到自定义帮助器中,以创建如下内容:

<div class="field">
   <label>A Label</label>
   <input class="medium new_value" size="20" type="text" name="value_name" />
</div>
Run Code Online (Sandbox Code Playgroud)

请注意,输入与表单无关,它将通过javascript保存.

这是帮手(它会做更多然后只显示html):

module InputHelper
    def editable_input(label,name)
         content_tag :div, :class => "field" do
          content_tag :label,label
          text_field_tag name,'', :class => 'medium new_value'
         end
    end
end

<%= editable_input 'Year Founded', 'companyStartDate' %>
Run Code Online (Sandbox Code Playgroud)

但是,当我调用帮助程序时,不显示标签,只显示输入.如果它注释掉text_field_tag,则显示标签.

谢谢!

ruby-on-rails helpers ruby-on-rails-3

80
推荐指数
2
解决办法
5万
查看次数

将文本添加到CALayer

是否可以在没有子类化UILabelCALayer情况下添加a 并将其绘制成drawInContext:

谢谢!

iphone

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

将Plist(NSString)解析为NSDictionary

所以我有一个plist结构化字符串,它是动态获取的(不是来自文件系统).我如何将此字符串转换为NSDictionary.

我尝试将其转换为NSData,然后转换为带有NSPropertyListSerialization的NSDictionary,但当我尝试访问NSDictionary时,它返回"[NSCFString objectAtIndex:]:无法识别的选择器发送到实例0x100539f40",表明我的词典未成功创建.

NSString的示例(即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>Key1</key> 
 <dict> 
  <key>Test1</key> 
  <false/> 
  <key>Key2</key> 
  <string>Value2</string> 
  <key>Key3</key> 
  <string>value3</string> 
 </dict> 
</dict> 
</plist> 
Run Code Online (Sandbox Code Playgroud)

谢谢!

xml cocoa parsing objective-c plist

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

当节为空时,分组的UITableView显示空白区域

我有一个分组的UITableView,其中并非所有部分都可以一次显示,该表由一些数据驱动,而不是每个记录都有.我的麻烦是,没有某些部分的记录在表格中显示为空白(见图)

替代文字http://img220.imageshack.us/img220/5633/screenshot20100322at228.png

没有页脚/标题.我错过了什么?

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [self getRowCount:section];
}


// Customize the appearance of table view cells.
- (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];
}

cell.textLabel.text = [NSString stringWithFormat:@"section: %d row: %d",indexPath.section,indexPath.row];
// Configure the cell...

return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    float …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview

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

将两个CGPoints转换为CGRect

如果有两种不同CGPoints,我怎么能把它们变成一种CGRect

例:

CGPoint p1 = CGPointMake(0,10);
CGPoint p2 = CGPointMake(10,0);
Run Code Online (Sandbox Code Playgroud)

我该怎么把它变成一个CGRect

iphone core-graphics cgpoint ios cgrect

22
推荐指数
3
解决办法
7218
查看次数

Rails-向redirect_to添加哈希

我需要指定一个哈希来添加到redirect_to.我该怎么做呢?

这就是我的redirect_to的形成方式:

 redirect_to :action => 'show', :id => @consultant.id
Run Code Online (Sandbox Code Playgroud)

我需要去example.com/consultant/#some_hash

谢谢!

ruby-on-rails ruby-on-rails-3

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

在获取百分比时处理第三方付款(使用PayPal)

我知道只需存储收款人的PayPal帐户信息,就可以使用PayPal 坐在付款人和收款人之间.

是否可以获取该交易的一定百分比并将其支付给不同的PayPal帐户.使用我们的网站基本上作为服务费?

如果它有帮助,我可能会使用Active Merchant for rails.

payment paypal ruby-on-rails

15
推荐指数
2
解决办法
3545
查看次数

从Rails架构生成模型

是否可以从rails模式(或迁移)生成rails模型?

mysql schema activerecord ruby-on-rails

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

灰色UISearchBar以编程方式匹配范围栏

我正在尝试重新创建这个UISearchBar(如表搜索示例代码中所示):

替代文字http://img168.imageshack.us/img168/6378/43558113.png

我见过的所有这些例子都涉及使用xib,但我需要以编程方式进行.问题是改变色调颜色也会改变取消按钮的色调:

替代文字http://img243.imageshack.us/img243/1375/screenshot20100527at944.png

有任何想法吗?

iphone uisearchbar tintcolor

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

将GPS坐标转换为坐标平面

这与我提出的另一个问题有些相关:将GPS坐标转换为PDF地图上的位置.这让我到了这一点,现在我坚持数学.

假设我有一个建筑物的平面图,我从建筑物的每个角落采取了gps坐标读数.还假设平面图与纬度和经度对齐.

如何将GPS坐标转换为此地图上的X,Y位置?我似乎无法使数学正确.

替代文字

iphone math gps map coordinate-systems

6
推荐指数
1
解决办法
4871
查看次数