我在XCode 6 GM 上UITableView
为iPhone 6模拟器(iOS 8)找到了一个奇怪的白色空间.我试图设置SeparatorInset
故事板和代码,但白色空间直到那里.
以下代码适用于iOS 7,但不适用于iOS 8(iPhone 6模拟器).
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
}
Run Code Online (Sandbox Code Playgroud)
我附上下面的屏幕截图:
我顺便使用AutoLayout.我希望有人可以告诉我一种方法来消除奇怪的白色空间TableView
.
我一直认为函数和方法是一样的,直到我通过"Swift编程语言"电子书学习Swift.我发现我不能greet("John", "Tuesday")
用来调用我在类中声明的函数,如下面屏幕截图中的电子书所示:
我收到一条错误,说"根据此屏幕截图,错过了参数标签'日:'正在通话中 ":
这是代码: -
import Foundation
import UIKit
class ViewController2: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//var dailyStatement = greet("John", "Tuesday")
var dailyStatement = greet("John", day: "Tuesday")
println(dailyStatement)
}
func greet(name: String, day: String) -> String {
return "Hello \(name), today is \(day)."
}
}
Run Code Online (Sandbox Code Playgroud)
经过一些研究,我发现了这篇文章:方法和函数之间的区别,在我看来,我在类中声明的函数实际上被称为方法.因此,与用于调用函数的语法相比,我用于调用方法的语法是不同的.
我在Objective-C编程时从未意识到这种差异.
Swift中的函数和方法有什么区别?
我们何时使用函数?何时使用Swift中的方法?
2014年初,Apple已将iOS 7.0更新为7.1,以便即使应用程序在前台而非后台处于活动状态时也允许位置更新.我们怎么做?
我读过一些文章,比如Apple的iOS 7.1将修复地理定位错误.但是,即使应用程序被终止/终止/暂停,Apple也没有提供与此相关的任何通信,也没有提供有关如何获取位置更新的示例代码.
我已阅读iOS 7.1发行说明.我也找不到任何相关的东西.
那么,即使应用程序被暂停,我们如何实际获得iOS 7和8的位置更新?
我正在尝试测试区域监控,因为我正在获得这样的当前位置:
- (void)startLocationTracking
{
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
// Start location manager
if ([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized) {
locationManager = [LocationTracker sharedLocationManager];
locationManager.delegate = self;
[locationManager startMonitoringSignificantLocationChanges];
}
}
Run Code Online (Sandbox Code Playgroud)
并跟踪区域监控的第一个位置,如下所示:
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:manager.location.coordinate radius:300 identifier:@"first location initializer"];
NSLog(@"0: %@", manager.location);
NSLog(@"1: %@", region);
[manager startMonitoringForRegion:region];
NSLog(@"[locationManager startMonitoringForRegion:%@];", region);
});
}
Run Code Online (Sandbox Code Playgroud)
然后在当前区域的每个出口处,我正在监视新位置,如下所示:
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(@"%s, %@", __PRETTY_FUNCTION__, region);
} …
Run Code Online (Sandbox Code Playgroud) 我发现了一个相关的问题:无法让新的AppLink在iOS或Android上运行但是我不确定它是否与我面临的问题完全相似.因此,我创造了这个问题.
如果我理解正确:https://developers.facebook.com/docs/applinks/ios
当我点击正确的applink与适当的元数据: -
案例1:我安装了应用程序:
预期的操作1:它将导航到应用程序内的特定页面.
案例2:我没有安装应用程序:
预期的行动2:它将指引我下载应用程序的应用商店页面.
以下是我到目前为止所做的配置: -
应用链接网址: http ://watchoverme.parseapp.com/
App Link元数据:
<html>
<head>
<title>Watch Over Me</title>
<meta property="al:ios:app_store_id" content="431208868"/>
<meta property="al:ios:app_name" content="Watch Over Me" />
<meta property="al:ios:url" content="watchoverme://promotion" />
<meta property="al:web:url"
content="https://itunes.apple.com/app/id431208868?mt=8" />
</head>
<body>
Yo!
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在应用程序方面,我添加了自定义网址方案,如下面的屏幕截图: -
到目前为止,我已经测试了以下几种情况: -
场景1:我用一个Button创建了另一个简单的应用程序来打开applink.
按钮的代码: -
- (IBAction)appLinkTapped:(UIButton *)sender {
NSLog(@"appLinkTapped");
UIApplication *app = [UIApplication sharedApplication];
NSString *path = @"watchoverme://promotion";
NSURL *ourURL = [NSURL URLWithString:path]; …
Run Code Online (Sandbox Code Playgroud) 我一直在iOS上开发区域监控大约2个月.最近我们发现了一个小故障,同时在一定半径范围内(约4.7KM或4700米)触发了所有区域.设备的当前位置甚至不靠近任何区域.我不确定是什么原因引发了这一事件.我搜索了StackOverFlow,Apple Developer论坛等,我没有发现任何与我面临的类似问题.
在我正在开发的应用程序中,我们正在监控城市内的8个区域(吉隆坡).有一次,我的同事发现他的手机同时触发了4个地区通知.下面是显示其位置,所有受监控区域,触发4区域通知的潜在半径的地图.
触发通知的屏幕截图:
这是我的位置管理器代码: -
CLLocationManager *locationManager = [LocationTracker sharedLocationManager];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.distanceFilter = kCLDistanceFilterNone;
Run Code Online (Sandbox Code Playgroud)
这是我的didEnterRegion代码: -
-(void)locationManager:(CLLocationManager *)manager
didEnterRegion:(CLRegion *)region{
NSString* message = [NSString stringWithFormat:@"Message"];
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if (state == UIApplicationStateBackground || state == UIApplicationStateInactive)
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [NSDate date];
NSTimeZone* timezone = [NSTimeZone defaultTimeZone];
notification.timeZone = timezone;
notification.alertBody = message;
notification.alertAction = @"Show";
notification.soundName = UILocalNotificationDefaultSoundName; …
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我添加UITabBarController
了“Storyborad”。但现在我想以UITabBarItem
编程方式添加。假设有 5 个按钮,每当用户单击该按钮时,UITabBarController
就会调用my 。“标签栏”中共有 5 个标签。例如:
选项卡名称:项目 1、项目 2、项目 3、项目 4、项目 5。按钮名称:item1、item2、item3、item4、item5。
假设用户单击 item1 按钮UITabBarcontroller
被调用。现在用户应该无法在“tabbarcontroller”中看到 item1 选项卡,他应该能够看到重置的“tabBaritem”。
谁能帮我解决这个问题?如何以编程方式做到这一点?
谢谢。
尼勒什
我一直在努力实现步行,骑自行车和驾驶的路线追踪图.
但是,正如您在下面的屏幕截图中看到的那样,即使我没有步行/骑自行车或驾驶该位置,我的坐标也会不时突然跳起.已在图像上绘制圆圈以指出问题.我的问题是为什么突然坐标跳跃?
这是我的实现快照:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CoordinateModel *coord = [[CoordinateModel alloc] init];
coord.latitude = newLocation.coordinate.latitude;
coord.longitude = newLocation.coordinate.longitude;
ActivityType currentActivityType = [DataManager sharedInstance].activityType;
if (currentActivityType == 0) {
// walking
[appDelegate.walkingCoordinates addObject:coord];
}
else if(currentActivityType == 1) {
[appDelegate.bikingCoordinates addObject:coord];
}
else if(currentActivityType == 2) {
// driving
[appDelegate.drivingCoordinates addObject:coord];
}
self.coordinate = newLocation.coordinate;
}
Run Code Online (Sandbox Code Playgroud) ios ×7
objective-c ×6
ios7 ×2
iphone ×2
applinks ×1
clregion ×1
facebook ×1
function ×1
ios8 ×1
methods ×1
swift ×1
uitabbaritem ×1
uitableview ×1
xcode ×1
xcode6 ×1