【问题标题】:How insert linebreaks in NSString for Facebook stream.publish如何在 Facebook stream.publish 的 NSString 中插入换行符
【发布时间】:2011-01-15 19:17:05
【问题描述】:

我看到 Facebook 上的一些应用程序可以将带有换行符的消息发布到用户墙上 - 就像这样:

  1. blablabla
  2. blablabla 等等

我的代码将此文本放在 Facebook 上 - “1. blablabla 2. blablabla 等” 如何在 Facebook 的 stream.publish 的描述部分插入换行符

\n - 不工作

我的代码是

- (void)publishTopToStream{

NSMutableString *topTenArrayString=[[NSMutableString alloc] initWithFormat:@""];

for (int i=0; i<7; i++) {
    NSString *tempString = [[NSString alloc] initWithFormat:@"%d. %@\n ",i+1,[[topTenArray objectAtIndex:i]  personName]];
    [topTenArrayString appendString:tempString];    
    [tempString release];
}

SBJSON *jsonWriter = [[SBJSON new] autorelease];

NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"Top 7 friends", @"name",
                            @"Top 7 friends", @"caption",
                            topTenArrayString, @"description",
                            @"http://www.qqq.net/", @"href",
                            nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               kAppId, @"api_key",
                               @"Share on Facebook",  @"user_message_prompt",
                               attachmentStr, @"attachment",
                               nil];

[_facebook dialog: @"stream.publish"
        andParams: params
      andDelegate:self];}

【问题讨论】:

    标签: iphone facebook


    【解决方案1】:

    我不知道这是否可行,但是您尝试过 \r 吗? 这是一个回车,而不是换行。

    【讨论】:

      【解决方案2】:

      我使用属性,例如:

      attachment = { 
                  name: Super Application Posr
                  href: 'http://apps.facebook.com/superapplication/',
                  caption: 'blahh blahh',
                  description: 'Here is a list of the top Smelly people in the world' ,
                  properties: {
                          1: "Mr Moo",
                          2: "Mrs Moo",
                          3: "Mr Sheep",
                          4: "me"
                          }
                    } 
      

      P.S ^^Javascript,但你明白了

      【讨论】:

      • 安迪,谢谢您的回复,但 iPhone 上的属性仍然出现在一行中 - “1. blablabla 2. blablabla” :(
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 2011-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多