小编Vik*_*ica的帖子

使用中世纪(小写,非衬里)数字

我有一个客户要求在iOS 7项目中使用某种字体,因为它有中世纪的数字.

有没有办法为NSAttributedString激活这些数字?由于使用了默认的衬里编号,因此也包含在字体中.


这是一个例子.两条线都有相同的字体,没有变体(常规),一旦激活了中世纪数字,第二条线就有默认的衬里数字.

在此输入图像描述

cocoa-touch typography objective-c nsattributedstring ios7

8
推荐指数
1
解决办法
683
查看次数

有谁知道iphone的Addressbook框架的包装器?

任何人都知道AddressBook框架的包装器,它使用起来更友好一点?

iphone cocoa-touch objective-c

7
推荐指数
2
解决办法
3321
查看次数

发布Vs nil - 最佳实践

当我们将内存分配给类变量时,我们应该释放它还是在dealloc方法中将其设置为nil?什么是最佳做法?

iphone cocoa-touch objective-c

7
推荐指数
1
解决办法
977
查看次数

UITableView - 直接设置tableHeaderView属性与实现-viewForHeaderInSection方法

直接设置tableHeaderView/tableFooterView属性有什么区别:

UIView *headerView =  [[UIView alloc] init...];
tableView.tableHeaderView = headerView;
[headerView release];
Run Code Online (Sandbox Code Playgroud)

并实现viewForHeaderInSection/viewForFooterInSection方法?:

- (UIView *)tableView:(UITableView *)tableView 
    viewForHeaderInSection:(NSInteger)section
{   
    UIView *headerView = [[[HeaderView alloc] init...] autorelease];
    return headerView;
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uitableview ios

7
推荐指数
1
解决办法
2万
查看次数

适用于iOS的类似CSS的样式类

我正在为我的iOS应用程序的本机控件实现类似CSS的样式引擎,以避免从plist中读取一大堆样式属性并在每个控件上应用每一个.

(编辑:不,我不想要UIWebView,我需要自定义本机控件.我不想实现纯CSS,只是看起来像CSS的东西,并使用简单的CSS.)

说我有一个像这样结构的plist:

closeButtonStyle = "background:transparent;font:Georgia/14;textColor:#faa"
titleLabelStyle  = "background:transparent;font:Helvetica/12;textAlignment:left"
Run Code Online (Sandbox Code Playgroud)

你可以很容易想象我在这里填充了什么样的属性.

到目前为止,一切正常,我有一个UIStyle类解析这样的声明并将所有找到的值存储在其ivars中; 我也有类别UIView,UILabel,UIButton,...只申报一个-(void)setStyle:(UIStyle *)style方法.仅当定义了样式变量时,此方法才应用样式变量.

正如我所说,一切正常.

我唯一的问题是关于样式字符串的解析.我选择使用NSScanner,但我不确定它是否是最佳选择,并希望得到您的意见.

为了记录,这是我实现我的方式UIStyle:

- UIStyle.h

typedef struct {
    BOOL frame:1;
    BOOL font:1;
    BOOL textColor:1;
    BOOL backgroundColor:1;
    BOOL shadowColor:1;
    BOOL shadowOffset:1;
    BOOL textAlignment:1;
    BOOL titleEdgeInsets:1;
    BOOL numberOfLines:1;
    BOOL lineBreakMode:1;
} UIStyleFlags;

@interface UIStyle: NSObject {
    UIStyleFlags         _has;
    CGRect               _frame;
    UIFont              *_font;
    UIColor             *_textColor;
    UIColor             *_backgroundColor;
    UIColor             *_shadowColor;
    CGSize               _shadowOffset;
    UITextAlignment      _textAlignment;
    UIEdgeInsets …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c styling ios

7
推荐指数
1
解决办法
4042
查看次数

UIColor,UIFont等的外部常量

我有一个constants.m文件,它是许多程序常量的集中集合.要设置颜色,我这样做:

@implementation UIColor (UIColor_Constants) 

+(UIColor *) defaultResultTableBackgroundColor{
    //return [[UIColor colorWithRed:0.6f green:0.004f blue:0.0f alpha:1.0f] retain];
    return [[UIColor colorWithRed:0.1f green:0.004f blue:0.3f alpha:0.3f] retain];
}

+(UIColor *) defaultResultHeaderBackgroundColor{
    return [[UIColor clearColor] retain];
}

@end
Run Code Online (Sandbox Code Playgroud)

在constants.h我有

@interface UIColor (UIColor_Constants) 

+(UIColor *) defaultResultTableBackgroundColor;
+(UIColor *) defaultResultHeaderBackgroundColor;

@end
Run Code Online (Sandbox Code Playgroud)

然后只使用[UIColor defaultResultTableBackgroundColor]我想引用此常量的位置.

我想有一些其他UIColor和UIFont常量,虽然这有效,但似乎比它需要的更复杂.有更简单的方法吗?

cocoa cocoa-touch objective-c extern

7
推荐指数
3
解决办法
6902
查看次数

如何按字母顺序对NSMutable数组中的自定义对象字段进行排序?

我有一个自定义对象,如:

#import <Foundation/Foundation.h>

@interface Store : NSObject{
    NSString *name;
    NSString *address;
}

@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *address;

@end
Run Code Online (Sandbox Code Playgroud)

我有一个包含Store对象的NSMutableArray(storeArray)数组:

store1 = [[Store alloc] init];
store1.name = @"Walmart";    
store1.address = @"walmart address here..";

store2 = [[Store alloc] init];
store2.name = @"Target";
store2.address = @"Target address here..";

store3 = [[Store alloc] init];
store3.name = @"Apple Store";
store3.address = @"Apple store address here..";

//add stores to array
storeArray = [[NSMutableArray alloc] init];
[storeArray addObject:store1];
[storeArray addObject:store2];
[storeArray addObject:store3]; …
Run Code Online (Sandbox Code Playgroud)

objective-c nsmutablearray ios

7
推荐指数
2
解决办法
3260
查看次数

UI问题与ipad的kal日历?

iPad版Kal Calendar有UI问题.在iPad上有一个空的空间,但在iPhone上它很好.我怎样才能让它适合iPad上的框架?

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    [kal.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    [kal.view setFrame:CGRectMake(0, 0,768 ,1004)];

}
Run Code Online (Sandbox Code Playgroud)

我尝试使用上面列出的代码,但它对我不起作用!

在此输入图像描述

cocoa-touch objective-c ipad ios

7
推荐指数
1
解决办法
1809
查看次数

NSNumberFormatter从13000到13K

我想将数字转换为更短的形式NSNumberFormatter.

例如:从23000到23K.

我怎么能用它NSNumberFormatter?

我知道可以自己做计算,但就我而言,这是不正确的方法.

objective-c nsnumberformatter

7
推荐指数
1
解决办法
1400
查看次数

如何将UIDatePicker的日期秒值设置为00?

如何总是得到秒数值" 00" UIDatePicker的日期?

现在我正在获得像这种格式的价值5:30:45,我需要获得这种格式的时间5:30:00.

怎么做到这一点?

cocoa-touch objective-c nsdate uidatepicker ios

7
推荐指数
3
解决办法
4180
查看次数