我有一个UIView阵列.我想检查该数组是否包含具有特定标记的UIView.如果它确实那么我应该得到那个观点,否则我应该收到零.
截至目前我使用以下
// validCells is an array UIView
NSPredicate *p = [NSPredicate predicateWithBlock:^BOOL(id obj, NSDictionary *ignored){
return ((UIView *)obj).tag == i;
}];
UIView *cell = [[validCells filteredArrayUsingPredicate:p] lastObject];
Run Code Online (Sandbox Code Playgroud)
这很好但复杂性是n ^ 2.我想知道是否还有其他更好的办法.
谢谢.
我正在开发一个仅以纵向模式运行的iPhone应用程序.这个应用程序只有视图控制器和1个接口文件(.xib).当用户点击任一工具栏/导航栏上的按钮时,我想在其他一些视图中滑动.让我们说像导航栏上的信息按钮.当我点击它时,UIView应该从底部滑入.当用户点击该视图上的完成按钮时,视图向下滑动.我已经在同一个xib中对这些视图进行了单独的uiview.我也查看了其他人的几个转换示例,但无法得到这个概念.任何人都可以给我一些指示吗?
这个问题随着iOS的其他新版本而反弹.所以我决定记下我从版本到版本之间的所有差异.让我知道他们是否更多.
我有一个包含两个操作的算法.第一操作运行时间为O(n),第二操作的运行时间为O(log n).在这种情况下,完整算法的运行时间是多少?它会是O(n)还是O(n)+ O(log n)?
我的 iOS 应用程序中出现了一些有线崩溃,并且它不是 100% 可重现的。从崩溃日志中,我可以看到无法识别的选择器(属性访问器)被发送到类型不正确的对象(很可能是僵尸对象)。无论如何,我可以用 XCode 来查看我是否正在尝试访问僵尸对象?
谢谢。
我有jar文件,我想与特定的属性文件一起运行.我正在运行以下命令来执行该jar
java –jar –DApp.config.file=local.properties App.jar
Run Code Online (Sandbox Code Playgroud)
使用此命令,我收到以下错误
Could not load properties from class path resource [local.properties]: class path resource [local.properties] cannot be opened because it does not exist
Run Code Online (Sandbox Code Playgroud)
基于我到目前为止所读到的内容,如果你传递-jar,那么你不必担心$ CLASSPATH.我在这里错过了什么吗?
PS - local.properties和jar文件在同一目录中.
所以这是交易,我使用FMDB SQLite Wrapper为我的数据库应用程序.我知道Cord Data就在那里,但我的数据库真的非常庞大,而我想做的就是阅读它.没有新的记录将通过iOS应用程序插入/更新.在这个应用程序的某一点上,我试图从DB中提取记录,这些记录是基于searchTerm和searchPosition的玩家名称和他们的Id.searchTerm工作得非常好.searchPosition查询适用于sqlite3但不适用于iOS应用.我不知道我哪里错了.帮帮我.两种方法的代码如下:
-(IBAction)searchTerm
{
searchTermValue=self.term.text;
self.fmdbUtils = [[[FMDBUtils alloc] initWithDatabase:@"Colts.sql"] autorelease];
FMDatabase *db = [self.fmdbUtils sharedDB];
FMResultSet *rs = nil;
NSString *AgentId = nil;
NSString *PlayerName = nil;
NSString *PlayerId = nil;
ScoutAppDelegate *appDelegate = (ScoutAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.playerList = [[NSMutableArray alloc] init];
NSString * query = @"SELECT * FROM Player WHERE LENGTH (lastname)>0 AND LENGTH (firstname)>0 AND ( lastname LIKE '%' || ? || '%' OR firstname LIKE'%' || ? || '%' OR Height LIKE '%' …Run Code Online (Sandbox Code Playgroud) 我现在正在与GKSession合作.我想连接两台以上的iPad.
我可以使用蓝牙GKSession PeerPickerController连接其中两个.我对这些东西很新.
任何人都可以给我一些指针或指向实现这种模型的教程的链接吗?
我想在iPhone屏幕上存储手指移动的路径.截至目前,我只是阅读触摸并向NSMutableArray添加CGPoints.当我尝试打印该数组中的所有cgpoint时,它是如何缺少中间点的.有更好的方法吗?我们可以直接存储整条路径吗?
这是我正在使用的代码
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
fingerSwiped = NO;
UITouch *touch = [touches anyObject];
lastPoint = [touch locationInView:self.view];
[self.myPoints addObject:[NSValue valueWithCGPoint:lastPoint]];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
fingerSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
UIGraphicsBeginImageContext(self.view.frame.size);
[slateImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), lineWidth);
//CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(),0,0,0, 1.0);
CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), self.drawcolor.CGColor);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
slateImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
[myPoints addObject:[NSValue valueWithCGPoint:lastPoint]];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent …Run Code Online (Sandbox Code Playgroud) 我已经定制了UITableViewCell(从nib加载的静态内容).这个单元格包含一个UILable,我想在用户点击它时更改其值.(将显示PickerView,并且该用户可以为该标签选择值).
所以我创建了以下IBAction.但是,当我尝试将其与UIlable连接时,它不允许我这样做.
-(IBAction)selectlanguage:(UILabel *)sender
{
/*
Code to display pickerview and select appropriate language
*/
self.languageLable.text=@"Spanish";
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.userTranslationLanuage = @"en|sp";
}
Run Code Online (Sandbox Code Playgroud)
谁能告诉我我失踪了什么?
萨米特