禁用iOS Overscroll,但允许正文滚动

我想禁用iOS应用程序在Web应用程序中的滚动,但仍然允许滚动。 $(document).on('touchmove', function(e) { e.preventDefault(); }); 完全禁用滚动(如预期的那样)。 有没有办法做我想做的事情?

更改UITable部分backgroundColor而不丢失部分标题

我已经改变了我的tableviews部分的backgroundColor / backgroundImage。 我使用普通的tableView。 不用担心,这个代码没有问题的工作: -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *sectionView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 728, 40)] autorelease]; sectionView.backgroundColor = [UIColor greenColor]; //For using an image use this: //sectionView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"whiteBackground.png"]]; return sectionView; } 现在的问题是, 节标题不见了。 我用这个代码设置部分的标题: – (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]){ return @""; } else […]

重新加载故事板来改变语言环境

我正在为我的应用程序使用一个本地化的Storyboard。 该应用程序必须有一个选项,即时改变语言。 到目前为止,我已经想出了如何更改应用程序启动期间使用的语言: [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"de", @"en", @"fr", nil] forKey:@"AppleLanguages"]; [[NSUserDefaults standardUserDefaults] synchronize]; //to make the change immediate 并设法通过删除关键窗口的所有子视图重新加载我的整个应用程序,从故事板重新加载初始视图控制器,并使其成为新的根视图控制器。 (它有一些问题,比如pipe理开放资源,但可以完成。) 我唯一无法弄清楚的是如何强制iOS用新语言重新加载故事板? 看起来故事板是以某种方式caching的,并且-UIStoryboad:stroyboardWithName:fromNib不会完全重新加载它,所以它出现在最后一种语言中。 我已经考虑了另外两个select: 有不同的故事板文件为每种语言(这是不可pipe理的,我不想这样做) 在我的所有视图控制器中使用事件侦听器来响应语言变化,并在UI上设置新的string(每次从故事板实例化时都必须调用这些string)。 这个解决scheme需要更多的时间,比我们想要花费的时间更多,同时也极大地增加了错误的可能性。 有没有更聪明的方法? 我不想保持我的应用程序的当前状态,所以重新启动它,就像它被杀死和实现似乎是一个合理的解决scheme。

如何使用“自动布局”为纵向和横向定向configuration不同的布局?

我有一个像附图中的视图 现在我添加约束条件,当方向改变为横向时,视图中的UITextview必须位于屏幕的右侧。 在UItextview上,我添加了下面的约束, 尾随空间:Superview 底部空间:Superview 虽然这些限制显示了一些关于ambugity的警告,但为我做了这个工作。 以下是横向模式的截图。 我的问题是,虽然UItextview被移动到右侧,我想要在横向模式下超级视图顶部的一些额外的宽度。 换句话说,我希望UITextview从现在处于横向模式的位置向下移动一点。 我在思考如何在IB中使用自动布局来做这件事,而我无法想象如何。 任何build议,请。

如何在用户通知中设置重复频率

直到iOS 9我们写这样的local notifications UILocalNotification* localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = pickerDate; localNotification.alertBody = self.textField.text; localNotification.timeZone = [NSTimeZone defaultTimeZone]; localNotification.repeatInterval = NSCalendarUnitMinute; localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 并在本地通知我们有repeatInterval ,现在在WWDC2016苹果宣布其中包含User Notification UNTimeIntervalNotificationTrigger。 UNCalendarNotificationTrigger。 UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:60 repeats:YES]; 上面的代码会在每分钟后触发通知。 但是不能设定date。 NSDateComponents* date = [[NSDateComponents alloc] init]; date.hour = 8; date.minute […]

CG Gradient在模拟器上运行,但不在iPhone上运行

