有没有一种标准的方法来设置一个表允许编辑就地,有点像这样:

我目前只需要可编辑的文本,但我将来可能需要UISwitches或UISliders.
在我的应用程序中,有一个集合视图,显示从Web服务检索的一组图像.每个图像都有标签.因此,该应用程序还可以使用标签过滤图像.
现在我正在尝试向此应用添加推送通知.将新图像添加到服务器时会发送推送通知.这些图像标记为最新.我通过推送通知将该标记作为消息传递,我需要的是当用户点击推送通知以打开应用程序时,它应该将最新的新图像加载到集合视图中.
我已经完成了一半.我收到推送通知,并将消息成功发送到文件中的didReceiveRemoteNotification方法AppDelegate.m.现在我需要将它传递给集合视图所在的视图控制器.我陷入了困境.我无法弄清楚如何将其发送到视图控制器.
我尝试在App委托中声明一个属性,为它分配消息值并从视图控制器中引用它,但它不起作用.我绑定了代表,通知中心,用户默认值但没有任何效果.
任何人都可以告诉我如何做到这一点?
谢谢.
编辑:
这是我的代码.我尝试的最后一种方法是本地通知.
AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"PushNotificationMessageReceivedNotification" object:nil userInfo:userInfo];
}
Run Code Online (Sandbox Code Playgroud)
ViewController.m
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(remoteNotificationReceived:) name:@"PushNotificationMessageReceivedNotification"
object:nil];
}
- (void)remoteNotificationReceived:(NSNotification *)notification
{
NSLog(@"Notification: %@", notification.userInfo);
NSString *msg = [[notification.userInfo valueForKey:@"aps"] valueForKey:@"alert"];
self.label.text = msg;
}
Run Code Online (Sandbox Code Playgroud) image push-notification apple-push-notifications viewcontroller ios
给定a的下面的函数NSString从该字符串中删除HTML标记并将结果也作为a返回NSString.
private func removeHTMLTags(source: NSString) -> NSString {
var range = NSMakeRange(0, 0)
let HTMLTags = "<[^>]*>"
var sourceString = source
while sourceString.rangeOfString(HTMLTags, options: NSStringCompareOptions.RegularExpressionSearch).location != NSNotFound {
range = sourceString.rangeOfString(HTMLTags, options: NSStringCompareOptions.RegularExpressionSearch)
sourceString = sourceString.stringByReplacingCharactersInRange(range, withString: "")
}
return sourceString;
}
Run Code Online (Sandbox Code Playgroud)
我试图用纯粹的Swift重写它.我Range在Swift中面临类型问题.
在原始代码函数中,range变量声明为type NSRange.在我的版本中,我不能这样做,因为sourceString.rangeOfString(HTMLTags, options: NSStringCompareOptions.RegularExpressionSearch)while循环中的行返回类型Range<String.Index>,它会给我错误无法将表达式的类型'()'转换为'NSRange'类型.
所以我声明了这个变量,var range = Range(start: 0, end: 0)但现在我得到了一些新的错误.
无法将表达式的类型'()'转换为在行中键入'Range'错误
range = sourceString.rangeOfString(HTMLTags, options: NSStringCompareOptions.RegularExpressionSearch) …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过CocoaPods为我正在开发的Swift项目添加Google Maps SDK for iOS,因为CocoaPods现在支持Swift.
这是我的podfile.
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '7.0'
pod 'Google-Maps-iOS-SDK'
Run Code Online (Sandbox Code Playgroud)
Pod安装成功完成,我可以导入这样的框架,import GoogleMaps没有任何编译错误.
但后来我继续添加了一个UIView并将其类设置为GMSMapView并将IBOutlet添加到我的视图控制器并构建项目.我收到以下错误.
链接器命令失败,退出代码为1(使用-v查看调用)

我已经添加并使用了Objective-C中编写的库,如MagicalRecord,MBProgressHUD在Swift项目上没有任何问题.
我也在这里上传了一个演示Xcode项目.
有什么办法解决这个问题?
我能够成功验证用户的Touch ID.但是,一旦触摸ID身份验证成功,检索用户登录名和密码以执行登录的最安全方法是什么.
对于iTunes连接应用程序,一旦触摸ID登录成功,似乎它将在本地检索密码并将其填入密码UITextField.我猜它正在使用钥匙串.
但是,将用户凭据存储在iPhone本身上是否安全?还有其他方法吗?

