我试图确定如何UISearchBar延迟呼叫,textDidChange直到几毫秒过去.我的目标是将多个键盘条目聚合到一个远程Web服务调用中.正如我现在所知,我每次按键都会调用服务器,这太过分了.
如果在其中一个UISearchBar委托方法中没有某种方式...是否有其他方法可以实现相同的目标...即只是在用户暂停输入密钥之前不要调用服务器?
我一直在使用这个委托方法:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
Run Code Online (Sandbox Code Playgroud) 我正在寻找可能是我新手问题的简单答案.我知道NSMutableArray只能保存对象,所以当我将double放入数组时,我使用了[myArray addObject:[NSNumber numberWithDouble:aValue]];转换方法.我现在需要做的是将值拉出来作为双倍并将它们平均.我相信我将使用快速枚举方法与FoR循环.
我只需要知道如何让以下工作.
double total;
total = [myArray objectAtIndex:i]
Run Code Online (Sandbox Code Playgroud) 我正在使用sqlite的核心数据..我在AppDelegate中找到了一个现成的应用程序
-(NSManagedObjectModel *) managedObjectModel
{
if(__managedObjectModel != nil)
{
return __managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MYSQLite" withExtension:@"momd"];
__managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return __managedObjectModel;
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中虽然我的SQLite数据库有.sqlite扩展名...这个例子有.momd扩展....这背后的原因是什么?
我的应用程序中出现以下崩溃日志错误:
-[NSNull length]: unrecognized selector sent to instance 0x194adc8
Run Code Online (Sandbox Code Playgroud)
我怎么读这个?这是否意味着:
NSNull'对象发送了一条"长度"消息?NSNull尝试在另一个类上调用选择器时,' '类中的'length'方法崩溃了?此外,如果它是前一个选项,我如何获得堆栈跟踪以查看哪个函数导致此崩溃?该顶行是我日志中唯一的错误.
谢谢
我已经实现了一个UITableViewCell被调用的子类UITableViewCellCustom.当进入编辑模式或当我滑动单元格以显示删除按钮时,我想隐藏我单元格中的标签并在退出编辑模式时显示它.
我在中实现了以下代码 UITableViewCellCustom
- (void)willTransitionToState:(UITableViewCellStateMask)state {
[super willTransitionToState:state];
if ((state == UITableViewCellStateShowingDeleteConfirmationMask) || (state == UITableViewCellStateShowingEditControlMask)) {
[UIView animateWithDuration:0.5
animations:^{rankLabel.alpha = 0.0;}];
}
}
- (void)didTransitionToState:(UITableViewCellStateMask)state {
[super didTransitionToState:state];
if (state == UITableViewCellStateDefaultMask) {
[UIView animateWithDuration:0.5
animations:^{rankLabel.alpha = 1.0;}];
}
}
Run Code Online (Sandbox Code Playgroud)
我有两个问题.
例如,如果我的tableview中有23行.当我显示前5行时,我进入编辑模式.我的rankLabel被隐藏,然后我滚动到我的桌子的底部(到第23行),我正在退出编辑模式.rankLabel再次显示但不是所有单元格,我的单元格6/12和18未正确刷新.任何的想法?
在方法willTransitionToState我animateWithDuration用来轻柔地隐藏我的rankLabel但它不起作用,rankLabel被隐藏但没有过渡.didTransitionToState当我想再次显示标签时,同样的方法非常有效.任何的想法?
感谢您的支持.
我试图存储Double值NSUserDefault但是虽然我能够存储它(因为我的NSLog值显示真值),当我尝试重新加载UITableView时,其Cell值不会更新userdefault中的当前值.
这种奇怪的行为只有在我setUserDefaults从委托方法调用我的方法时才会发生UIAlertView
为什么会出现这种奇怪的行为?
这是我的代码:
- (void)setUserDefaults
{
NSLog(@"setUserDefault : empArray: %d, empCount: %d",empArray.count, empCount);
NSMutableDictionary *empData = [[NSMutableDictionary alloc] init];
if (empArray.count>1)
empData = [empArray objectAtIndex:(empCount-1)]; // because empCount starts from 1. and empArray[0] = empCount 1
else
empData = [empArray objectAtIndex:0];
[userDefault setObject:[NSString stringWithFormat:@"%.2f",[empData objectForKey:@"salary"]] forKey:@"salary"];
NSLog(@"setUserDefaults: salary=%.2f",[[empData objectForKey:@"salary"] doubleValue]);
[empData release];
[self.tblView reloadData];
}
Run Code Online (Sandbox Code Playgroud)
UIAlertView的委托方法如下:
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger) buttonIndex
{
if (alertView.tag == 1) // btnRemoveEmpPressed.
{
if(buttonIndex==0)
{
NSLog(@"buttonIndex …Run Code Online (Sandbox Code Playgroud) 我正在动态创建UITableView.当表视图已从数组填充时,我想添加3个虚拟行.
我的情况是,当有足够的数据时UITableView,然后在空白文本的uitable虚拟行的底部.
这样即使有40条记录,通过向上滚动最后两行也是可见的.假设我的数组计数为14(这是动态/不总是14)那么我如何在索引路径14,15,16中添加三个空行并将其文本设置为:
cell.textlabel.text=@"";
Run Code Online (Sandbox Code Playgroud) 我一直在研究一个使用的iPhone应用程序,如果可以的话我CoreData想使用NSPersistentDocument它.我一直在看有关NSPersistentDocument在iPhone应用程序中使用的讨论,但没有提到哪个iPhone框架定义了NSPersistentDocument?
下面是代码UITableView,但当我滚动它的行为奇怪(太烦人)...这个问题是由于reuseIdentifier ....但不知道如何解决..
- (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier];
NSInteger imgTag = 1;
NSInteger lblTag = 2;
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(2, 2, 52, 52)];
// Image:[UIImage imageNamed:[self.glassType objectAtIndex:indexPath.row]]];
imgView.tag = imgTag;
[cell.contentView addSubview:imgView];
[imgView release];
UILabel *lblName = [[UILabel alloc] initWithFrame:CGRectMake(60, cell.frame.size.height/4, 200, 21)];
// lblName.text = [self.glassName objectAtIndex:indexPath.row];
lblName.tag = …Run Code Online (Sandbox Code Playgroud) 我有一个UITableView用方法UITableViewCells填充的等等.在将UILabel添加到单元格之后,我想更改UITableViewCell的高度.我怎样才能做到这一点?我在该方法中阅读了很多关于这样做的内容,但之前调用了这个,所以调用时新的自定义高度是未知的.cellForRowAtIndexPathUILabelsheightForRowAtIndexPathcellForRowAtIndexPathheightForRowAtIndexPath
那么如何UITableViewCell在cellForRowAtIndexPath方法中设置我的高度呢?
提前谢谢,浪费了很多时间.
iphone ×9
objective-c ×7
ios ×3
uitableview ×3
core-data ×2
cocoa-touch ×1
crash ×1
delegates ×1
double ×1
uialertview ×1
uisearchbar ×1