我创建了自定义 UITableViewCell。
@interface AnswerCell : UITableViewCell
@property (nonatomic, retain) IBOutlet UILabel *textLabel;
@property (nonatomic, retain) IBOutlet UILabel *detailTextLabel;
@end
Run Code Online (Sandbox Code Playgroud)
并设置detailTextLabel.numberOfLines = 0;
cell = [tableView dequeueReusableCellWithIdentifier:kAnswerIdentifier];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"AnswerCell" owner:self options:nil];
cell=answerCell;
}
cell.detailTextLabel.text = [self extractText:indexPath forLabelAttribute:kDetailTextLabel];
cell.detailTextLabel.font = [self extractFont:indexPath forLabelAttribute:kDetailTextLabel];
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.numberOfLines = 0;
Run Code Online (Sandbox Code Playgroud)
UILabel 仅显示文本的第一行。但为什么?
更新:我的detailTextLabel 的高度= 21。我需要做什么?我需要改变高度=1000吗?
我运行我的应用程序,然后获取我的数据.数据还可以.当我第二次跑步时,我的旧价值出现了问题.怎么了?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Test" inManagedObjectContext:[self managedObjectContext]];
for (int i =0; i<2; i++)
{
Test *test = [[[Test alloc] initWithEntity:entity insertIntoManagedObjectContext:[self managedObjectContext]] autorelease];
test.text = @"Text";
test.index = [NSNumber numberWithInt:i];
}
[self saveContext];
}
-(void) showValues
{
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Test" inManagedObjectContext:[self managedObjectContext]];
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:entity];
NSError *error;
NSArray *array = [[self managedObjectContext] executeFetchRequest:request error:&error];
NSLog(@"Array: %@ ", array);
}
Run Code Online (Sandbox Code Playgroud)
第一次运行
2012-01-22 21:48:52.092 Mew[411:707] Array: ( …Run Code Online (Sandbox Code Playgroud) 是否可以在NSMakeRange中执行负位置?
NSString *string = @"abc";
NSString *myString = [string substringWithRange:NSMakeRange(-1, 1)];
Run Code Online (Sandbox Code Playgroud) scrollRectToVisible不适用于键盘和(下一个/上一个/完成)工具栏.请看图片.
[scrollview scrollRectToVisible: textFieldRect animated:YES];
Run Code Online (Sandbox Code Playgroud)

UITabBarItem图像的最大大小是多少?
我不完全了解sqlite3_finalize.我的初始代码.
while (j < Autors.count)
{
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
{
sqlite3_bind_int(compiledStatement, 1, ((AuthorSettings *)[Autors objectAtIndex:j]).authorId);
if(sqlite3_step(compiledStatement) != SQLITE_DONE)
{
NSLog(@"sqlite3_step error %s", sqlite3_errmsg(database));
sqlite3_busy_timeout(database, 5);
}
else
{
if(sqlite3_prepare_v2(database, sqlStatement_1, -1, &compiledStatement, NULL) == SQLITE_OK)
{
sqlite3_bind_int(compiledStatement, 1, bookId);
if(sqlite3_step(compiledStatement) != SQLITE_DONE)
{
NSLog(@"sqlite3_step error %s", sqlite3_errmsg(database));
sqlite3_busy_timeout(database, 5);
}
else j++;
}
else NSLog(@"sqlite3_prepare_v2 error %s", sqlite3_errmsg(database));
}
}
}
sqlite3_finalize(compiledStatement);
Run Code Online (Sandbox Code Playgroud)
我添加了sqlite3_finalize函数.请检查我.
while (j < Autors.count)
{
sqlite3_finalize(compiledStatement); //**added
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == …Run Code Online (Sandbox Code Playgroud) 我有一个非常奇怪的sqlite语法错误.
const char *statement = "DELETE FROM quotes t1 WHERE t1.id=127";
int returnCode = sqlite3_exec(database, statement, NULL, NULL, &errorMsg);
if (returnCode!=SQLITE_OK)
{
fprintf(stderr, "Error: %s", errorMsg);
sqlite3_free(errorMsg);
}
Error: near "t1": syntax error
Run Code Online (Sandbox Code Playgroud)
但是这段代码效果很好
const char *statement = "DELETE FROM quotes WHERE id=127";
int returnCode = sqlite3_exec(database, statement, NULL, NULL, &errorMsg);
Run Code Online (Sandbox Code Playgroud) 我的代码是:
NSString *buffer = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)name, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8);
NSString *totalString = [NSString stringWithFormat:@"buffer/%@", buffer];
Run Code Online (Sandbox Code Playgroud)
我运行了"构建和分析工具"并看到:"在第979行分配并存储到'缓冲区'中的对象在此点之后不再被引用,并且保留计数为+1(对象泄漏)".
为什么我可能有泄漏CFURLCreateStringByAddingPercentEscapes?
iphone ×5
ios ×4
sqlite ×2
core-data ×1
macos ×1
memory-leaks ×1
nsrange ×1
photolibrary ×1
sql ×1
uiimage ×1
uilabel ×1
uiscrollview ×1
uitabbar ×1
uitableview ×1
uitextfield ×1