我有一个UIImageView视图控制器.是否可以使图像视图的某些区域可以进行处理?
示例:我有一张地图图片.只允许POI可点击.不是整个形象.这可能吗?
我正在将核心数据数据库中的对象列表加载到表视图中.
class ScheduleViewController: UITableViewController {
private var items: [AnyObject]?
// MARK: - Table view data source
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if let itemCount = items?.count {
return itemCount
}
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("DayScheduleCell", forIndexPath: indexPath) as DayScheduleCell
if let act = items[indexPath.row] as Activity {
if act.client != nil {
// ...
}
}
return cell
}
}
Run Code Online (Sandbox Code Playgroud)
在闭包内检索数据,因此我已将items数组声明为可选,因为它在第一次运行时可能为零.
我收到错误'[AnyObject]?' …
我写了一个小应用程序.我已将数据库特定信息放在属性文件中.
db.url=jdbc:mysql://localhost:3306/librarydb
db.user=root
db.passwd=pas$w0rd
Run Code Online (Sandbox Code Playgroud)
当我构建应用程序以获取可执行jar文件时,属性文件包含在其中.将这些信息放在属性文件中的全部目的是允许用户更改这些信息,但这使得它变得不可能.
如何包含不包含jar文件的属性文件?有点像你在.NET应用程序中使用AppSettings文件.
我是Java的新手,所以如果你能把它分解为一系列步骤我会很感激.
谢谢.
编辑:
这就是我从程序中的属性文件中获取值的方法.
public class DatabaseHandler {
public static Connection connectToDb() {
Connection con = null;
Properties props = new Properties();
InputStream in = null;
try {
in = DatabaseHandler.class.getResourceAsStream("database.properties");
props.load(in);
in.close();
String url = props.getProperty("db.url");
String user = props.getProperty("db.user");
String password = props.getProperty("db.passwd");
con = DriverManager.getConnection(url, user, password);
} catch (Exception ex) {
Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
}
return con;
}
}
Run Code Online (Sandbox Code Playgroud) 我得到一个大致看起来像这样的JSON响应.
{
"status": "success",
"data": [
{
....
}
]
}
Run Code Online (Sandbox Code Playgroud)
该status字段可以有两个值:成功或失败.
所以在我的代码中,我有以下枚举.
private enum Status {
SUCCESS("success", 0),
FAIL("fail", 1);
private String stringValue;
private int intValue;
private Status(String toString, int value) {
stringValue = toString;
intValue = value;
}
@Override
public String toString() {
return stringValue;
}
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是在switch语句中,我需要检查状态值并在每个条件下执行代码.
String status = jsonObj.getString("status");
switch (status) {
case Status.SUCCESS.toString():
Log.d(LOG_TAG, "Response is successful!");
case Status.FAIL.toString():
Log.d(LOG_TAG, "Response failed :(");
default:
return;
}
Run Code Online (Sandbox Code Playgroud)
但是我在每种情况下都得到Constant …
我计划在Swift项目中使用Google Drive API.我正在尝试通过CocoaPods(v0.39.0)添加Drive SDK.下面是我的Podfile.
platform :ios, '8.0'
use_frameworks!
pod 'Google-API-Client/Drive'
Run Code Online (Sandbox Code Playgroud)
我use_frameworks!添加了标志,以便CocoaPods可以将Objective-C pod转换为Swift框架而不是静态库.
Pod安装成功.但是,当我构建项目时,我收到以下错误.
类"GTMHTTPUploadFetcher"的重复接口定义
删除DerivedData文件夹并清理项目不起作用.
我也试过没有添加use_frameworks!,然后通过桥接头方式添加库.这没有问题.事情是我所有其他依赖项工作与它打开.不幸的是,CocoaPods 不 支持仅针对某些pod 播放该标志.
是否有解决此问题的解决方法?
正如Google的文档中所述,Google工程师据称会监控使用google-drive-sdk标记的问题,所以我希望至少他们会看到这个问题并尽快解决.