我正在使用以下代码创建UIview:
UIview* baseView = [[UIview alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
//self.view = baseView;
[self.view addSubview:baseView];
[baseView setBackgroundColor:[UIColor blackColor]];
baseView.userInteractionEnabled = YES;
baseView.alpha = 0.7;
Run Code Online (Sandbox Code Playgroud)
唯一的问题是即使我使用mainScreen选项将其设置为全屏,它也会全屏显示,除了UIWindow顶部的5cm线.这有什么理由吗?
我想使用容器视图来启动另一个视图控制器,但我看不到有关如何以编程方式分配它的任何信息.我可以从用户界面做到这一点,但如果我想用coes创建一个,并将其链接到UIviewController,我该怎么做?它的行为是否像普通的UIview一样?
我正在尝试在我的应用程序中实现解析.这里的问题是我得到了这些奇怪的错误,我不知道它们是什么意思:

我试过:
1)改变架构,但最新版本的Xcode不允许我自己设置(例如arm64).2)我试图删除可能存在冲突的SDK(Dropbox).3)我已链接到二进制4)我已添加所有必需的框架.
直到现在还没有解决方案......
如何使UITextView可滚动但不可编辑?
我试过这个:
textmessage.enabled = NO;
textmessage.userInteractionEnabled = YES;
Run Code Online (Sandbox Code Playgroud)
......但是不起作用......
我有一个集成了Facebook请求的应用程序.当我向帐户发送请求时,通知会在Facebook.com网站上显示通知,但不会出现在IOS上运行的移动Facebook应用程序上.如果我打开通知选项卡,我会看到除了我的网站上显示的所有通知.这有什么特别的原因吗?
我试图比较两个NSDates,以了解它们是否在同一天.这是两个日期(第二个日期始终是当前日期,NSDate()):
2015-08-23 22:00:00 +0000 2015-08-23 19:13:45 +0000
很明显,日期是在同一天,因为23 = 23.但是我似乎无法在代码中建立这个.我试过了:
1)
let date = tripObject["tripDate"] as! NSDate
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let str = dateFormatter.stringFromDate(date)
let date2 = NSDate()
let dateFormatter2 = NSDateFormatter()
dateFormatter2.dateFormat = "yyyy-MM-dd"
let str2 = dateFormatter2.stringFromDate(date2)
println(". \(str) and \(str2) .")
Run Code Online (Sandbox Code Playgroud)
这给出了2015-08-24和2015-08-23
2)
let dateComponents = NSCalendar.currentCalendar().components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay, fromDate: tripObject["tripDate"] as! NSDate)
let dateComponents2 = NSCalendar.currentCalendar().components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay, fromDate: NSDate())
Run Code Online (Sandbox Code Playgroud)
这给出了不同的日期组件.
3)
if NSCalendar.currentCalendar().isDate(firstDate!, inSameDayAsDate: secondDate!){
Run Code Online (Sandbox Code Playgroud)
4)
if …Run Code Online (Sandbox Code Playgroud) 我使用此代码删除索引处的对象:
-(IBAction)deleteMessage:(id)sender{
UIButton *button = (UIButton*) sender;
for (UIImageView *imageView in imageArray)
{
if ([imageView isKindOfClass:[UIImageView class]] && imageView.tag == button.tag)
{
if (imageView.frame.size.height == 60) {
x = 60;
}
if (imageView.frame.size.height == 200) {
x = 200;
}
for (UITextView *text in messagetext)
{
for (UITextView *name in messagename)
{
if ([text isKindOfClass:[UITextView class]] && text.tag == button.tag && text.tag== name.tag)
{
[imageView removeFromSuperview];
[messagename removeObjectAtIndex:button.tag - 1];
[messagetext removeObjectAtIndex:button.tag - 1];
}
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用多重连接,这是方法之一:
-(void)session:(MCSession *)session didStartReceivingResourceWithName:(NSString *)resourceName fromPeer:(MCPeerID *)peerID withProgress:(NSProgress *)progress
{
NSLog(@"RECEIVING... %@ from peer: %@", progress, peerID);
UIProgressView *progressBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
progressBar.frame = CGRectMake(0, 200, 100, 20);
progressBar.progress = 0.5;
UIButton* btn = [BluetoothDeviceDictionary objectForKey:peerID];
[self.view addSubview:progressBar];
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Alert View Title" message:@"Alert View Text" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertView show];
}
Run Code Online (Sandbox Code Playgroud)
由于某些非常严重的原因,当调用此方法时,我知道由于NSLog的响应而调用它,其余代码不会被执行.NSLog出现后,警报显示20秒(或多或少),并且进度视图永远不会出现.我不明白为什么.对于多重连接框架中的大多数方法都会发生这种情况.这怎么可能?
编辑:实际上进度视图出现了,但是在调用方法之后出现了很多
我使用多重连接在蓝牙上发送文件.进度存储在名为Progress的变量中:
NSProgress* progress;
Run Code Online (Sandbox Code Playgroud)
并以这种方式访问它:
progress.fractionCompleted
Run Code Online (Sandbox Code Playgroud)
当数字发生变化时,如何调用方法来更新我的UIprogressBar?
有一种方法:
-(void)session:(MCSession *)session didStartReceivingResourceWithName:(NSString *)resourceName fromPeer:(MCPeerID *)peerID withProgress:(NSProgress *)progress
{
NSLog(@"RECEIVING... %@ from peer: %@", progress, peerID);
}
Run Code Online (Sandbox Code Playgroud)
但它只被召唤一次......
我试图在屏幕上获得节点的大小.这是代码:
var v1 = SCNVector3(x:0, y:0, z:0)
var v2 = SCNVector3(x:0, y:0, z:0)
carNode.getBoundingBoxMin(&v1, max: &v2)
print(v2)
carNode.scale = SCNVector3(0.9, 1.2, 0.5)
//carNode.transform = SCNMatrix4MakeScale(0.9, 1.2, 0.5)
carNode.getBoundingBoxMin(&v1, max: &v2)
print(v2)
Run Code Online (Sandbox Code Playgroud)
但是,getBoundingBoxMin之前和之后返回的值是相同的,就好像没有考虑缩放一样.这是为什么?我需要此信息来为节点上的物理主体设置正确的大小以进行冲突检测,并确定其他节点是否在距离对象的某个范围内.