我正在玩idandersen的钥匙串的scifihifi-iphone代码并遇到以下行为 - 我设置了密码,比如说
[SFHFKeychainUtils storeUsername:@"User" andPassword:@"123"
forServiceName:@"TestService" updateExisting:YES error:&error];
Run Code Online (Sandbox Code Playgroud)
然后从设备中删除测试应用程序并再次安装 - 先前设置的密码似乎仍保留在钥匙串中...
这是预期的行为吗?有没有办法确保我设置的密码将被应用程序删除?
我收到警告说setFont已被弃用?
[button setFont:[UIFont boldSystemFontOfSize:13]];
Run Code Online (Sandbox Code Playgroud)
任何建议如何把它带走..
问题是 - 有没有办法限制MKMapView的最大缩放级别?或者有没有办法跟踪用户何时缩放到没有可用地图图像的级别?
我在UITableView中有一个UILabel.这是我在cellForRowAtIndexPath中编写的代码
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(30.0, 5.0, 250.0, 35.0) reuseIdentifier:CellIdentifier] autorelease];
}
CGRect rect = CGRectMake(30.0, 5.0, 250.0, 35.0);
UILabel *label = [[UILabel alloc] initWithFrame:rect];
label.opaque = NO;
label.font = [UIFont systemFontOfSize:14];
label.numberOfLines = 2;
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor darkGrayColor];
label.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
[label setText:@"Test Message"];
[cell addSubview:label];
[label release];
cell.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Run Code Online (Sandbox Code Playgroud)
我的目的是将单元格和UILabel的背景设置为透明.
但它没有用.任何人都可以告诉我这里缺少什么
谢谢
桑迪普
这样做有什么不同吗?
@class MyViewController;
Run Code Online (Sandbox Code Playgroud)
而不是将.h正常导入到appdelegate.h中
#import "MyViewController.h"
Run Code Online (Sandbox Code Playgroud)
我最近看到一些使用@class方式的例子,并想知道是否有任何差异.
谢谢.
我试图通过连接其他NSString实例来实现常量NSString.
以下是我在实现文件中所做的事情:
static NSString *const MY_CONST = @"TEST";
static NSString *const MY_CONCATENATE_CONST = [NSString stringWithFormat:@"STRING %@", MY_CONST];
Run Code Online (Sandbox Code Playgroud)
它导致以下编译错误:Initializer元素不是常量
我想这是因为stringWithFormat没有返回一个常量的NSString,但由于没有其他方法来连接Obj-C中的字符串,我该怎么做?
谢谢你的帮助,
埃里克.
我有以下一点代码:
NSData *data = [NSData dataWithContentsOfFile:filePath options:0 error:&fileError];
NSString *recipe = @"";
if (fileError == nil) {
recipe = [NSString stringWithUTF8String:[data bytes]];
NSLog(@"Converted Recipe as: %@",recipe);
NSLog(@"Original Data was: %@",data);
} else {
NSLog(@"Error reading file: %@", [fileError localizedDescription]);
}
Run Code Online (Sandbox Code Playgroud)
问题是有时stringWithUTF8String返回null,有时它正确返回文件的内容...... SAME文件.有时它会起作用,有时则不起作用.这是一个来自日志的片段,当它没有....这对我意味着文件读取工作,但由于某种原因,这次转换失败了.如果我再次这样做(这被称为tableView didSelectRowAtIndexPath的结果:所以我可以点击另一行,然后回到这一行.
2010-08-01 16:14:29.031 RecipeBrowse[52056:207] Converted Recipe as: (null)
2010-08-01 16:14:29.037 RecipeBrowse[52056:207] Original Data was: <426c6163 6b656e65 64204361 626f2046 69736820 5461636f 730a0a49 4e475245 4449454e 54533a0a 0a2d200a 0a0a4d45 54484f44 3a0a0a42 4c41434b 454e4544 20434142 4f204649 53482054 41434f53
Run Code Online (Sandbox Code Playgroud)
任何想法如何使这更可靠?
有一个坐标对象有三个变量纬度(NSNumber),经度(NSNumber)和时间(NSDate),为了检查我的模拟器上的程序,我给了下面的代码
[coordinate setLatitude:[NSNumber numberWithDouble:23.234223]];
[coordinate setLongitude:[NSNumber numberWithDouble:73.234323]];
Run Code Online (Sandbox Code Playgroud)
但是当我NSLog coordinate.latitude和coordinate.longitude时,它会显示0.00000
NSLog(@"cordlat : %f",coordinate.latitude);
NSLog(@"cordlong : %f",coordinate.longitude);
Run Code Online (Sandbox Code Playgroud)
可能是什么问题???
如何在Objective C中声明虚函数
virtual void A(int s);
Run Code Online (Sandbox Code Playgroud)
如何在Objective C中声明相同的内容.
-(void)A:(int)s //normal declaration
Run Code Online (Sandbox Code Playgroud) 我想在表格单元格中显示这么多图像.我知道两种显示图像的方法.
一个是为UIImageView创建一个实例并显示它
CGRect rect=CGRectMake(x,y,width,height);
UIImageView *image=[[UIImageView alloc]initWithFrame:rect];
[image setImage:[UIImage imageNamed:@"sample.jpg"]];
Run Code Online (Sandbox Code Playgroud)
另一种方法是,
CGRect rect=CGRectMake(x,y,width,height);
[[UIImage imageNamed:@"sample.jpg"] drawInRect:rect];
Run Code Online (Sandbox Code Playgroud)
现在,我的问题是,这两者有什么区别?哪一个有效?还是有其他功能比这更好?
提前致谢....
objective-c ×6
iphone ×5
ios ×2
cocoa-touch ×1
drawrect ×1
ios4 ×1
keychain ×1
mkmapview ×1
nsnumber ×1
transparent ×1
uiimage ×1
uiimageview ×1
uilabel ×1
zoom ×1