小编Gar*_*oal的帖子

将NSAttributedString的子字符串替换为另一个NSAttributedString

我想将a的子串(例如@"replace")替换为NSAttributedString另一个子串NSAttributedString.

我在寻找一个相当于方法NSStringstringByReplacingOccurrencesOfString:withString:NSAttributedString.

string cocoa replace foundation nsattributedstring

52
推荐指数
6
解决办法
3万
查看次数

UITableViewCell在突出显示时使标签的背景清晰

我在UITableViewCell上有一个UIlabel,我是以编程方式创建的(即不是nib或子类).

当单元格突出显示(变为蓝色)时,它会使UILabels的所有背景颜色变为清晰.我有2个UILabels,我不希望这样.目前我在UILabel后面使用UIImageViews使它看起来像背景颜色不会改变.但这似乎是一种效率低下的方法.

当UITableViewCell突出显示时,如何停止某些UILabel的背景颜色变化?

iphone objective-c background-color uitableview uilabel

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

使用CoreText显示NSAttributedString

我听说我可以使用CoreText显示NSAttributedString,谁能说我怎么样(最简单的方法)?

请不要使用CATextLayer或OHAttributedLabel回答.

我知道在这个论坛上有很多关于这方面的问题,但我找不到答案

谢谢!!

iphone nsattributedstring core-text ios

8
推荐指数
2
解决办法
6623
查看次数

UITextfield.text返回null

假设有一个iphone项目的代码是:

      IBOutlet UITextField* numberDisplay;
      @property (strong,nonatomic) IBOutlet UITextField *numberDisplay;
Run Code Online (Sandbox Code Playgroud)

在实现文件和

@synthesize numberDisplay;

在实施文件中.同样在实施中

     -(IBAction)numberClicked:(id)sender {  
     UIButton *buttonPressed = (UIButton *)sender;  
    int val = buttonPressed.tag;  
     if ( [numberDisplay.text compare:@"0"] == 0 ) {  
    numberDisplay.text =[NSString  stringWithFormat:@"%d", val ];  

  } else {  
      numberDisplay.text = [NSString  
                     stringWithFormat:@"%@%d", numberDisplay.text, val ];  
    }

   }
Run Code Online (Sandbox Code Playgroud)

当我运行应用程序时,UITextfield中没有显示任何显示,即使连接是使用IB进行的,并且已经证明是通过查看检查器进行的.即使作为测试,如果我添加线条

    numberDisplay.text = @"a";
    NSLog(@"the value is %@",numberDisplay.text);   
    NSLog(@"the value is %@",numberDisplay);
Run Code Online (Sandbox Code Playgroud)

我得到"两个案例中的值都是(null).任何想法.

有人可以告诉我这两行有什么问题吗?谢谢.


谢谢大家.我从零开始,现在一切正常.看起来我有一个贴错标签的文件.

xcode objective-c ios ios-4.2

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

如何在 iOS 的 UIDatePicker 中阻止天数

我在我的 IOS 应用程序上使用日期选择器,我想知道是否可以阻止几天。例如,我需要阻止一年中的所有星期一,这可能吗?

谢谢。

iphone xcode datepicker uipickerview ios

5
推荐指数
1
解决办法
8071
查看次数

阻止调用子类中的继承方法

我有一个UIView继承了该- initWithFrame:方法的子类.但是,我不希望在我的子类上调用该方法.有没有办法在我的子类上"删除"该方法?

objective-c ios

3
推荐指数
1
解决办法
118
查看次数

从NSMutableString中删除括号

我有一个像这样的NSMutableString:

(
    993,
    12836,
    10630
)
Run Code Online (Sandbox Code Playgroud)

我怎样才能删除括号?

编辑

字符串是此指令的结果:

NSMutableString * result = [labelpost description];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios

-2
推荐指数
1
解决办法
519
查看次数