【问题标题】:use of escape sequence转义序列的使用
【发布时间】:2011-07-07 12:53:25
【问题描述】:

我想以 a*b 格式显示图像的高度和宽度。因为我正在使用以下代码。问题是标签未显示正确的值,而高度和 ImagesizeWidth 变量显示正确的值。

UIImage *newImage = image;
NSString *c= @"*";
int height = image.size.height;
int ImageSizeWidth = image.size.width;

//int size = image.size.height * image.size.width;
pixelInformation.text = [NSString stringWithFormat:@"%d%a%d",ImageSizeWidth,c,height];

谁能帮帮我。提前致谢。

【问题讨论】:

    标签: objective-c cocoa-touch ipad uiimage


    【解决方案1】:

    您应该使用 Objective-C 对象的%@ 格式说明符。他们需要实现description

    所以最后一行应该是,

    pixelInformation.text = [NSString stringWithFormat:@"%d%@%d",ImageSizeWidth,c,height];
    

    不是%a。不过你可以直接在字符串中输入*

    pixelInformation.text = [NSString stringWithFormat:@"%d*%d",ImageSizeWidth,height];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-25
      • 1970-01-01
      • 2023-03-15
      相关资源
      最近更新 更多