我有一个编译没有问题的代码。 它在iPhone模拟器上运行良好,但在我的设备上,我得到了一个EXC_BAD_ACCESS。 这发生在一个帮助函数绘制渐变。 我遵循这个教程来做到这一点。 我有的代码如下: – (void) drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGColorRef whiteColor = [UIColor whiteColor].CGColor; CGColorRef lightGrayColor = [UIColor colorWithRed:230.0/255.0 green:230.0/255.0 blue:230.0/255.0 alpha:1.0].CGColor; CGColorRef separatorColor = [UIColor colorWithRed:208.0/255.0 green:208.0/255.0 blue:208.0/255.0 alpha:1.0].CGColor; CGRect paperRect = self.bounds; CGRect nameRect = self.nameLabel.frame; CGPoint sepStartPoint = CGPointMake(nameRect.origin.x, nameRect.origin.x + nameRect.size.height + 2); CGPoint sepEndPoint = CGPointMake(nameRect.origin.x […]

在safari ios中打开保存在应用程序中的.mobileconfig文件

我试图在safari中打开一个移动configuration文件(mobileconfig)来安装它,但没有任何工作。 我使用URL Scheme: NSURL *finalURL = [NSURL URLWithString:[NSString stringWithFormat:@"myAppURLScheme://%@",fileName]]; BOOL canOpen = [[UIApplication sharedApplication] openURL:finalURL]; if (canOpen) NSLog(@"can open"); else NSLog(@"can't open"); 日志 – > can open 我试图设置所有的path(该文件是在Documents夹中)文件,而不是文件名,什么都没有。 我该怎么做。 ? 编辑1 :这个应用程序执行相同的操作(打开Safari浏览器来安assembly置) 编辑2 :我认为我必须search的方式发送文件(任何)Safari浏览器,Safari会知道如何处理它。

UISegmentedControl中的两行文本

尝试我可能,我无法解决iOS7 iPhone应用程序的UISegmentedControl错误。 当我创build分段控件时,我使用下面的代码: NSArray *segmentedControlItemArray = [NSArray arrayWithObjects: @"Nominal:\n27 inch", @"Actual:\n700c x 23mm", @"Actual:\n700c x 20mm", nil]; _wheelDiameterSegmentedControl = [[UISegmentedControl alloc] initWithItems:segmentedControlItemArray]; _wheelDiameterSegmentedControl.frame = CGRectMake(0, 102, 290, 50); _wheelDiameterSegmentedControl.selectedSegmentIndex = 0; _wheelDiameterSegmentedControl.tintColor = [UIColor colorWithRed:0.35 green:0.4 blue:0.9 alpha:1.0]; for (id segment in [_wheelDiameterSegmentedControl subviews]) { for (id label in [segment subviews]) { if ([label isKindOfClass:[UILabel […]

如何将场景背景的内容设置为立方体贴图

我试图设置一个场景的背景内容使用大约6个图像的天空盒效果。 我以正确的顺序创build了图像数组,我知道我需要使用 + (instancetype) materialPropertyWithContents:(id)contents 不过,我正在努力解决如何以及在哪里使用该类方法返回包含立方体贴图的属性。

从代码打开地图应用程序 – 在哪里/如何find“当前位置”?

我正在打开地图应用程序,以显示从用户的当前位置到目标坐标的方向,从我的代码。 我正在使用下面的代码来打开地图应用程序。 我按下button时调用此代码。 getCurrentLocation是返回最近更新的位置的方法。 – (void)showDirectionsToHere { CLLocationCoordinate2D currentLocation = [self getCurrentLocation]; // LINE 1 NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", currentLocation.latitude, currentLocation.longitude, destCoordinate.latitude, destCoordinate.longitude]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; } 这里LINE 1中的 [self getCurrentLocation]使用CLLocationManager来确定当前位置并返回值。 注意 :我还没有在LINE1中实现代码。 我刚刚计划这样做。 我的问题是: 这是在地图应用程序被调用时计算当前位置的好习惯吗? 在openURL被调用之前, [self getCurrentLocation ]会返回当前位置? 在打开地图应用程序之前,我必须确定当前位置吗? 我对这些事情有点困惑。 请引导我。 谢谢。